diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 26299645537e6..39ff399696606 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11927,7 +11927,7 @@ namespace ts { 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); @@ -17650,8 +17650,8 @@ namespace ts { 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)) }; } } @@ -26908,7 +26908,7 @@ namespace ts { if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); + return getTypeOfPropertyOfContextualType(attributesType, getEscapedTextOfJsxAttributeName(attribute.name)); } else { return getContextualType(attribute.parent); @@ -27962,7 +27962,7 @@ namespace ts { attributeSymbol.target = member; attributesTable.set(attributeSymbol.escapedName, attributeSymbol); allAttributesTable?.set(attributeSymbol.escapedName, attributeSymbol); - if (attributeDecl.name.escapedText === jsxChildrenPropertyName) { + if (getEscapedTextOfJsxAttributeName(attributeDecl.name) === jsxChildrenPropertyName) { explicitlySpecifyChildrenAttribute = true; } } @@ -44068,8 +44068,9 @@ namespace ts { } 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); @@ -44082,25 +44083,11 @@ namespace ts { } function checkGrammarJsxName(node: JsxTagNameExpression) { - if (isPropertyAccessExpression(node)) { - let propName: JsxTagNameExpression = node; - do { - const check = checkGrammarJsxNestedIdentifier(propName.name); - if (check) { - return check; - } - propName = propName.expression; - } while (isPropertyAccessExpression(propName)); - const check = checkGrammarJsxNestedIdentifier(propName); - if (check) { - return check; - } + 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 e8a765e514cb5..0ccaf380f3079 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2747,6 +2747,10 @@ "category": "Error", "code": 2637 }, + "React components cannot include JSX namespace names": { + "category": "Error", + "code": 2638 + }, "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 a0fbb74b33be1..ee348de74725e 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1744,6 +1744,8 @@ namespace ts { 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: @@ -3670,6 +3672,12 @@ namespace ts { } } + 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 cbeb8df5e5b25..b1e99d08bd45b 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -418,6 +418,9 @@ namespace ts { updateJsxSpreadAttribute, createJsxExpression, updateJsxExpression, + createJsxNamespacedName, + updateJsxNamespacedName, + createCaseClause, updateCaseClause, createDefaultClause, @@ -5036,6 +5039,26 @@ namespace ts { : 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 cf473caf65bf7..b56104d99ab1b 100644 --- a/src/compiler/factory/nodeTests.ts +++ b/src/compiler/factory/nodeTests.ts @@ -712,6 +712,10 @@ namespace ts { 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 7642612e27a44..92bdc93a3f1cd 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -519,7 +519,9 @@ namespace ts { visitNode(cbNode, (node as JsxExpression).expression); case SyntaxKind.JsxClosingElement: return visitNode(cbNode, (node as JsxClosingElement).tagName); - + case SyntaxKind.JsxNamespacedName: + return visitNode(cbNode, (node as JsxNamespacedName).namespace) || + visitNode(cbNode, (node as JsxNamespacedName).name); case SyntaxKind.OptionalType: case SyntaxKind.RestType: case SyntaxKind.JSDocTypeExpression: @@ -5418,20 +5420,31 @@ namespace ts { 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(factory.createPropertyAccessExpression(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)) { @@ -5464,11 +5477,10 @@ namespace ts { return parseJsxSpreadAttribute(); } - scanJsxIdentifier(); const pos = getNodePos(); return finishNode( factory.createJsxAttribute( - parseIdentifierName(), + parseJsxAttributeName(), token() !== SyntaxKind.EqualsToken ? undefined : scanJsxAttributeValue() === SyntaxKind.StringLiteral ? parseLiteralNode() as StringLiteral : parseJsxExpression(/*inExpressionContext*/ true) @@ -5477,6 +5489,18 @@ namespace ts { ); } + 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); @@ -9664,6 +9688,11 @@ namespace ts { 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 107ff3a143efa..70acc8b5a90be 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -2349,7 +2349,6 @@ namespace ts { // 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) { @@ -2357,24 +2356,12 @@ namespace ts { 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 d321e74817bd4..da2d09a1b7a9d 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -173,7 +173,7 @@ namespace ts { if (isJsxSpreadAttribute(elem)) { 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; } } @@ -518,12 +518,15 @@ namespace ts { 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); } } } @@ -535,13 +538,11 @@ namespace ts { */ 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 0831da97a629c..b055e9efb1f0f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -337,6 +337,7 @@ namespace ts { JsxAttributes, JsxSpreadAttribute, JsxExpression, + JsxNamespacedName, // Clauses CaseClause, @@ -2559,17 +2560,25 @@ namespace ts { | 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; @@ -2607,16 +2616,17 @@ namespace ts { 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: Identifier | JsxNamespacedName; /// JSX attribute initializers are optional; is sugar for readonly initializer?: StringLiteral | JsxExpression; } - export interface JsxSpreadAttribute extends ObjectLiteralElement { + export interface JsxSpreadAttribute extends Declaration { readonly kind: SyntaxKind.JsxSpreadAttribute; + readonly name: PropertyName; readonly parent: JsxAttributes; readonly expression: Expression; } @@ -7663,14 +7673,16 @@ namespace ts { createJsxOpeningFragment(): JsxOpeningFragment; createJsxJsxClosingFragment(): JsxClosingFragment; updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; - createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; - updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; + createJsxAttribute(name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; + updateJsxAttribute(node: JsxAttribute, name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | 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 3454d260df225..059d4cd2c4599 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1026,6 +1026,8 @@ namespace ts { } 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); } @@ -7658,4 +7660,12 @@ namespace ts { export function getParameterTypeNode(parameter: ParameterDeclaration | JSDocParameterTag) { return parameter.kind === SyntaxKind.JSDocParameterTag ? parameter.typeExpression?.type : parameter.type; } + + export function getEscapedTextOfJsxAttributeName(node: Identifier | JsxNamespacedName): __String { + return isIdentifier(node) ? node.escapedText : (getEscapedTextOfJsxAttributeName(node.namespace) + ":" + getEscapedTextOfJsxAttributeName(node.name)) as __String; + } + + export function getTextOfJsxAttributeName(node: Identifier | JsxNamespacedName): string { + return isIdentifier(node) ? idText(node) : getTextOfJsxAttributeName(node.namespace) + ":" + getTextOfJsxAttributeName(node.name); + } } diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index ecfb4e52dafca..821ec4fc8c5d3 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -1522,6 +1522,7 @@ namespace ts { case SyntaxKind.JsxElement: case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxFragment: + case SyntaxKind.JsxNamespacedName: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.ParenthesizedExpression: @@ -1865,7 +1866,8 @@ namespace ts { const kind = node.kind; return kind === SyntaxKind.ThisKeyword || kind === SyntaxKind.Identifier - || kind === SyntaxKind.PropertyAccessExpression; + || kind === SyntaxKind.PropertyAccessExpression + || kind === SyntaxKind.JsxNamespacedName; } /* @internal */ diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index d7606830ea1ea..5961869229fb2 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -589,7 +589,7 @@ namespace ts.codefix { 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 1f1007f2f6150..e67f0ee7a2fd6 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -3673,7 +3673,7 @@ namespace ts.Completions { } 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 61f90c9817d7d..d90eff1b0f480 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -268,7 +268,7 @@ namespace ts.Completions.StringCompletions { 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 6146af8bb9f75..64cc98703f099 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -394,74 +394,75 @@ declare namespace ts { JsxAttributes = 286, JsxSpreadAttribute = 287, JsxExpression = 288, - CaseClause = 289, - DefaultClause = 290, - HeritageClause = 291, - CatchClause = 292, - AssertClause = 293, - AssertEntry = 294, - ImportTypeAssertionContainer = 295, - PropertyAssignment = 296, - ShorthandPropertyAssignment = 297, - SpreadAssignment = 298, - EnumMember = 299, - UnparsedPrologue = 300, - UnparsedPrepend = 301, - UnparsedText = 302, - UnparsedInternalText = 303, - UnparsedSyntheticReference = 304, - SourceFile = 305, - Bundle = 306, - UnparsedSource = 307, - InputFiles = 308, - JSDocTypeExpression = 309, - JSDocNameReference = 310, - JSDocMemberName = 311, - JSDocAllType = 312, - JSDocUnknownType = 313, - JSDocNullableType = 314, - JSDocNonNullableType = 315, - JSDocOptionalType = 316, - JSDocFunctionType = 317, - JSDocVariadicType = 318, - JSDocNamepathType = 319, + JsxNamespacedName = 289, + CaseClause = 290, + DefaultClause = 291, + HeritageClause = 292, + CatchClause = 293, + AssertClause = 294, + AssertEntry = 295, + ImportTypeAssertionContainer = 296, + PropertyAssignment = 297, + ShorthandPropertyAssignment = 298, + SpreadAssignment = 299, + EnumMember = 300, + UnparsedPrologue = 301, + UnparsedPrepend = 302, + UnparsedText = 303, + UnparsedInternalText = 304, + UnparsedSyntheticReference = 305, + SourceFile = 306, + Bundle = 307, + UnparsedSource = 308, + InputFiles = 309, + JSDocTypeExpression = 310, + JSDocNameReference = 311, + JSDocMemberName = 312, + JSDocAllType = 313, + JSDocUnknownType = 314, + JSDocNullableType = 315, + JSDocNonNullableType = 316, + JSDocOptionalType = 317, + JSDocFunctionType = 318, + JSDocVariadicType = 319, + JSDocNamepathType = 320, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 320, - JSDocText = 321, - JSDocTypeLiteral = 322, - JSDocSignature = 323, - JSDocLink = 324, - JSDocLinkCode = 325, - JSDocLinkPlain = 326, - JSDocTag = 327, - JSDocAugmentsTag = 328, - JSDocImplementsTag = 329, - JSDocAuthorTag = 330, - JSDocDeprecatedTag = 331, - JSDocClassTag = 332, - JSDocPublicTag = 333, - JSDocPrivateTag = 334, - JSDocProtectedTag = 335, - JSDocReadonlyTag = 336, - JSDocOverrideTag = 337, - JSDocCallbackTag = 338, - JSDocEnumTag = 339, - JSDocParameterTag = 340, - JSDocReturnTag = 341, - JSDocThisTag = 342, - JSDocTypeTag = 343, - JSDocTemplateTag = 344, - JSDocTypedefTag = 345, - JSDocSeeTag = 346, - JSDocPropertyTag = 347, - SyntaxList = 348, - NotEmittedStatement = 349, - PartiallyEmittedExpression = 350, - CommaListExpression = 351, - MergeDeclarationMarker = 352, - EndOfDeclarationMarker = 353, - SyntheticReferenceExpression = 354, - Count = 355, + JSDocComment = 321, + JSDocText = 322, + JSDocTypeLiteral = 323, + JSDocSignature = 324, + JSDocLink = 325, + JSDocLinkCode = 326, + JSDocLinkPlain = 327, + JSDocTag = 328, + JSDocAugmentsTag = 329, + JSDocImplementsTag = 330, + JSDocAuthorTag = 331, + JSDocDeprecatedTag = 332, + JSDocClassTag = 333, + JSDocPublicTag = 334, + JSDocPrivateTag = 335, + JSDocProtectedTag = 336, + JSDocReadonlyTag = 337, + JSDocOverrideTag = 338, + JSDocCallbackTag = 339, + JSDocEnumTag = 340, + JSDocParameterTag = 341, + JSDocReturnTag = 342, + JSDocThisTag = 343, + JSDocTypeTag = 344, + JSDocTemplateTag = 345, + JSDocTypedefTag = 346, + JSDocSeeTag = 347, + JSDocPropertyTag = 348, + SyntaxList = 349, + NotEmittedStatement = 350, + PartiallyEmittedExpression = 351, + CommaListExpression = 352, + MergeDeclarationMarker = 353, + EndOfDeclarationMarker = 354, + SyntheticReferenceExpression = 355, + Count = 356, FirstAssignment = 63, LastAssignment = 78, FirstCompoundAssignment = 64, @@ -489,11 +490,11 @@ declare namespace ts { FirstStatement = 237, LastStatement = 253, FirstNode = 161, - FirstJSDocNode = 309, - LastJSDocNode = 347, - FirstJSDocTagNode = 327, - LastJSDocTagNode = 347, - JSDoc = 320 + FirstJSDocNode = 310, + LastJSDocNode = 348, + FirstJSDocTagNode = 328, + LastJSDocTagNode = 348, + JSDoc = 321 } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; @@ -1349,14 +1350,20 @@ declare namespace ts { } export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + 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; + } export interface JsxOpeningElement extends Expression { readonly kind: SyntaxKind.JsxOpeningElement; readonly parent: JsxElement; @@ -1384,14 +1391,15 @@ declare namespace ts { readonly kind: SyntaxKind.JsxClosingFragment; 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: Identifier | JsxNamespacedName; readonly initializer?: StringLiteral | JsxExpression; } - export interface JsxSpreadAttribute extends ObjectLiteralElement { + export interface JsxSpreadAttribute extends Declaration { readonly kind: SyntaxKind.JsxSpreadAttribute; + readonly name: PropertyName; readonly parent: JsxAttributes; readonly expression: Expression; } @@ -3744,14 +3752,16 @@ declare namespace ts { createJsxOpeningFragment(): JsxOpeningFragment; createJsxJsxClosingFragment(): JsxClosingFragment; updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; - createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; - updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; + createJsxAttribute(name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; + updateJsxAttribute(node: JsxAttribute, name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | 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; @@ -4742,6 +4752,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; @@ -11317,9 +11328,9 @@ declare namespace ts { /** @deprecated Use `factory.updateJsxFragment` or the factory supplied by your transformation context instead. */ const updateJsxFragment: (node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment) => JsxFragment; /** @deprecated Use `factory.createJsxAttribute` or the factory supplied by your transformation context instead. */ - const createJsxAttribute: (name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; + const createJsxAttribute: (name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; /** @deprecated Use `factory.updateJsxAttribute` or the factory supplied by your transformation context instead. */ - const updateJsxAttribute: (node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; + const updateJsxAttribute: (node: JsxAttribute, name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; /** @deprecated Use `factory.createJsxAttributes` or the factory supplied by your transformation context instead. */ const createJsxAttributes: (properties: readonly JsxAttributeLike[]) => JsxAttributes; /** @deprecated Use `factory.updateJsxAttributes` or the factory supplied by your transformation context instead. */ diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 22af7579a0367..ee5d116879c66 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -394,74 +394,75 @@ declare namespace ts { JsxAttributes = 286, JsxSpreadAttribute = 287, JsxExpression = 288, - CaseClause = 289, - DefaultClause = 290, - HeritageClause = 291, - CatchClause = 292, - AssertClause = 293, - AssertEntry = 294, - ImportTypeAssertionContainer = 295, - PropertyAssignment = 296, - ShorthandPropertyAssignment = 297, - SpreadAssignment = 298, - EnumMember = 299, - UnparsedPrologue = 300, - UnparsedPrepend = 301, - UnparsedText = 302, - UnparsedInternalText = 303, - UnparsedSyntheticReference = 304, - SourceFile = 305, - Bundle = 306, - UnparsedSource = 307, - InputFiles = 308, - JSDocTypeExpression = 309, - JSDocNameReference = 310, - JSDocMemberName = 311, - JSDocAllType = 312, - JSDocUnknownType = 313, - JSDocNullableType = 314, - JSDocNonNullableType = 315, - JSDocOptionalType = 316, - JSDocFunctionType = 317, - JSDocVariadicType = 318, - JSDocNamepathType = 319, + JsxNamespacedName = 289, + CaseClause = 290, + DefaultClause = 291, + HeritageClause = 292, + CatchClause = 293, + AssertClause = 294, + AssertEntry = 295, + ImportTypeAssertionContainer = 296, + PropertyAssignment = 297, + ShorthandPropertyAssignment = 298, + SpreadAssignment = 299, + EnumMember = 300, + UnparsedPrologue = 301, + UnparsedPrepend = 302, + UnparsedText = 303, + UnparsedInternalText = 304, + UnparsedSyntheticReference = 305, + SourceFile = 306, + Bundle = 307, + UnparsedSource = 308, + InputFiles = 309, + JSDocTypeExpression = 310, + JSDocNameReference = 311, + JSDocMemberName = 312, + JSDocAllType = 313, + JSDocUnknownType = 314, + JSDocNullableType = 315, + JSDocNonNullableType = 316, + JSDocOptionalType = 317, + JSDocFunctionType = 318, + JSDocVariadicType = 319, + JSDocNamepathType = 320, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 320, - JSDocText = 321, - JSDocTypeLiteral = 322, - JSDocSignature = 323, - JSDocLink = 324, - JSDocLinkCode = 325, - JSDocLinkPlain = 326, - JSDocTag = 327, - JSDocAugmentsTag = 328, - JSDocImplementsTag = 329, - JSDocAuthorTag = 330, - JSDocDeprecatedTag = 331, - JSDocClassTag = 332, - JSDocPublicTag = 333, - JSDocPrivateTag = 334, - JSDocProtectedTag = 335, - JSDocReadonlyTag = 336, - JSDocOverrideTag = 337, - JSDocCallbackTag = 338, - JSDocEnumTag = 339, - JSDocParameterTag = 340, - JSDocReturnTag = 341, - JSDocThisTag = 342, - JSDocTypeTag = 343, - JSDocTemplateTag = 344, - JSDocTypedefTag = 345, - JSDocSeeTag = 346, - JSDocPropertyTag = 347, - SyntaxList = 348, - NotEmittedStatement = 349, - PartiallyEmittedExpression = 350, - CommaListExpression = 351, - MergeDeclarationMarker = 352, - EndOfDeclarationMarker = 353, - SyntheticReferenceExpression = 354, - Count = 355, + JSDocComment = 321, + JSDocText = 322, + JSDocTypeLiteral = 323, + JSDocSignature = 324, + JSDocLink = 325, + JSDocLinkCode = 326, + JSDocLinkPlain = 327, + JSDocTag = 328, + JSDocAugmentsTag = 329, + JSDocImplementsTag = 330, + JSDocAuthorTag = 331, + JSDocDeprecatedTag = 332, + JSDocClassTag = 333, + JSDocPublicTag = 334, + JSDocPrivateTag = 335, + JSDocProtectedTag = 336, + JSDocReadonlyTag = 337, + JSDocOverrideTag = 338, + JSDocCallbackTag = 339, + JSDocEnumTag = 340, + JSDocParameterTag = 341, + JSDocReturnTag = 342, + JSDocThisTag = 343, + JSDocTypeTag = 344, + JSDocTemplateTag = 345, + JSDocTypedefTag = 346, + JSDocSeeTag = 347, + JSDocPropertyTag = 348, + SyntaxList = 349, + NotEmittedStatement = 350, + PartiallyEmittedExpression = 351, + CommaListExpression = 352, + MergeDeclarationMarker = 353, + EndOfDeclarationMarker = 354, + SyntheticReferenceExpression = 355, + Count = 356, FirstAssignment = 63, LastAssignment = 78, FirstCompoundAssignment = 64, @@ -489,11 +490,11 @@ declare namespace ts { FirstStatement = 237, LastStatement = 253, FirstNode = 161, - FirstJSDocNode = 309, - LastJSDocNode = 347, - FirstJSDocTagNode = 327, - LastJSDocTagNode = 347, - JSDoc = 320 + FirstJSDocNode = 310, + LastJSDocNode = 348, + FirstJSDocTagNode = 328, + LastJSDocTagNode = 348, + JSDoc = 321 } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; @@ -1349,14 +1350,20 @@ declare namespace ts { } export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + 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; + } export interface JsxOpeningElement extends Expression { readonly kind: SyntaxKind.JsxOpeningElement; readonly parent: JsxElement; @@ -1384,14 +1391,15 @@ declare namespace ts { readonly kind: SyntaxKind.JsxClosingFragment; 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: Identifier | JsxNamespacedName; readonly initializer?: StringLiteral | JsxExpression; } - export interface JsxSpreadAttribute extends ObjectLiteralElement { + export interface JsxSpreadAttribute extends Declaration { readonly kind: SyntaxKind.JsxSpreadAttribute; + readonly name: PropertyName; readonly parent: JsxAttributes; readonly expression: Expression; } @@ -3744,14 +3752,16 @@ declare namespace ts { createJsxOpeningFragment(): JsxOpeningFragment; createJsxJsxClosingFragment(): JsxClosingFragment; updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; - createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; - updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; + createJsxAttribute(name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; + updateJsxAttribute(node: JsxAttribute, name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | 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; @@ -4742,6 +4752,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; @@ -7466,9 +7477,9 @@ declare namespace ts { /** @deprecated Use `factory.updateJsxFragment` or the factory supplied by your transformation context instead. */ const updateJsxFragment: (node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment) => JsxFragment; /** @deprecated Use `factory.createJsxAttribute` or the factory supplied by your transformation context instead. */ - const createJsxAttribute: (name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; + const createJsxAttribute: (name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; /** @deprecated Use `factory.updateJsxAttribute` or the factory supplied by your transformation context instead. */ - const updateJsxAttribute: (node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; + const updateJsxAttribute: (node: JsxAttribute, name: Identifier | JsxNamespacedName, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute; /** @deprecated Use `factory.createJsxAttributes` or the factory supplied by your transformation context instead. */ const createJsxAttributes: (properties: readonly JsxAttributeLike[]) => JsxAttributes; /** @deprecated Use `factory.updateJsxAttributes` or the factory supplied by your transformation context instead. */ 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 7061befb881aa..e2b557cee2190 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 1269825548570..aa53f23806fff 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 />; @@ -129,14 +127,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 0b215a47a7c2d..65c5eaf33ea41 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 cb54dc62c3af7..fe2b2ec265339 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 2eb3df02ad13a..8e56974a07de8 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt +++ b/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt @@ -15,10 +15,9 @@ 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(22,27): error TS1003: Identifier expected. -tests/cases/compiler/jsxNamespacePrefixInName.tsx(22,29): error TS1005: '...' expected. 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. @@ -26,7 +25,8 @@ 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 (29 errors) ==== @@ -85,15 +85,13 @@ 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. + var endOfIdent2 = ; + ~ +!!! error TS1003: Identifier expected. var beginOfIdent1 = <:a attr={"value"} />; ~ @@ -111,8 +109,10 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,24): error TS1003: Identifi ~ !!! error TS1109: Expression expected. var beginOfIdent2 = ; - ~ + ~ !!! error TS1003: Identifier expected. + ~~~~~~~ +!!! error TS1005: '...' expected. 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 890fc67fc262a..ab9d561db6b04 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt +++ b/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt @@ -15,10 +15,9 @@ 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(24,27): error TS1003: Identifier expected. -tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(24,29): error TS1005: '...' expected. 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. @@ -26,7 +25,8 @@ 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 (29 errors) ==== @@ -87,15 +87,13 @@ 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. + var endOfIdent2 = ; + ~ +!!! error TS1003: Identifier expected. var beginOfIdent1 = <:a attr={"value"} />; ~ @@ -113,8 +111,10 @@ tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(27,24): error TS1003: Ide ~ !!! error TS1109: Expression expected. var beginOfIdent2 = ; - ~ + ~ !!! error TS1003: Identifier expected. + ~~~~~~~ +!!! error TS1005: '...' expected. 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 f7142133ebe14..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; }'. -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; }'. 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..def71195752a5 --- /dev/null +++ b/tests/baselines/reference/tsxNamespacedTagName2.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/jsx/a.tsx(5,12): error TS2637: 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 TS2637: 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 = ;