diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cb5b3abfda23a..40f730bb47153 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -275,6 +275,7 @@ import { getEntityNameFromTypeNode, getErrorSpanForNode, getEscapedTextOfIdentifierOrLiteral, + getEscapedTextOfJsxAttributeName, getESModuleInterop, getExpandoInitializer, getExportAssignmentExpression, @@ -350,6 +351,7 @@ import { getSymbolNameForPrivateIdentifier, getTextOfIdentifierOrLiteral, getTextOfJSDocComment, + getTextOfJsxAttributeName, getTextOfNode, getTextOfPropertyName, getThisContainer, @@ -593,6 +595,7 @@ import { isJsxAttributeLike, isJsxAttributes, isJsxElement, + isJsxNamespacedName, isJsxOpeningElement, isJsxOpeningFragment, isJsxOpeningLikeElement, @@ -807,7 +810,6 @@ import { MappedTypeNode, MatchingKeys, maybeBind, - MemberName, MemberOverrideStatus, memoize, MetaProperty, @@ -13517,7 +13519,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean { const list = obj.properties as NodeArray; return list.some(property => { - const nameType = property.name && getLiteralTypeFromPropertyName(property.name); + const nameType = property.name && (isJsxNamespacedName(property.name) ? getStringLiteralType(getTextOfJsxAttributeName(property.name)) : getLiteralTypeFromPropertyName(property.name)); const name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined; const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected); @@ -19590,8 +19592,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function *generateJsxAttributes(node: JsxAttributes): ElaborationIterator { if (!length(node.properties)) return; for (const prop of node.properties) { - if (isJsxSpreadAttribute(prop) || isHyphenatedJsxName(idText(prop.name))) continue; - yield { errorNode: prop.name, innerExpression: prop.initializer, nameType: getStringLiteralType(idText(prop.name)) }; + if (isJsxSpreadAttribute(prop) || isHyphenatedJsxName(getTextOfJsxAttributeName(prop.name))) continue; + yield { errorNode: prop.name, innerExpression: prop.initializer, nameType: getStringLiteralType(getTextOfJsxAttributeName(prop.name)) }; } } @@ -29264,7 +29266,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, getEscapedTextOfJsxAttributeName(attribute.name)); } else { return getContextualType(attribute.parent, contextFlags); @@ -30398,12 +30400,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { attributeSymbol.links.target = member; attributesTable.set(attributeSymbol.escapedName, attributeSymbol); allAttributesTable?.set(attributeSymbol.escapedName, attributeSymbol); - if (attributeDecl.name.escapedText === jsxChildrenPropertyName) { + if (getEscapedTextOfJsxAttributeName(attributeDecl.name) === jsxChildrenPropertyName) { explicitlySpecifyChildrenAttribute = true; } if (contextualType) { const prop = getPropertyOfType(contextualType, member.escapedName); - if (prop && prop.declarations && isDeprecatedSymbol(prop)) { + if (prop && prop.declarations && isDeprecatedSymbol(prop) && isIdentifier(attributeDecl.name)) { addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText as string); } } @@ -47850,8 +47852,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } const { name, initializer } = attr; - if (!seen.get(name.escapedText)) { - seen.set(name.escapedText, true); + const escapedText = getEscapedTextOfJsxAttributeName(name); + if (!seen.get(escapedText)) { + seen.set(escapedText, true); } else { return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); @@ -47864,25 +47867,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } 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; - } + if (isPropertyAccessExpression(node) && isJsxNamespacedName(node.expression)) { + return grammarErrorOnNode(node.expression, Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names); } - - 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); - } + if (isJsxNamespacedName(node) && getJSXTransformEnabled(compilerOptions) && !isIntrinsicJsxName(node.namespace.escapedText)) { + return grammarErrorOnNode(node, Diagnostics.React_components_cannot_include_JSX_namespace_names); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7816d4ec7976e..d5460a49e3928 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2893,6 +2893,10 @@ "category": "Error", "code": 2638 }, + "React components cannot include JSX namespace names": { + "category": "Error", + "code": 2639 + }, "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d15e4de4be6e0..16d111d3659be 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -289,6 +289,7 @@ import { JsxEmit, JsxExpression, JsxFragment, + JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, @@ -2283,6 +2284,8 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri return emitJsxSelfClosingElement(node as JsxSelfClosingElement); case SyntaxKind.JsxFragment: return emitJsxFragment(node as JsxFragment); + case SyntaxKind.JsxNamespacedName: + return emitJsxNamespacedName(node as JsxNamespacedName); // Synthesized list case SyntaxKind.SyntaxList: @@ -4225,6 +4228,12 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri } } + function emitJsxNamespacedName(node: JsxNamespacedName) { + emitIdentifierName(node.namespace); + writePunctuation(":"); + emitIdentifierName(node.name); + } + function emitJsxTagName(node: JsxTagNameExpression) { if (node.kind === SyntaxKind.Identifier) { emitExpression(node); diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index d4c3f2e345c6d..9399263537ad9 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -267,6 +267,7 @@ import { JSDocVariadicType, JsxAttribute, JsxAttributeLike, + JsxAttributeName, JsxAttributes, JsxAttributeValue, JsxChild, @@ -275,6 +276,7 @@ import { JsxElement, JsxExpression, JsxFragment, + JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, @@ -908,6 +910,8 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode updateJsxSpreadAttribute, createJsxExpression, updateJsxExpression, + createJsxNamespacedName, + updateJsxNamespacedName, createCaseClause, updateCaseClause, createDefaultClause, @@ -5582,7 +5586,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined) { + function createJsxAttribute(name: JsxAttributeName, initializer: JsxAttributeValue | undefined) { const node = createBaseDeclaration(SyntaxKind.JsxAttribute); node.name = name; node.initializer = initializer; @@ -5594,7 +5598,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined) { + function updateJsxAttribute(node: JsxAttribute, name: JsxAttributeName, initializer: JsxAttributeValue | undefined) { return node.name !== name || node.initializer !== initializer ? update(createJsxAttribute(name, initializer), node) @@ -5654,6 +5658,26 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode : node; } + // @api + function createJsxNamespacedName(namespace: Identifier, name: Identifier) { + const node = createBaseNode(SyntaxKind.JsxNamespacedName); + node.namespace = namespace; + node.name = name; + node.transformFlags |= + propagateChildFlags(node.namespace) | + propagateChildFlags(node.name) | + TransformFlags.ContainsJsx; + return node; + } + + // @api + function updateJsxNamespacedName(node: JsxNamespacedName, namespace: Identifier, name: Identifier) { + return node.namespace !== namespace + || node.name !== name + ? update(createJsxNamespacedName(namespace, name), node) + : node; + } + // // Clauses // diff --git a/src/compiler/factory/nodeTests.ts b/src/compiler/factory/nodeTests.ts index 54cbe50462c40..bfe0ec7de9fe6 100644 --- a/src/compiler/factory/nodeTests.ts +++ b/src/compiler/factory/nodeTests.ts @@ -128,6 +128,7 @@ import { JsxElement, JsxExpression, JsxFragment, + JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, @@ -963,6 +964,10 @@ export function isJsxExpression(node: Node): node is JsxExpression { return node.kind === SyntaxKind.JsxExpression; } +export function isJsxNamespacedName(node: Node): node is JsxNamespacedName { + return node.kind === SyntaxKind.JsxNamespacedName; +} + // Clauses export function isCaseClause(node: Node): node is CaseClause { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e6912998b1665..64257c7203935 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -221,6 +221,7 @@ import { JsxElement, JsxExpression, JsxFragment, + JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxOpeningLikeElement, @@ -1030,6 +1031,10 @@ const forEachChildTable: ForEachChildTable = { [SyntaxKind.JsxClosingElement]: function forEachChildInJsxClosingElement(node: JsxClosingElement, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined { return visitNode(cbNode, node.tagName); }, + [SyntaxKind.JsxNamespacedName]: function forEachChildInJsxNamespacedName(node: JsxNamespacedName, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined { + return visitNode(cbNode, node.namespace) || + visitNode(cbNode, node.name); + }, [SyntaxKind.OptionalType]: forEachChildInOptionalRestOrJSDocParameterModifier, [SyntaxKind.RestType]: forEachChildInOptionalRestOrJSDocParameterModifier, [SyntaxKind.JSDocTypeExpression]: forEachChildInOptionalRestOrJSDocParameterModifier, @@ -6102,20 +6107,31 @@ namespace Parser { function parseJsxElementName(): JsxTagNameExpression { const pos = getNodePos(); - scanJsxIdentifier(); // JsxElement can have name in the form of // propertyAccessExpression // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - let expression: JsxTagNameExpression = token() === SyntaxKind.ThisKeyword ? - parseTokenNode() : parseIdentifierName(); + let expression: JsxTagNameExpression = parseJsxTagName(); while (parseOptional(SyntaxKind.DotToken)) { expression = finishNode(factoryCreatePropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos) as JsxTagNamePropertyAccess; } return expression; } + function parseJsxTagName(): Identifier | JsxNamespacedName | ThisExpression { + const pos = getNodePos(); + scanJsxIdentifier(); + + const isThis = token() === SyntaxKind.ThisKeyword; + const tagName = parseIdentifierName(); + if (parseOptional(SyntaxKind.ColonToken)) { + scanJsxIdentifier(); + return finishNode(factory.createJsxNamespacedName(tagName, parseIdentifierName()), pos); + } + return isThis ? finishNode(factory.createToken(SyntaxKind.ThisKeyword), pos) : tagName; + } + function parseJsxExpression(inExpressionContext: boolean): JsxExpression | undefined { const pos = getNodePos(); if (!parseExpected(SyntaxKind.OpenBraceToken)) { @@ -6148,9 +6164,8 @@ namespace Parser { return parseJsxSpreadAttribute(); } - scanJsxIdentifier(); const pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos); + return finishNode(factory.createJsxAttribute(parseJsxAttributeName(), parseJsxAttributeValue()), pos); } function parseJsxAttributeValue(): JsxAttributeValue | undefined { @@ -6169,6 +6184,18 @@ namespace Parser { return undefined; } + function parseJsxAttributeName() { + const pos = getNodePos(); + scanJsxIdentifier(); + + const attrName = parseIdentifierName(); + if (parseOptional(SyntaxKind.ColonToken)) { + scanJsxIdentifier(); + return finishNode(factory.createJsxNamespacedName(attrName, parseIdentifierName()), pos); + } + return attrName; + } + function parseJsxSpreadAttribute(): JsxSpreadAttribute { const pos = getNodePos(); parseExpected(SyntaxKind.OpenBraceToken); @@ -10425,6 +10452,11 @@ export function tagNamesAreEquivalent(lhs: JsxTagNameExpression, rhs: JsxTagName return true; } + if (lhs.kind === SyntaxKind.JsxNamespacedName) { + return lhs.namespace.escapedText === (rhs as JsxNamespacedName).namespace.escapedText && + lhs.name.escapedText === (rhs as JsxNamespacedName).name.escapedText; + } + // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 32860b744e080..9f539aec49d80 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -2543,7 +2543,6 @@ export function createScanner(languageVersion: ScriptTarget, // everything after it to the token // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token // Any caller should be expecting this behavior and should only read the pos or token value after calling it. - let namespaceSeparator = false; while (pos < end) { const ch = text.charCodeAt(pos); if (ch === CharacterCodes.minus) { @@ -2551,24 +2550,12 @@ export function createScanner(languageVersion: ScriptTarget, pos++; continue; } - else if (ch === CharacterCodes.colon && !namespaceSeparator) { - tokenValue += ":"; - pos++; - namespaceSeparator = true; - token = SyntaxKind.Identifier; // swap from keyword kind to identifier kind - continue; - } const oldPos = pos; tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled if (pos === oldPos) { break; } } - // Do not include a trailing namespace separator in the token, since this is against the spec. - if (tokenValue.slice(-1) === ":") { - tokenValue = tokenValue.slice(0, -1); - pos--; - } return getIdentifierToken(); } return token; diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 4463613bf8a64..52fa0bc564f74 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -32,6 +32,7 @@ import { isJsxAttribute, isJsxElement, isJsxFragment, + isJsxNamespacedName, isJsxSelfClosingElement, isJsxSpreadAttribute, isLineBreak, @@ -262,7 +263,7 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B if (isJsxSpreadAttribute(elem) && (!isObjectLiteralExpression(elem.expression) || elem.expression.properties.some(isSpreadAssignment))) { spread = true; } - else if (spread && isJsxAttribute(elem) && elem.name.escapedText === "key") { + else if (spread && isJsxAttribute(elem) && isIdentifier(elem.name) && elem.name.escapedText === "key") { return true; } } @@ -639,12 +640,15 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B return getTagName(node.openingElement); } else { - const name = node.tagName; - if (isIdentifier(name) && isIntrinsicJsxName(name.escapedText)) { - return factory.createStringLiteral(idText(name)); + const tagName = node.tagName; + if (isIdentifier(tagName) && isIntrinsicJsxName(tagName.escapedText)) { + return factory.createStringLiteral(idText(tagName)); + } + else if (isJsxNamespacedName(tagName)) { + return factory.createStringLiteral(idText(tagName.namespace) + ":" + idText(tagName.name)); } else { - return createExpressionFromEntityName(factory, name); + return createExpressionFromEntityName(factory, tagName); } } } @@ -656,13 +660,11 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B */ function getAttributeName(node: JsxAttribute): StringLiteral | Identifier { const name = node.name; - const text = idText(name); - if (/^[A-Za-z_]\w*$/.test(text)) { - return name; - } - else { - return factory.createStringLiteral(text); + if (isIdentifier(name)) { + const text = idText(name); + return (/^[A-Za-z_]\w*$/.test(text)) ? name : factory.createStringLiteral(text); } + return factory.createStringLiteral(idText(name.namespace) + ":" + idText(name.name)); } function visitJsxExpression(node: JsxExpression) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b97d9becc8f68..78f58d6b005a0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -367,6 +367,7 @@ export const enum SyntaxKind { JsxAttributes, JsxSpreadAttribute, JsxExpression, + JsxNamespacedName, // Clauses CaseClause, @@ -1153,6 +1154,7 @@ export type HasChildren = | JsxAttributes | JsxSpreadAttribute | JsxExpression + | JsxNamespacedName | CaseClause | DefaultClause | HeritageClause @@ -3177,21 +3179,34 @@ export type JsxAttributeLike = | JsxSpreadAttribute ; +export type JsxAttributeName = + | Identifier + | JsxNamespacedName + ; + export type JsxTagNameExpression = | Identifier | ThisExpression | JsxTagNamePropertyAccess + | JsxNamespacedName ; export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { readonly expression: JsxTagNameExpression; } -export interface JsxAttributes extends ObjectLiteralExpressionBase { +export interface JsxAttributes extends PrimaryExpression, Declaration { + readonly properties: NodeArray; readonly kind: SyntaxKind.JsxAttributes; readonly parent: JsxOpeningLikeElement; } +export interface JsxNamespacedName extends PrimaryExpression { + readonly kind: SyntaxKind.JsxNamespacedName; + readonly name: Identifier; + readonly namespace: Identifier; +} + /// The opening element of a ... JsxElement export interface JsxOpeningElement extends Expression { readonly kind: SyntaxKind.JsxOpeningElement; @@ -3229,10 +3244,10 @@ export interface JsxClosingFragment extends Expression { readonly parent: JsxFragment; } -export interface JsxAttribute extends ObjectLiteralElement { +export interface JsxAttribute extends Declaration { readonly kind: SyntaxKind.JsxAttribute; readonly parent: JsxAttributes; - readonly name: Identifier; + readonly name: JsxAttributeName; /// JSX attribute initializers are optional; is sugar for readonly initializer?: JsxAttributeValue; } @@ -3246,6 +3261,7 @@ export type JsxAttributeValue = export interface JsxSpreadAttribute extends ObjectLiteralElement { readonly kind: SyntaxKind.JsxSpreadAttribute; + readonly name: PropertyName; readonly parent: JsxAttributes; readonly expression: Expression; } @@ -8713,14 +8729,16 @@ export interface NodeFactory { createJsxOpeningFragment(): JsxOpeningFragment; createJsxJsxClosingFragment(): JsxClosingFragment; updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; - createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; - updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; + createJsxAttribute(name: JsxAttributeName, initializer: JsxAttributeValue | undefined): JsxAttribute; + updateJsxAttribute(node: JsxAttribute, name: JsxAttributeName, initializer: JsxAttributeValue | undefined): JsxAttribute; createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; + createJsxNamespacedName(namespace: Identifier, name: Identifier): JsxNamespacedName; + updateJsxNamespacedName(node: JsxNamespacedName, namespace: Identifier, name: Identifier): JsxNamespacedName; // // Clauses diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 6e4085a82ae27..a4d7c936ec68e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -355,6 +355,7 @@ import { JSDocTemplateTag, JSDocTypedefTag, JsonSourceFile, + JsxAttributeName, JsxChild, JsxElement, JsxEmit, @@ -2062,6 +2063,8 @@ export function entityNameToString(name: EntityNameOrEntityNameExpression | JSDo } case SyntaxKind.JSDocMemberName: return entityNameToString(name.left) + entityNameToString(name.right); + case SyntaxKind.JsxNamespacedName: + return entityNameToString(name.namespace) + ":" + entityNameToString(name.name); default: return Debug.assertNever(name); } @@ -10162,3 +10165,20 @@ export function tryGetJSDocSatisfiesTypeNode(node: Node) { const tag = getJSDocSatisfiesTag(node); return tag && tag.typeExpression && tag.typeExpression.type; } + +/** @internal */ +export function getEscapedTextOfJsxAttributeName(node: JsxAttributeName): __String { + return isIdentifier(node) ? node.escapedText : `${node.namespace.escapedText}:${idText(node.name)}` as __String; +} + +/** @internal */ +export function getTextOfJsxAttributeName(node: JsxAttributeName): string { + return isIdentifier(node) ? idText(node) : `${idText(node.namespace)}:${idText(node.name)}`; +} + +/** @internal */ +export function isJsxAttributeName(node: Node): node is JsxAttributeName { + const kind = node.kind; + return kind === SyntaxKind.Identifier + || kind === SyntaxKind.JsxNamespacedName; +} diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 25114f2b96feb..2a4a3d21a19c9 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -1941,6 +1941,7 @@ function isLeftHandSideExpressionKind(kind: SyntaxKind): boolean { case SyntaxKind.JsxElement: case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxFragment: + case SyntaxKind.JsxNamespacedName: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.ParenthesizedExpression: @@ -2406,7 +2407,8 @@ export function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression const kind = node.kind; return kind === SyntaxKind.ThisKeyword || kind === SyntaxKind.Identifier - || kind === SyntaxKind.PropertyAccessExpression; + || kind === SyntaxKind.PropertyAccessExpression + || kind === SyntaxKind.JsxNamespacedName; } export function isJsxChild(node: Node): node is JsxChild { diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 0ae4957ffab32..08475d5c0ae7a 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -46,6 +46,7 @@ import { isImportSpecifier, isImportTypeAssertionContainer, isJsxAttributeLike, + isJsxAttributeName, isJsxAttributes, isJsxChild, isJsxClosingElement, @@ -1429,6 +1430,12 @@ const visitEachChildTable: VisitEachChildTable = { Debug.checkDefined(nodeVisitor(node.tagName, visitor, isJsxTagNameExpression))); }, + [SyntaxKind.JsxNamespacedName]: function forEachChildInJsxNamespacedName(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { + return context.factory.updateJsxNamespacedName(node, + Debug.checkDefined(nodeVisitor(node.namespace, visitor, isIdentifier)), + Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))); + }, + [SyntaxKind.JsxFragment]: function visitEachChildOfJsxFragment(node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) { return context.factory.updateJsxFragment(node, Debug.checkDefined(nodeVisitor(node.openingFragment, visitor, isJsxOpeningFragment)), @@ -1438,7 +1445,7 @@ const visitEachChildTable: VisitEachChildTable = { [SyntaxKind.JsxAttribute]: function visitEachChildOfJsxAttribute(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { return context.factory.updateJsxAttribute(node, - Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier)), + Debug.checkDefined(nodeVisitor(node.name, visitor, isJsxAttributeName)), nodeVisitor(node.initializer, visitor, isStringLiteralOrJsxExpression)); }, diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 3d46bc1511d2a..2231cd0509a9b 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -29,6 +29,7 @@ import { getCheckFlags, getClassLikeDeclarationOfSymbol, getEmitScriptTarget, + getEscapedTextOfJsxAttributeName, getFirstConstructorWithBody, getNodeId, getObjectFlags, @@ -742,7 +743,7 @@ function getUnmatchedAttributes(checker: TypeChecker, target: ScriptTarget, sour const seenNames = new Set<__String>(); for (const sourceProp of source.attributes.properties) { if (isJsxAttribute(sourceProp)) { - seenNames.add(sourceProp.name.escapedText); + seenNames.add(getEscapedTextOfJsxAttributeName(sourceProp.name)); } if (isJsxSpreadAttribute(sourceProp)) { const type = checker.getTypeAtLocation(sourceProp.expression); diff --git a/src/services/completions.ts b/src/services/completions.ts index 43ae8c2497a1c..f4fc9d9d80e24 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -82,6 +82,7 @@ import { getEmitModuleResolutionKind, getEmitScriptTarget, getEscapedTextOfIdentifierOrLiteral, + getEscapedTextOfJsxAttributeName, getExportInfoMap, getFormatCodeSettingsForWriting, getJSDocParameterTags, @@ -4787,7 +4788,7 @@ function getCompletionData( } if (attr.kind === SyntaxKind.JsxAttribute) { - seenNames.add(attr.name.escapedText); + seenNames.add(getEscapedTextOfJsxAttributeName(attr.name)); } else if (isJsxSpreadAttribute(attr)) { setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 7347c231344aa..61c23266701fa 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -59,6 +59,7 @@ import { getResolvePackageJsonExports, getSupportedExtensions, getSupportedExtensionsWithJsonIfResolveJsonModule, + getTextOfJsxAttributeName, getTokenAtPosition, hasIndexSignature, hasProperty, @@ -487,7 +488,7 @@ function getStringLiteralCompletionsFromSignature(call: CallLikeExpression, arg: if (!signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length) return; let type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex); if (isJsxOpeningLikeElement(call)) { - const propType = checker.getTypeOfPropertyOfType(type, (editingArgument as JsxAttribute).name.text); + const propType = checker.getTypeOfPropertyOfType(type, getTextOfJsxAttributeName((editingArgument as JsxAttribute).name)); if (propType) { type = propType; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 4bf70d659b1ff..7a7adbc8a0755 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4350,78 +4350,79 @@ declare namespace ts { JsxAttributes = 291, JsxSpreadAttribute = 292, JsxExpression = 293, - CaseClause = 294, - DefaultClause = 295, - HeritageClause = 296, - CatchClause = 297, - AssertClause = 298, - AssertEntry = 299, - ImportTypeAssertionContainer = 300, - PropertyAssignment = 301, - ShorthandPropertyAssignment = 302, - SpreadAssignment = 303, - EnumMember = 304, - /** @deprecated */ UnparsedPrologue = 305, - /** @deprecated */ UnparsedPrepend = 306, - /** @deprecated */ UnparsedText = 307, - /** @deprecated */ UnparsedInternalText = 308, - /** @deprecated */ UnparsedSyntheticReference = 309, - SourceFile = 310, - Bundle = 311, - /** @deprecated */ UnparsedSource = 312, - /** @deprecated */ InputFiles = 313, - JSDocTypeExpression = 314, - JSDocNameReference = 315, - JSDocMemberName = 316, - JSDocAllType = 317, - JSDocUnknownType = 318, - JSDocNullableType = 319, - JSDocNonNullableType = 320, - JSDocOptionalType = 321, - JSDocFunctionType = 322, - JSDocVariadicType = 323, - JSDocNamepathType = 324, - JSDoc = 325, + JsxNamespacedName = 294, + CaseClause = 295, + DefaultClause = 296, + HeritageClause = 297, + CatchClause = 298, + AssertClause = 299, + AssertEntry = 300, + ImportTypeAssertionContainer = 301, + PropertyAssignment = 302, + ShorthandPropertyAssignment = 303, + SpreadAssignment = 304, + EnumMember = 305, + /** @deprecated */ UnparsedPrologue = 306, + /** @deprecated */ UnparsedPrepend = 307, + /** @deprecated */ UnparsedText = 308, + /** @deprecated */ UnparsedInternalText = 309, + /** @deprecated */ UnparsedSyntheticReference = 310, + SourceFile = 311, + Bundle = 312, + /** @deprecated */ UnparsedSource = 313, + /** @deprecated */ InputFiles = 314, + JSDocTypeExpression = 315, + JSDocNameReference = 316, + JSDocMemberName = 317, + JSDocAllType = 318, + JSDocUnknownType = 319, + JSDocNullableType = 320, + JSDocNonNullableType = 321, + JSDocOptionalType = 322, + JSDocFunctionType = 323, + JSDocVariadicType = 324, + JSDocNamepathType = 325, + JSDoc = 326, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 325, - JSDocText = 326, - JSDocTypeLiteral = 327, - JSDocSignature = 328, - JSDocLink = 329, - JSDocLinkCode = 330, - JSDocLinkPlain = 331, - JSDocTag = 332, - JSDocAugmentsTag = 333, - JSDocImplementsTag = 334, - JSDocAuthorTag = 335, - JSDocDeprecatedTag = 336, - JSDocClassTag = 337, - JSDocPublicTag = 338, - JSDocPrivateTag = 339, - JSDocProtectedTag = 340, - JSDocReadonlyTag = 341, - JSDocOverrideTag = 342, - JSDocCallbackTag = 343, - JSDocOverloadTag = 344, - JSDocEnumTag = 345, - JSDocParameterTag = 346, - JSDocReturnTag = 347, - JSDocThisTag = 348, - JSDocTypeTag = 349, - JSDocTemplateTag = 350, - JSDocTypedefTag = 351, - JSDocSeeTag = 352, - JSDocPropertyTag = 353, - JSDocThrowsTag = 354, - JSDocSatisfiesTag = 355, - SyntaxList = 356, - NotEmittedStatement = 357, - PartiallyEmittedExpression = 358, - CommaListExpression = 359, - MergeDeclarationMarker = 360, - EndOfDeclarationMarker = 361, - SyntheticReferenceExpression = 362, - Count = 363, + JSDocComment = 326, + JSDocText = 327, + JSDocTypeLiteral = 328, + JSDocSignature = 329, + JSDocLink = 330, + JSDocLinkCode = 331, + JSDocLinkPlain = 332, + JSDocTag = 333, + JSDocAugmentsTag = 334, + JSDocImplementsTag = 335, + JSDocAuthorTag = 336, + JSDocDeprecatedTag = 337, + JSDocClassTag = 338, + JSDocPublicTag = 339, + JSDocPrivateTag = 340, + JSDocProtectedTag = 341, + JSDocReadonlyTag = 342, + JSDocOverrideTag = 343, + JSDocCallbackTag = 344, + JSDocOverloadTag = 345, + JSDocEnumTag = 346, + JSDocParameterTag = 347, + JSDocReturnTag = 348, + JSDocThisTag = 349, + JSDocTypeTag = 350, + JSDocTemplateTag = 351, + JSDocTypedefTag = 352, + JSDocSeeTag = 353, + JSDocPropertyTag = 354, + JSDocThrowsTag = 355, + JSDocSatisfiesTag = 356, + SyntaxList = 357, + NotEmittedStatement = 358, + PartiallyEmittedExpression = 359, + CommaListExpression = 360, + MergeDeclarationMarker = 361, + EndOfDeclarationMarker = 362, + SyntheticReferenceExpression = 363, + Count = 364, FirstAssignment = 64, LastAssignment = 79, FirstCompoundAssignment = 65, @@ -4449,10 +4450,10 @@ declare namespace ts { FirstStatement = 242, LastStatement = 258, FirstNode = 165, - FirstJSDocNode = 314, - LastJSDocNode = 355, - FirstJSDocTagNode = 332, - LastJSDocTagNode = 355 + FirstJSDocNode = 315, + LastJSDocNode = 356, + FirstJSDocTagNode = 333, + LastJSDocTagNode = 356 } type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; @@ -5360,14 +5361,21 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + type JsxAttributeName = Identifier | JsxNamespacedName; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess | JsxNamespacedName; interface JsxTagNamePropertyAccess extends PropertyAccessExpression { readonly expression: JsxTagNameExpression; } - interface JsxAttributes extends ObjectLiteralExpressionBase { + interface JsxAttributes extends PrimaryExpression, Declaration { + readonly properties: NodeArray; readonly kind: SyntaxKind.JsxAttributes; readonly parent: JsxOpeningLikeElement; } + interface JsxNamespacedName extends PrimaryExpression { + readonly kind: SyntaxKind.JsxNamespacedName; + readonly name: Identifier; + readonly namespace: Identifier; + } interface JsxOpeningElement extends Expression { readonly kind: SyntaxKind.JsxOpeningElement; readonly parent: JsxElement; @@ -5395,15 +5403,16 @@ declare namespace ts { readonly kind: SyntaxKind.JsxClosingFragment; readonly parent: JsxFragment; } - interface JsxAttribute extends ObjectLiteralElement { + interface JsxAttribute extends Declaration { readonly kind: SyntaxKind.JsxAttribute; readonly parent: JsxAttributes; - readonly name: Identifier; + readonly name: JsxAttributeName; readonly initializer?: JsxAttributeValue; } type JsxAttributeValue = StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; interface JsxSpreadAttribute extends ObjectLiteralElement { readonly kind: SyntaxKind.JsxSpreadAttribute; + readonly name: PropertyName; readonly parent: JsxAttributes; readonly expression: Expression; } @@ -7940,14 +7949,16 @@ declare namespace ts { createJsxOpeningFragment(): JsxOpeningFragment; createJsxJsxClosingFragment(): JsxClosingFragment; updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; - createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; - updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; + createJsxAttribute(name: JsxAttributeName, initializer: JsxAttributeValue | undefined): JsxAttribute; + updateJsxAttribute(node: JsxAttribute, name: JsxAttributeName, initializer: JsxAttributeValue | undefined): JsxAttribute; createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; + createJsxNamespacedName(namespace: Identifier, name: Identifier): JsxNamespacedName; + updateJsxNamespacedName(node: JsxNamespacedName, namespace: Identifier, name: Identifier): JsxNamespacedName; createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; createDefaultClause(statements: readonly Statement[]): DefaultClause; @@ -9018,6 +9029,7 @@ declare namespace ts { function isJsxAttributes(node: Node): node is JsxAttributes; function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute; function isJsxExpression(node: Node): node is JsxExpression; + function isJsxNamespacedName(node: Node): node is JsxNamespacedName; function isCaseClause(node: Node): node is CaseClause; function isDefaultClause(node: Node): node is DefaultClause; function isHeritageClause(node: Node): node is HeritageClause; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 6acc0c5bc906e..ff62845a28f2c 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -338,78 +338,79 @@ declare namespace ts { JsxAttributes = 291, JsxSpreadAttribute = 292, JsxExpression = 293, - CaseClause = 294, - DefaultClause = 295, - HeritageClause = 296, - CatchClause = 297, - AssertClause = 298, - AssertEntry = 299, - ImportTypeAssertionContainer = 300, - PropertyAssignment = 301, - ShorthandPropertyAssignment = 302, - SpreadAssignment = 303, - EnumMember = 304, - /** @deprecated */ UnparsedPrologue = 305, - /** @deprecated */ UnparsedPrepend = 306, - /** @deprecated */ UnparsedText = 307, - /** @deprecated */ UnparsedInternalText = 308, - /** @deprecated */ UnparsedSyntheticReference = 309, - SourceFile = 310, - Bundle = 311, - /** @deprecated */ UnparsedSource = 312, - /** @deprecated */ InputFiles = 313, - JSDocTypeExpression = 314, - JSDocNameReference = 315, - JSDocMemberName = 316, - JSDocAllType = 317, - JSDocUnknownType = 318, - JSDocNullableType = 319, - JSDocNonNullableType = 320, - JSDocOptionalType = 321, - JSDocFunctionType = 322, - JSDocVariadicType = 323, - JSDocNamepathType = 324, - JSDoc = 325, + JsxNamespacedName = 294, + CaseClause = 295, + DefaultClause = 296, + HeritageClause = 297, + CatchClause = 298, + AssertClause = 299, + AssertEntry = 300, + ImportTypeAssertionContainer = 301, + PropertyAssignment = 302, + ShorthandPropertyAssignment = 303, + SpreadAssignment = 304, + EnumMember = 305, + /** @deprecated */ UnparsedPrologue = 306, + /** @deprecated */ UnparsedPrepend = 307, + /** @deprecated */ UnparsedText = 308, + /** @deprecated */ UnparsedInternalText = 309, + /** @deprecated */ UnparsedSyntheticReference = 310, + SourceFile = 311, + Bundle = 312, + /** @deprecated */ UnparsedSource = 313, + /** @deprecated */ InputFiles = 314, + JSDocTypeExpression = 315, + JSDocNameReference = 316, + JSDocMemberName = 317, + JSDocAllType = 318, + JSDocUnknownType = 319, + JSDocNullableType = 320, + JSDocNonNullableType = 321, + JSDocOptionalType = 322, + JSDocFunctionType = 323, + JSDocVariadicType = 324, + JSDocNamepathType = 325, + JSDoc = 326, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 325, - JSDocText = 326, - JSDocTypeLiteral = 327, - JSDocSignature = 328, - JSDocLink = 329, - JSDocLinkCode = 330, - JSDocLinkPlain = 331, - JSDocTag = 332, - JSDocAugmentsTag = 333, - JSDocImplementsTag = 334, - JSDocAuthorTag = 335, - JSDocDeprecatedTag = 336, - JSDocClassTag = 337, - JSDocPublicTag = 338, - JSDocPrivateTag = 339, - JSDocProtectedTag = 340, - JSDocReadonlyTag = 341, - JSDocOverrideTag = 342, - JSDocCallbackTag = 343, - JSDocOverloadTag = 344, - JSDocEnumTag = 345, - JSDocParameterTag = 346, - JSDocReturnTag = 347, - JSDocThisTag = 348, - JSDocTypeTag = 349, - JSDocTemplateTag = 350, - JSDocTypedefTag = 351, - JSDocSeeTag = 352, - JSDocPropertyTag = 353, - JSDocThrowsTag = 354, - JSDocSatisfiesTag = 355, - SyntaxList = 356, - NotEmittedStatement = 357, - PartiallyEmittedExpression = 358, - CommaListExpression = 359, - MergeDeclarationMarker = 360, - EndOfDeclarationMarker = 361, - SyntheticReferenceExpression = 362, - Count = 363, + JSDocComment = 326, + JSDocText = 327, + JSDocTypeLiteral = 328, + JSDocSignature = 329, + JSDocLink = 330, + JSDocLinkCode = 331, + JSDocLinkPlain = 332, + JSDocTag = 333, + JSDocAugmentsTag = 334, + JSDocImplementsTag = 335, + JSDocAuthorTag = 336, + JSDocDeprecatedTag = 337, + JSDocClassTag = 338, + JSDocPublicTag = 339, + JSDocPrivateTag = 340, + JSDocProtectedTag = 341, + JSDocReadonlyTag = 342, + JSDocOverrideTag = 343, + JSDocCallbackTag = 344, + JSDocOverloadTag = 345, + JSDocEnumTag = 346, + JSDocParameterTag = 347, + JSDocReturnTag = 348, + JSDocThisTag = 349, + JSDocTypeTag = 350, + JSDocTemplateTag = 351, + JSDocTypedefTag = 352, + JSDocSeeTag = 353, + JSDocPropertyTag = 354, + JSDocThrowsTag = 355, + JSDocSatisfiesTag = 356, + SyntaxList = 357, + NotEmittedStatement = 358, + PartiallyEmittedExpression = 359, + CommaListExpression = 360, + MergeDeclarationMarker = 361, + EndOfDeclarationMarker = 362, + SyntheticReferenceExpression = 363, + Count = 364, FirstAssignment = 64, LastAssignment = 79, FirstCompoundAssignment = 65, @@ -437,10 +438,10 @@ declare namespace ts { FirstStatement = 242, LastStatement = 258, FirstNode = 165, - FirstJSDocNode = 314, - LastJSDocNode = 355, - FirstJSDocTagNode = 332, - LastJSDocTagNode = 355 + FirstJSDocNode = 315, + LastJSDocNode = 356, + FirstJSDocTagNode = 333, + LastJSDocTagNode = 356 } type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; @@ -1348,14 +1349,21 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + type JsxAttributeName = Identifier | JsxNamespacedName; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess | JsxNamespacedName; interface JsxTagNamePropertyAccess extends PropertyAccessExpression { readonly expression: JsxTagNameExpression; } - interface JsxAttributes extends ObjectLiteralExpressionBase { + interface JsxAttributes extends PrimaryExpression, Declaration { + readonly properties: NodeArray; readonly kind: SyntaxKind.JsxAttributes; readonly parent: JsxOpeningLikeElement; } + interface JsxNamespacedName extends PrimaryExpression { + readonly kind: SyntaxKind.JsxNamespacedName; + readonly name: Identifier; + readonly namespace: Identifier; + } interface JsxOpeningElement extends Expression { readonly kind: SyntaxKind.JsxOpeningElement; readonly parent: JsxElement; @@ -1383,15 +1391,16 @@ declare namespace ts { readonly kind: SyntaxKind.JsxClosingFragment; readonly parent: JsxFragment; } - interface JsxAttribute extends ObjectLiteralElement { + interface JsxAttribute extends Declaration { readonly kind: SyntaxKind.JsxAttribute; readonly parent: JsxAttributes; - readonly name: Identifier; + readonly name: JsxAttributeName; readonly initializer?: JsxAttributeValue; } type JsxAttributeValue = StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; interface JsxSpreadAttribute extends ObjectLiteralElement { readonly kind: SyntaxKind.JsxSpreadAttribute; + readonly name: PropertyName; readonly parent: JsxAttributes; readonly expression: Expression; } @@ -3928,14 +3937,16 @@ declare namespace ts { createJsxOpeningFragment(): JsxOpeningFragment; createJsxJsxClosingFragment(): JsxClosingFragment; updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; - createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; - updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute; + createJsxAttribute(name: JsxAttributeName, initializer: JsxAttributeValue | undefined): JsxAttribute; + updateJsxAttribute(node: JsxAttribute, name: JsxAttributeName, initializer: JsxAttributeValue | undefined): JsxAttribute; createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; + createJsxNamespacedName(namespace: Identifier, name: Identifier): JsxNamespacedName; + updateJsxNamespacedName(node: JsxNamespacedName, namespace: Identifier, name: Identifier): JsxNamespacedName; createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; createDefaultClause(statements: readonly Statement[]): DefaultClause; @@ -5006,6 +5017,7 @@ declare namespace ts { function isJsxAttributes(node: Node): node is JsxAttributes; function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute; function isJsxExpression(node: Node): node is JsxExpression; + function isJsxNamespacedName(node: Node): node is JsxNamespacedName; function isCaseClause(node: Node): node is CaseClause; function isDefaultClause(node: Node): node is DefaultClause; function isHeritageClause(node: Node): node is HeritageClause; diff --git a/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.errors.txt b/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.errors.txt index d758a3ed0c9b5..55a28e9330031 100644 --- a/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.errors.txt +++ b/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.errors.txt @@ -1,9 +1,7 @@ -tests/cases/conformance/jsx/checkJsxNamespaceNamesQuestionableForms.tsx(12,2): error TS2304: Cannot find name 'b:c'. tests/cases/conformance/jsx/checkJsxNamespaceNamesQuestionableForms.tsx(12,2): error TS2633: JSX property access expressions cannot include JSX namespace names -tests/cases/conformance/jsx/checkJsxNamespaceNamesQuestionableForms.tsx(12,10): error TS2304: Cannot find name 'b:c'. -==== tests/cases/conformance/jsx/checkJsxNamespaceNamesQuestionableForms.tsx (3 errors) ==== +==== tests/cases/conformance/jsx/checkJsxNamespaceNamesQuestionableForms.tsx (1 errors) ==== declare namespace JSX { interface IntrinsicElements { 'this:b': any; @@ -17,9 +15,5 @@ tests/cases/conformance/jsx/checkJsxNamespaceNamesQuestionableForms.tsx(12,10): ; ; ~~~ -!!! error TS2304: Cannot find name 'b:c'. - ~~~ !!! error TS2633: JSX property access expressions cannot include JSX namespace names - ~~~ -!!! error TS2304: Cannot find name 'b:c'. ; \ No newline at end of file diff --git a/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.symbols b/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.symbols index 405838180ce31..9f2a5cb77ceef 100644 --- a/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.symbols +++ b/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.symbols @@ -21,11 +21,5 @@ declare namespace JSX { } ; ->a:b : Symbol(JSX.IntrinsicElements['a:b'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 5, 10)) ->a:b : Symbol(JSX.IntrinsicElements['a:b'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 5, 10)) - ; ; ->this:b : Symbol(JSX.IntrinsicElements['this:b'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 1, 33)) ->this:b : Symbol(JSX.IntrinsicElements['this:b'], Decl(checkJsxNamespaceNamesQuestionableForms.tsx, 1, 33)) - diff --git a/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.types b/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.types index 9f99922032253..ea6728210b671 100644 --- a/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.types +++ b/tests/baselines/reference/checkJsxNamespaceNamesQuestionableForms.types @@ -18,20 +18,26 @@ declare namespace JSX { ; > : any ->a:b : any ->a:b : any +>a : any +>b : any +>a : any +>b : any ; > : any >b:c.x : any ->b:c : any +>b : any +>c : any >x : any >b:c.x : any ->b:c : any +>b : any +>c : any >x : any ; > : any ->this:b : any ->this:b : any +>this : any +>b : any +>this : any +>b : any diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.types b/tests/baselines/reference/jsxEsprimaFbTestSuite.types index 4b48d7c378d53..3731eac7a2374 100644 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.types +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.types @@ -29,13 +29,18 @@ declare var value; ; > : any ->n:a : any +>n : any +>a : any >n:v : true +>n : any +>v : any {value} ; > {value} : any >a : any >n:foo : string +>n : any +>foo : any >value : any > : any >b : any diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt index cbe83ef6ece5a..f332ade0a3d52 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -35,7 +35,7 @@ tests/cases/conformance/jsx/17.tsx(1,2): error TS17008: JSX element 'a' has no c tests/cases/conformance/jsx/17.tsx(1,10): error TS1005: '; - ~ + ~ !!! error TS1003: Identifier expected. ==== tests/cases/conformance/jsx/3.tsx (5 errors) ==== <:a />; @@ -127,14 +125,10 @@ tests/cases/conformance/jsx/9.tsx(1,10): error TS2304: Cannot find name 'a:b'. ; ~ !!! error TS17002: Expected corresponding JSX closing tag for 'a:b'. -==== tests/cases/conformance/jsx/9.tsx (3 errors) ==== +==== tests/cases/conformance/jsx/9.tsx (1 errors) ==== ; ~~~ -!!! error TS2304: Cannot find name 'a:b'. - ~~~ !!! error TS2633: JSX property access expressions cannot include JSX namespace names - ~~~ -!!! error TS2304: Cannot find name 'a:b'. ==== tests/cases/conformance/jsx/10.tsx (6 errors) ==== ; ~ diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js index e0d10043838a8..8c1d7dea1c27c 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -77,7 +77,7 @@ var x =
one
/* intervening comment */
two
;; //// [1.jsx] > ; //// [2.jsx] -; +; //// [3.jsx] < ; a / > ; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types index 277d3da9da61b..e3bb4ff69559f 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types @@ -11,6 +11,7 @@ declare var React: any; ; > : any >a : any +> : any === tests/cases/conformance/jsx/3.tsx === <:a />; @@ -51,17 +52,20 @@ declare var React: any; === tests/cases/conformance/jsx/8.tsx === ; > : any ->a:b : any +>a : any +>b : any >b : any === tests/cases/conformance/jsx/9.tsx === ; > : any >a:b.c : any ->a:b : any +>a : any +>b : any >c : any >a:b.c : any ->a:b : any +>a : any +>b : any >c : any === tests/cases/conformance/jsx/10.tsx === diff --git a/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt b/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt index a983e8736b03c..b600af4c155a7 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt +++ b/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt @@ -15,11 +15,10 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(11,32): error TS1003: Identifi tests/cases/compiler/jsxNamespacePrefixInName.tsx(11,68): error TS1005: '>' expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(11,73): error TS1005: ',' expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(11,74): error TS1109: Expression expected. -tests/cases/compiler/jsxNamespacePrefixInName.tsx(21,21): error TS1003: Identifier expected. -tests/cases/compiler/jsxNamespacePrefixInName.tsx(22,26): error TS1003: Identifier expected. +tests/cases/compiler/jsxNamespacePrefixInName.tsx(21,27): error TS1003: Identifier expected. +tests/cases/compiler/jsxNamespacePrefixInName.tsx(21,29): error TS1005: '...' expected. +tests/cases/compiler/jsxNamespacePrefixInName.tsx(21,29): error TS2698: Spread types may only be created from object types. tests/cases/compiler/jsxNamespacePrefixInName.tsx(22,27): error TS1003: Identifier expected. -tests/cases/compiler/jsxNamespacePrefixInName.tsx(22,29): error TS1005: '...' expected. -tests/cases/compiler/jsxNamespacePrefixInName.tsx(22,29): error TS2698: Spread types may only be created from object types. tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,21): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,22): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,25): error TS1005: ',' expected. @@ -27,10 +26,12 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,30): error TS2362: The left tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,38): error TS1005: ':' expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,41): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,42): error TS1109: Expression expected. -tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,24): error TS1003: Identifier expected. +tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,29): error TS1003: Identifier expected. +tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,31): error TS1005: '...' expected. +tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,31): error TS2698: Spread types may only be created from object types. -==== tests/cases/compiler/jsxNamespacePrefixInName.tsx (30 errors) ==== +==== tests/cases/compiler/jsxNamespacePrefixInName.tsx (31 errors) ==== var justElement1 = ; var justElement2 = ; var justElement3 = ; @@ -86,17 +87,15 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,24): error TS1003: Identifi var both3 = {"text"}; var endOfIdent1 = ; - ~ -!!! error TS1003: Identifier expected. - var endOfIdent2 = ; - ~ -!!! error TS1003: Identifier expected. ~ !!! error TS1003: Identifier expected. ~~~~~~~ !!! error TS1005: '...' expected. ~~~~~~~ !!! error TS2698: Spread types may only be created from object types. + var endOfIdent2 = ; + ~ +!!! error TS1003: Identifier expected. var beginOfIdent1 = <:a attr={"value"} />; ~ @@ -114,8 +113,12 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,24): error TS1003: Identifi ~ !!! error TS1109: Expression expected. var beginOfIdent2 = ; - ~ + ~ !!! error TS1003: Identifier expected. + ~~~~~~~ +!!! error TS1005: '...' expected. + ~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. var upcaseComponent1 = ; // Parsed as intrinsic var upcaseComponent2 = ; // Parsed as instrinsic diff --git a/tests/baselines/reference/jsxNamespacePrefixInName.js b/tests/baselines/reference/jsxNamespacePrefixInName.js index eca335921a34a..8952eea50106b 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInName.js +++ b/tests/baselines/reference/jsxNamespacePrefixInName.js @@ -50,9 +50,9 @@ var justAttribute3 = {"text"}; var both1 = ; var both2 = ; var both3 = {"text"}; -var endOfIdent1 = ; -var endOfIdent2 = ; +var endOfIdent1 = ; +var endOfIdent2 = ; var beginOfIdent1 = < , a, attr = { "value": } / > ; -var beginOfIdent2 = ; +var beginOfIdent2 = ; var upcaseComponent1 = ; // Parsed as intrinsic var upcaseComponent2 = ; // Parsed as instrinsic diff --git a/tests/baselines/reference/jsxNamespacePrefixInName.symbols b/tests/baselines/reference/jsxNamespacePrefixInName.symbols index 876ffa59e06b2..aaa19da28e0ce 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInName.symbols +++ b/tests/baselines/reference/jsxNamespacePrefixInName.symbols @@ -68,11 +68,10 @@ var both3 = {"text"}; var endOfIdent1 = ; >endOfIdent1 : Symbol(endOfIdent1, Decl(jsxNamespacePrefixInName.tsx, 20, 3)) ->attr : Symbol(attr, Decl(jsxNamespacePrefixInName.tsx, 20, 21)) var endOfIdent2 = ; >endOfIdent2 : Symbol(endOfIdent2, Decl(jsxNamespacePrefixInName.tsx, 21, 3)) ->attr : Symbol(attr, Decl(jsxNamespacePrefixInName.tsx, 21, 20)) +>attr: : Symbol(attr:, Decl(jsxNamespacePrefixInName.tsx, 21, 20)) var beginOfIdent1 = <:a attr={"value"} />; >beginOfIdent1 : Symbol(beginOfIdent1, Decl(jsxNamespacePrefixInName.tsx, 23, 3)) @@ -82,7 +81,6 @@ var beginOfIdent1 = <:a attr={"value"} />; var beginOfIdent2 = ; >beginOfIdent2 : Symbol(beginOfIdent2, Decl(jsxNamespacePrefixInName.tsx, 24, 3)) ->attr : Symbol(attr, Decl(jsxNamespacePrefixInName.tsx, 24, 24)) var upcaseComponent1 = ; // Parsed as intrinsic >upcaseComponent1 : Symbol(upcaseComponent1, Decl(jsxNamespacePrefixInName.tsx, 26, 3)) diff --git a/tests/baselines/reference/jsxNamespacePrefixInName.types b/tests/baselines/reference/jsxNamespacePrefixInName.types index 616ac016b7935..c86c34874c2d9 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInName.types +++ b/tests/baselines/reference/jsxNamespacePrefixInName.types @@ -2,50 +2,62 @@ var justElement1 = ; >justElement1 : any > : any ->a:element : any +>a : any +>element : any var justElement2 = ; >justElement2 : any > : any ->a:element : any ->a:element : any +>a : any +>element : any +>a : any +>element : any var justElement3 = ; >justElement3 : any > : any ->a:element : any +>a : any +>element : any >attr : string >"value" : "value" ->a:element : any +>a : any +>element : any var justElement4 = {"text"}; >justElement4 : any >{"text"} : any ->a:element : any +>a : any +>element : any >"text" : "text" ->a:element : any +>a : any +>element : any var justElement5 = {"text"}; >justElement5 : any >{"text"} : any ->a:element : any +>a : any +>element : any >attr : string >"value" : "value" >"text" : "text" ->a:element : any +>a : any +>element : any var tooManySeparators1 = ; >tooManySeparators1 : any > : any ->a:ele : any +>a : any +>ele : any >ment : true var tooManySeparators2 = ; >tooManySeparators2 : any >a:ele : any +>a : any +>ele : any >ment : true ->a:ele : any +>a : any +>ele : any >ment : any >> : boolean > : any @@ -54,11 +66,13 @@ var tooManySeparators2 = ; var tooManySeparators3 = ; >tooManySeparators3 : any >a:ele : any +>a : any +>ele : any >ment : true >attr : string >"value" : "value" ->a:ele : any +>a : any +>ele : any >ment : any >> : boolean > : any @@ -67,10 +81,12 @@ var tooManySeparators3 = ; var tooManySeparators4 = {"text"}; >tooManySeparators4 : any >{"text"}a:ele : any +>a : any +>ele : any >ment : true >"text" : "text" ->a:ele : any +>a : any +>ele : any >ment : any >> : boolean > : any @@ -79,12 +95,14 @@ var tooManySeparators4 = {"text"}; var tooManySeparators5 = {"text"}; >tooManySeparators5 : any >{"text"}a:ele : any +>a : any +>ele : any >ment : true >attr : string >"value" : "value" >"text" : "text" ->a:ele : any +>a : any +>ele : any >ment : any >> : boolean > : any @@ -95,6 +113,8 @@ var justAttribute1 = ; > : any >element : any >a:attr : string +>a : any +>attr : any >"value" : "value" var justAttribute2 = ; @@ -102,6 +122,8 @@ var justAttribute2 = ; > : any >element : any >a:attr : string +>a : any +>attr : any >"value" : "value" >element : any @@ -110,6 +132,8 @@ var justAttribute3 = {"text"}; >{"text"} : any >element : any >a:attr : string +>a : any +>attr : any >"value" : "value" >"text" : "text" >element : any @@ -117,39 +141,52 @@ var justAttribute3 = {"text"}; var both1 = ; >both1 : any > : any ->a:element : any +>a : any +>element : any >a:attr : string +>a : any +>attr : any >"value" : "value" var both2 = ; >both2 : any > : any ->a:element : any +>a : any +>element : any >k:attr : string +>k : any +>attr : any >"value" : "value" ->a:element : any +>a : any +>element : any var both3 = {"text"}; >both3 : any >{"text"} : any ->a:element : any +>a : any +>element : any >a:attr : string +>a : any +>attr : any >"value" : "value" >"text" : "text" ->a:element : any +>a : any +>element : any var endOfIdent1 = ; >endOfIdent1 : any > : any >a : any ->attr : string +>attr : any >"value" : "value" var endOfIdent2 = ; >endOfIdent2 : any > : any >a : any ->attr : true +>attr: : string +>attr : any +> : any >"value" : "value" var beginOfIdent1 = <:a attr={"value"} />; @@ -171,16 +208,18 @@ var beginOfIdent2 = ; >beginOfIdent2 : any > : any >a : any ->attr : string +>attr : any >"value" : "value" var upcaseComponent1 = ; // Parsed as intrinsic >upcaseComponent1 : any > : any ->ns:Upcase : any +>ns : any +>Upcase : any var upcaseComponent2 = ; // Parsed as instrinsic >upcaseComponent2 : any > : any ->Upcase:element : any +>Upcase : any +>element : any diff --git a/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt b/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt index bae65da057a4b..9aa5eea9df2a8 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt +++ b/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt @@ -15,11 +15,10 @@ tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(13,32): error TS1003: Ide tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(13,68): error TS1005: '>' expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(13,73): error TS1005: ',' expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(13,74): error TS1109: Expression expected. -tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(23,21): error TS1003: Identifier expected. -tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(24,26): error TS1003: Identifier expected. +tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(23,27): error TS1003: Identifier expected. +tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(23,29): error TS1005: '...' expected. +tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(23,29): error TS2698: Spread types may only be created from object types. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(24,27): error TS1003: Identifier expected. -tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(24,29): error TS1005: '...' expected. -tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(24,29): error TS2698: Spread types may only be created from object types. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,21): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,22): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,25): error TS1005: ',' expected. @@ -27,10 +26,12 @@ tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,30): error TS2362: The tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,38): error TS1005: ':' expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,41): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,42): error TS1109: Expression expected. -tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(27,24): error TS1003: Identifier expected. +tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(27,29): error TS1003: Identifier expected. +tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(27,31): error TS1005: '...' expected. +tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(27,31): error TS2698: Spread types may only be created from object types. -==== tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx (30 errors) ==== +==== tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx (31 errors) ==== declare var React: any; var justElement1 = ; @@ -88,17 +89,15 @@ tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(27,24): error TS1003: Ide var both3 = {"text"}; var endOfIdent1 = ; - ~ -!!! error TS1003: Identifier expected. - var endOfIdent2 = ; - ~ -!!! error TS1003: Identifier expected. ~ !!! error TS1003: Identifier expected. ~~~~~~~ !!! error TS1005: '...' expected. ~~~~~~~ !!! error TS2698: Spread types may only be created from object types. + var endOfIdent2 = ; + ~ +!!! error TS1003: Identifier expected. var beginOfIdent1 = <:a attr={"value"} />; ~ @@ -116,8 +115,12 @@ tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(27,24): error TS1003: Ide ~ !!! error TS1109: Expression expected. var beginOfIdent2 = ; - ~ + ~ !!! error TS1003: Identifier expected. + ~~~~~~~ +!!! error TS1005: '...' expected. + ~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. var upcaseComponent1 = ; // Parsed as intrinsic var upcaseComponent2 = ; // Parsed as instrinsic diff --git a/tests/baselines/reference/jsxNamespacePrefixInNameReact.js b/tests/baselines/reference/jsxNamespacePrefixInNameReact.js index c0cee80308aac..84158b12986f5 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInNameReact.js +++ b/tests/baselines/reference/jsxNamespacePrefixInNameReact.js @@ -63,9 +63,9 @@ var justAttribute3 = React.createElement("element", { "a:attr": "value" }, "text var both1 = React.createElement("a:element", { "a:attr": "value" }); var both2 = React.createElement("a:element", { "k:attr": "value" }); var both3 = React.createElement("a:element", { "a:attr": "value" }, "text"); -var endOfIdent1 = React.createElement("a", { attr: "value" }); -var endOfIdent2 = React.createElement("a", __assign({ attr: true }, "value")); +var endOfIdent1 = React.createElement("a:attr", __assign({}, "value")); +var endOfIdent2 = React.createElement("a", { "attr:": "value" }); var beginOfIdent1 = < , a, attr = { "value": } / > ; -var beginOfIdent2 = React.createElement("a", { attr: "value" }); +var beginOfIdent2 = React.createElement("a:attr", __assign({}, "value")); var upcaseComponent1 = React.createElement("ns:Upcase", null); // Parsed as intrinsic var upcaseComponent2 = React.createElement("Upcase:element", null); // Parsed as instrinsic diff --git a/tests/baselines/reference/jsxNamespacePrefixInNameReact.symbols b/tests/baselines/reference/jsxNamespacePrefixInNameReact.symbols index 34136573521b5..e5b56ad08f5e8 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInNameReact.symbols +++ b/tests/baselines/reference/jsxNamespacePrefixInNameReact.symbols @@ -71,11 +71,10 @@ var both3 = {"text"}; var endOfIdent1 = ; >endOfIdent1 : Symbol(endOfIdent1, Decl(jsxNamespacePrefixInNameReact.tsx, 22, 3)) ->attr : Symbol(attr, Decl(jsxNamespacePrefixInNameReact.tsx, 22, 21)) var endOfIdent2 = ; >endOfIdent2 : Symbol(endOfIdent2, Decl(jsxNamespacePrefixInNameReact.tsx, 23, 3)) ->attr : Symbol(attr, Decl(jsxNamespacePrefixInNameReact.tsx, 23, 20)) +>attr: : Symbol(attr:, Decl(jsxNamespacePrefixInNameReact.tsx, 23, 20)) var beginOfIdent1 = <:a attr={"value"} />; >beginOfIdent1 : Symbol(beginOfIdent1, Decl(jsxNamespacePrefixInNameReact.tsx, 25, 3)) @@ -85,7 +84,6 @@ var beginOfIdent1 = <:a attr={"value"} />; var beginOfIdent2 = ; >beginOfIdent2 : Symbol(beginOfIdent2, Decl(jsxNamespacePrefixInNameReact.tsx, 26, 3)) ->attr : Symbol(attr, Decl(jsxNamespacePrefixInNameReact.tsx, 26, 24)) var upcaseComponent1 = ; // Parsed as intrinsic >upcaseComponent1 : Symbol(upcaseComponent1, Decl(jsxNamespacePrefixInNameReact.tsx, 28, 3)) diff --git a/tests/baselines/reference/jsxNamespacePrefixInNameReact.types b/tests/baselines/reference/jsxNamespacePrefixInNameReact.types index e67a617796670..c177fc2e587fb 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInNameReact.types +++ b/tests/baselines/reference/jsxNamespacePrefixInNameReact.types @@ -5,50 +5,62 @@ declare var React: any; var justElement1 = ; >justElement1 : any > : any ->a:element : any +>a : any +>element : any var justElement2 = ; >justElement2 : any > : any ->a:element : any ->a:element : any +>a : any +>element : any +>a : any +>element : any var justElement3 = ; >justElement3 : any > : any ->a:element : any +>a : any +>element : any >attr : string >"value" : "value" ->a:element : any +>a : any +>element : any var justElement4 = {"text"}; >justElement4 : any >{"text"} : any ->a:element : any +>a : any +>element : any >"text" : "text" ->a:element : any +>a : any +>element : any var justElement5 = {"text"}; >justElement5 : any >{"text"} : any ->a:element : any +>a : any +>element : any >attr : string >"value" : "value" >"text" : "text" ->a:element : any +>a : any +>element : any var tooManySeparators1 = ; >tooManySeparators1 : any > : any ->a:ele : any +>a : any +>ele : any >ment : true var tooManySeparators2 = ; >tooManySeparators2 : any >a:ele : any +>a : any +>ele : any >ment : true ->a:ele : any +>a : any +>ele : any >ment : any >> : boolean > : any @@ -57,11 +69,13 @@ var tooManySeparators2 = ; var tooManySeparators3 = ; >tooManySeparators3 : any >a:ele : any +>a : any +>ele : any >ment : true >attr : string >"value" : "value" ->a:ele : any +>a : any +>ele : any >ment : any >> : boolean > : any @@ -70,10 +84,12 @@ var tooManySeparators3 = ; var tooManySeparators4 = {"text"}; >tooManySeparators4 : any >{"text"}a:ele : any +>a : any +>ele : any >ment : true >"text" : "text" ->a:ele : any +>a : any +>ele : any >ment : any >> : boolean > : any @@ -82,12 +98,14 @@ var tooManySeparators4 = {"text"}; var tooManySeparators5 = {"text"}; >tooManySeparators5 : any >{"text"}a:ele : any +>a : any +>ele : any >ment : true >attr : string >"value" : "value" >"text" : "text" ->a:ele : any +>a : any +>ele : any >ment : any >> : boolean > : any @@ -98,6 +116,8 @@ var justAttribute1 = ; > : any >element : any >a:attr : string +>a : any +>attr : any >"value" : "value" var justAttribute2 = ; @@ -105,6 +125,8 @@ var justAttribute2 = ; > : any >element : any >a:attr : string +>a : any +>attr : any >"value" : "value" >element : any @@ -113,6 +135,8 @@ var justAttribute3 = {"text"}; >{"text"} : any >element : any >a:attr : string +>a : any +>attr : any >"value" : "value" >"text" : "text" >element : any @@ -120,39 +144,52 @@ var justAttribute3 = {"text"}; var both1 = ; >both1 : any > : any ->a:element : any +>a : any +>element : any >a:attr : string +>a : any +>attr : any >"value" : "value" var both2 = ; >both2 : any > : any ->a:element : any +>a : any +>element : any >k:attr : string +>k : any +>attr : any >"value" : "value" ->a:element : any +>a : any +>element : any var both3 = {"text"}; >both3 : any >{"text"} : any ->a:element : any +>a : any +>element : any >a:attr : string +>a : any +>attr : any >"value" : "value" >"text" : "text" ->a:element : any +>a : any +>element : any var endOfIdent1 = ; >endOfIdent1 : any > : any >a : any ->attr : string +>attr : any >"value" : "value" var endOfIdent2 = ; >endOfIdent2 : any > : any >a : any ->attr : true +>attr: : string +>attr : any +> : any >"value" : "value" var beginOfIdent1 = <:a attr={"value"} />; @@ -174,16 +211,18 @@ var beginOfIdent2 = ; >beginOfIdent2 : any > : any >a : any ->attr : string +>attr : any >"value" : "value" var upcaseComponent1 = ; // Parsed as intrinsic >upcaseComponent1 : any > : any ->ns:Upcase : any +>ns : any +>Upcase : any var upcaseComponent2 = ; // Parsed as instrinsic >upcaseComponent2 : any > : any ->Upcase:element : any +>Upcase : any +>element : any diff --git a/tests/baselines/reference/jsxNamespacePrefixIntrinsics.errors.txt b/tests/baselines/reference/jsxNamespacePrefixIntrinsics.errors.txt index 22bacb161c5dd..c9a4a81eeeec1 100644 --- a/tests/baselines/reference/jsxNamespacePrefixIntrinsics.errors.txt +++ b/tests/baselines/reference/jsxNamespacePrefixIntrinsics.errors.txt @@ -1,11 +1,7 @@ tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(15,18): error TS2339: Property 'element' does not exist on type 'JSX.IntrinsicElements'. -tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(16,30): error TS2322: Type '{ attribute: string; }' is not assignable to type '{ "ns:attribute": string; }'. - Property 'attribute' does not exist on type '{ "ns:attribute": string; }'. Did you mean '"ns:attribute"'? -tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(17,30): error TS2322: Type '{ "ns:invalid": string; }' is not assignable to type '{ "ns:attribute": string; }'. - Property 'ns:invalid' does not exist on type '{ "ns:attribute": string; }'. -==== tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx (3 errors) ==== +==== tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx (1 errors) ==== declare namespace JSX { interface IntrinsicElements { "ns:element": { @@ -24,11 +20,5 @@ tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(17,30): error TS2322: Type ~~~~~~~~~~~ !!! error TS2339: Property 'element' does not exist on type 'JSX.IntrinsicElements'. const invalid2 = ; - ~~~~~~~~~ -!!! error TS2322: Type '{ attribute: string; }' is not assignable to type '{ "ns:attribute": string; }'. -!!! error TS2322: Property 'attribute' does not exist on type '{ "ns:attribute": string; }'. Did you mean '"ns:attribute"'? const invalid3 = ; - ~~~~~~~~~~ -!!! error TS2322: Type '{ "ns:invalid": string; }' is not assignable to type '{ "ns:attribute": string; }'. -!!! error TS2322: Property 'ns:invalid' does not exist on type '{ "ns:attribute": string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/jsxNamespacePrefixIntrinsics.symbols b/tests/baselines/reference/jsxNamespacePrefixIntrinsics.symbols index b12b339ca223a..31ef8f7b2db0b 100644 --- a/tests/baselines/reference/jsxNamespacePrefixIntrinsics.symbols +++ b/tests/baselines/reference/jsxNamespacePrefixIntrinsics.symbols @@ -22,27 +22,22 @@ declare namespace JSX { const valid = ; >valid : Symbol(valid, Decl(jsxNamespacePrefixIntrinsics.tsx, 10, 5)) ->ns:element : Symbol(JSX.IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31)) >ns:attribute : Symbol(ns:attribute, Decl(jsxNamespacePrefixIntrinsics.tsx, 10, 25)) const validUpcase1 = ; >validUpcase1 : Symbol(validUpcase1, Decl(jsxNamespacePrefixIntrinsics.tsx, 11, 5)) ->ns:NamespacedUpcaseAlsoIntrinsic : Symbol(JSX.IntrinsicElements["ns:NamespacedUpcaseAlsoIntrinsic"], Decl(jsxNamespacePrefixIntrinsics.tsx, 4, 6)) const validUpcase2 = ; >validUpcase2 : Symbol(validUpcase2, Decl(jsxNamespacePrefixIntrinsics.tsx, 12, 5)) ->NS:NamespacedUpcaseAlsoIntrinsic : Symbol(JSX.IntrinsicElements["NS:NamespacedUpcaseAlsoIntrinsic"], Decl(jsxNamespacePrefixIntrinsics.tsx, 5, 44)) const invalid1 = ; >invalid1 : Symbol(invalid1, Decl(jsxNamespacePrefixIntrinsics.tsx, 14, 5)) const invalid2 = ; >invalid2 : Symbol(invalid2, Decl(jsxNamespacePrefixIntrinsics.tsx, 15, 5)) ->ns:element : Symbol(JSX.IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31)) >attribute : Symbol(attribute, Decl(jsxNamespacePrefixIntrinsics.tsx, 15, 28)) const invalid3 = ; >invalid3 : Symbol(invalid3, Decl(jsxNamespacePrefixIntrinsics.tsx, 16, 5)) ->ns:element : Symbol(JSX.IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31)) >ns:invalid : Symbol(ns:invalid, Decl(jsxNamespacePrefixIntrinsics.tsx, 16, 28)) diff --git a/tests/baselines/reference/jsxNamespacePrefixIntrinsics.types b/tests/baselines/reference/jsxNamespacePrefixIntrinsics.types index 962128ca2f41a..1b4f542baee5d 100644 --- a/tests/baselines/reference/jsxNamespacePrefixIntrinsics.types +++ b/tests/baselines/reference/jsxNamespacePrefixIntrinsics.types @@ -19,18 +19,23 @@ declare namespace JSX { const valid = ; >valid : any > : any ->ns:element : any +>ns : any +>element : any >ns:attribute : string +>ns : any +>attribute : any const validUpcase1 = ; >validUpcase1 : any > : any ->ns:NamespacedUpcaseAlsoIntrinsic : any +>ns : any +>NamespacedUpcaseAlsoIntrinsic : any const validUpcase2 = ; >validUpcase2 : any > : any ->NS:NamespacedUpcaseAlsoIntrinsic : any +>NS : any +>NamespacedUpcaseAlsoIntrinsic : any const invalid1 = ; >invalid1 : any @@ -40,12 +45,16 @@ const invalid1 = ; const invalid2 = ; >invalid2 : any > : any ->ns:element : any +>ns : any +>element : any >attribute : string const invalid3 = ; >invalid3 : any > : any ->ns:element : any +>ns : any +>element : any >ns:invalid : string +>ns : any +>invalid : any diff --git a/tests/baselines/reference/tsxNamespacedAttributeName1.js b/tests/baselines/reference/tsxNamespacedAttributeName1.js new file mode 100644 index 0000000000000..736243791ff48 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedAttributeName1.js @@ -0,0 +1,8 @@ +//// [a.tsx] +const a = ; +const b = ; + + +//// [a.jsx] +var a = ; +var b = ; diff --git a/tests/baselines/reference/tsxNamespacedAttributeName1.symbols b/tests/baselines/reference/tsxNamespacedAttributeName1.symbols new file mode 100644 index 0000000000000..3256bddfb67d2 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedAttributeName1.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsx/a.tsx === +const a = ; +>a : Symbol(a, Decl(a.tsx, 0, 5)) +>a:b : Symbol(a:b, Decl(a.tsx, 0, 19)) + +const b = ; +>b : Symbol(b, Decl(a.tsx, 1, 5)) +>a:b : Symbol(a:b, Decl(a.tsx, 1, 21)) + diff --git a/tests/baselines/reference/tsxNamespacedAttributeName1.types b/tests/baselines/reference/tsxNamespacedAttributeName1.types new file mode 100644 index 0000000000000..4ab13055b7613 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedAttributeName1.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/a.tsx === +const a = ; +>a : error +> : error +>svg : error +>path : error +>a:b : number +>a : error +>b : error +>1 : 1 +>svg : error +>path : error + +const b = ; +>b : error +> : error +>svg : error +>path : error +>a:b : number +>a : error +>b : error +>1 : 1 +>svg : error +>path : error + diff --git a/tests/baselines/reference/tsxNamespacedAttributeName2.js b/tests/baselines/reference/tsxNamespacedAttributeName2.js new file mode 100644 index 0000000000000..a99853e5e96dc --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedAttributeName2.js @@ -0,0 +1,10 @@ +//// [a.tsx] +declare var React: any; + +const a = ; +const b = ; + + +//// [a.js] +var a = React.createElement("svg:path", { "a:b": 1 }); +var b = React.createElement("svg:path", { "a:b": 1 }); diff --git a/tests/baselines/reference/tsxNamespacedAttributeName2.symbols b/tests/baselines/reference/tsxNamespacedAttributeName2.symbols new file mode 100644 index 0000000000000..ba9168814e5db --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedAttributeName2.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare var React: any; +>React : Symbol(React, Decl(a.tsx, 0, 11)) + +const a = ; +>a : Symbol(a, Decl(a.tsx, 2, 5)) +>a:b : Symbol(a:b, Decl(a.tsx, 2, 19)) + +const b = ; +>b : Symbol(b, Decl(a.tsx, 3, 5)) +>a:b : Symbol(a:b, Decl(a.tsx, 3, 21)) + diff --git a/tests/baselines/reference/tsxNamespacedAttributeName2.types b/tests/baselines/reference/tsxNamespacedAttributeName2.types new file mode 100644 index 0000000000000..9415a504a8f68 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedAttributeName2.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare var React: any; +>React : any + +const a = ; +>a : error +> : error +>svg : error +>path : error +>a:b : number +>a : error +>b : error +>1 : 1 +>svg : error +>path : error + +const b = ; +>b : error +> : error +>svg : error +>path : error +>a:b : number +>a : error +>b : error +>1 : 1 +>svg : error +>path : error + diff --git a/tests/baselines/reference/tsxNamespacedTagName1.js b/tests/baselines/reference/tsxNamespacedTagName1.js new file mode 100644 index 0000000000000..8fe1db6f88a26 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedTagName1.js @@ -0,0 +1,12 @@ +//// [a.tsx] +const a = ; +const b = ; +const c = ; +const d = ; + + +//// [a.jsx] +var a = ; +var b = ; +var c = ; +var d = ; diff --git a/tests/baselines/reference/tsxNamespacedTagName1.symbols b/tests/baselines/reference/tsxNamespacedTagName1.symbols new file mode 100644 index 0000000000000..da528e4be8af6 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedTagName1.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/jsx/a.tsx === +const a = ; +>a : Symbol(a, Decl(a.tsx, 0, 5)) + +const b = ; +>b : Symbol(b, Decl(a.tsx, 1, 5)) + +const c = ; +>c : Symbol(c, Decl(a.tsx, 2, 5)) + +const d = ; +>d : Symbol(d, Decl(a.tsx, 3, 5)) + diff --git a/tests/baselines/reference/tsxNamespacedTagName1.types b/tests/baselines/reference/tsxNamespacedTagName1.types new file mode 100644 index 0000000000000..c1ae229108065 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedTagName1.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsx/a.tsx === +const a = ; +>a : error +> : error +>svg : error +>path : error +>svg : error +>path : error + +const b = ; +>b : error +> : error +>svg : error +>path : error +>svg : error +>path : error + +const c = ; +>c : error +> : error +>A : error +>foo : error +>A : error +>foo : error + +const d = ; +>d : error +> : error +>a : error +>foo : error +>a : error +>foo : error + diff --git a/tests/baselines/reference/tsxNamespacedTagName2.errors.txt b/tests/baselines/reference/tsxNamespacedTagName2.errors.txt new file mode 100644 index 0000000000000..d1cefe79cccaf --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedTagName2.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/jsx/a.tsx(5,12): error TS2639: React components cannot include JSX namespace names + + +==== tests/cases/conformance/jsx/a.tsx (1 errors) ==== + declare var React: any; + + const a = ; + const b = ; + const c = ; + ~~~~~ +!!! error TS2639: React components cannot include JSX namespace names + const d = ; + \ No newline at end of file diff --git a/tests/baselines/reference/tsxNamespacedTagName2.js b/tests/baselines/reference/tsxNamespacedTagName2.js new file mode 100644 index 0000000000000..415b4bf70cebb --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedTagName2.js @@ -0,0 +1,14 @@ +//// [a.tsx] +declare var React: any; + +const a = ; +const b = ; +const c = ; +const d = ; + + +//// [a.js] +var a = React.createElement("svg:path", null); +var b = React.createElement("svg:path", null); +var c = React.createElement("A:foo", null); +var d = React.createElement("a:foo", null); diff --git a/tests/baselines/reference/tsxNamespacedTagName2.symbols b/tests/baselines/reference/tsxNamespacedTagName2.symbols new file mode 100644 index 0000000000000..46adee08a03f4 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedTagName2.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare var React: any; +>React : Symbol(React, Decl(a.tsx, 0, 11)) + +const a = ; +>a : Symbol(a, Decl(a.tsx, 2, 5)) + +const b = ; +>b : Symbol(b, Decl(a.tsx, 3, 5)) + +const c = ; +>c : Symbol(c, Decl(a.tsx, 4, 5)) + +const d = ; +>d : Symbol(d, Decl(a.tsx, 5, 5)) + diff --git a/tests/baselines/reference/tsxNamespacedTagName2.types b/tests/baselines/reference/tsxNamespacedTagName2.types new file mode 100644 index 0000000000000..c90a5aaedc127 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedTagName2.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare var React: any; +>React : any + +const a = ; +>a : any +> : any +>svg : any +>path : any +>svg : any +>path : any + +const b = ; +>b : any +> : any +>svg : any +>path : any +>svg : any +>path : any + +const c = ; +>c : any +> : any +>A : any +>foo : any +>A : any +>foo : any + +const d = ; +>d : any +> : any +>a : any +>foo : any +>a : any +>foo : any + diff --git a/tests/cases/conformance/jsx/tsxNamespacedAttributeName1.tsx b/tests/cases/conformance/jsx/tsxNamespacedAttributeName1.tsx new file mode 100644 index 0000000000000..076556145f4ac --- /dev/null +++ b/tests/cases/conformance/jsx/tsxNamespacedAttributeName1.tsx @@ -0,0 +1,5 @@ +// @jsx: preserve +// @filename: a.tsx + +const a = ; +const b = ; diff --git a/tests/cases/conformance/jsx/tsxNamespacedAttributeName2.tsx b/tests/cases/conformance/jsx/tsxNamespacedAttributeName2.tsx new file mode 100644 index 0000000000000..e9b92585d119b --- /dev/null +++ b/tests/cases/conformance/jsx/tsxNamespacedAttributeName2.tsx @@ -0,0 +1,6 @@ +// @jsx: react +// @filename: a.tsx +declare var React: any; + +const a = ; +const b = ; diff --git a/tests/cases/conformance/jsx/tsxNamespacedTagName1.tsx b/tests/cases/conformance/jsx/tsxNamespacedTagName1.tsx new file mode 100644 index 0000000000000..ad03e0faab01c --- /dev/null +++ b/tests/cases/conformance/jsx/tsxNamespacedTagName1.tsx @@ -0,0 +1,7 @@ +// @jsx: preserve +// @filename: a.tsx + +const a = ; +const b = ; +const c = ; +const d = ; diff --git a/tests/cases/conformance/jsx/tsxNamespacedTagName2.tsx b/tests/cases/conformance/jsx/tsxNamespacedTagName2.tsx new file mode 100644 index 0000000000000..b5b06d748a9e3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxNamespacedTagName2.tsx @@ -0,0 +1,8 @@ +// @jsx: react +// @filename: a.tsx +declare var React: any; + +const a = ; +const b = ; +const c = ; +const d = ;