mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 17:30:04 -05:00
fix(7410): allow using JSXElement as JSXAttributeValue (#47994)
This commit is contained in:
@@ -435,6 +435,10 @@
|
||||
"category": "Error",
|
||||
"code": 1144
|
||||
},
|
||||
"'{' or JSX element expected.": {
|
||||
"category": "Error",
|
||||
"code": 1145
|
||||
},
|
||||
"Declaration expected.": {
|
||||
"category": "Error",
|
||||
"code": 1146
|
||||
|
||||
@@ -4964,7 +4964,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// @api
|
||||
function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined) {
|
||||
function createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined) {
|
||||
const node = createBaseNode<JsxAttribute>(SyntaxKind.JsxAttribute);
|
||||
node.name = name;
|
||||
node.initializer = initializer;
|
||||
@@ -4976,7 +4976,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// @api
|
||||
function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined) {
|
||||
function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined) {
|
||||
return node.name !== name
|
||||
|| node.initializer !== initializer
|
||||
? update(createJsxAttribute(name, initializer), node)
|
||||
|
||||
@@ -5454,15 +5454,23 @@ namespace ts {
|
||||
|
||||
scanJsxIdentifier();
|
||||
const pos = getNodePos();
|
||||
return finishNode(
|
||||
factory.createJsxAttribute(
|
||||
parseIdentifierName(),
|
||||
token() !== SyntaxKind.EqualsToken ? undefined :
|
||||
scanJsxAttributeValue() === SyntaxKind.StringLiteral ? parseLiteralNode() as StringLiteral :
|
||||
parseJsxExpression(/*inExpressionContext*/ true)
|
||||
),
|
||||
pos
|
||||
);
|
||||
return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos);
|
||||
}
|
||||
|
||||
function parseJsxAttributeValue(): JsxAttributeValue | undefined {
|
||||
if (token() === SyntaxKind.EqualsToken) {
|
||||
if (scanJsxAttributeValue() === SyntaxKind.StringLiteral) {
|
||||
return parseLiteralNode() as StringLiteral;
|
||||
}
|
||||
if (token() === SyntaxKind.OpenBraceToken) {
|
||||
return parseJsxExpression(/*inExpressionContext*/ true);
|
||||
}
|
||||
if (token() === SyntaxKind.LessThanToken) {
|
||||
return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true);
|
||||
}
|
||||
parseErrorAtCurrentToken(Diagnostics.or_JSX_element_expected);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parseJsxSpreadAttribute(): JsxSpreadAttribute {
|
||||
|
||||
@@ -400,26 +400,33 @@ namespace ts {
|
||||
return factory.createPropertyAssignment(name, expression);
|
||||
}
|
||||
|
||||
function transformJsxAttributeInitializer(node: StringLiteral | JsxExpression | undefined): Expression {
|
||||
function transformJsxAttributeInitializer(node: JsxAttributeValue | undefined): Expression {
|
||||
if (node === undefined) {
|
||||
return factory.createTrue();
|
||||
}
|
||||
else if (node.kind === SyntaxKind.StringLiteral) {
|
||||
if (node.kind === SyntaxKind.StringLiteral) {
|
||||
// Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which
|
||||
// Need to be escaped to be handled correctly in a normal string
|
||||
const singleQuote = node.singleQuote !== undefined ? node.singleQuote : !isStringDoubleQuoted(node, currentSourceFile);
|
||||
const literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote);
|
||||
return setTextRange(literal, node);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.JsxExpression) {
|
||||
if (node.kind === SyntaxKind.JsxExpression) {
|
||||
if (node.expression === undefined) {
|
||||
return factory.createTrue();
|
||||
}
|
||||
return visitNode(node.expression, visitor, isExpression);
|
||||
}
|
||||
else {
|
||||
return Debug.failBadSyntaxKind(node);
|
||||
if (isJsxElement(node)) {
|
||||
return visitJsxElement(node, /*isChild*/ false);
|
||||
}
|
||||
if (isJsxSelfClosingElement(node)) {
|
||||
return visitJsxSelfClosingElement(node, /*isChild*/ false);
|
||||
}
|
||||
if (isJsxFragment(node)) {
|
||||
return visitJsxFragment(node, /*isChild*/ false);
|
||||
}
|
||||
return Debug.failBadSyntaxKind(node);
|
||||
}
|
||||
|
||||
function visitJsxText(node: JsxText): StringLiteral | undefined {
|
||||
|
||||
@@ -2612,9 +2612,16 @@ namespace ts {
|
||||
readonly parent: JsxAttributes;
|
||||
readonly name: Identifier;
|
||||
/// JSX attribute initializers are optional; <X y /> is sugar for <X y={true} />
|
||||
readonly initializer?: StringLiteral | JsxExpression;
|
||||
readonly initializer?: JsxAttributeValue;
|
||||
}
|
||||
|
||||
export type JsxAttributeValue =
|
||||
| StringLiteral
|
||||
| JsxExpression
|
||||
| JsxElement
|
||||
| JsxSelfClosingElement
|
||||
| JsxFragment;
|
||||
|
||||
export interface JsxSpreadAttribute extends ObjectLiteralElement {
|
||||
readonly kind: SyntaxKind.JsxSpreadAttribute;
|
||||
readonly parent: JsxAttributes;
|
||||
@@ -7680,8 +7687,8 @@ 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, initializer: JsxAttributeValue | undefined): JsxAttribute;
|
||||
updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute;
|
||||
createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes;
|
||||
updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes;
|
||||
createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute;
|
||||
|
||||
@@ -1388,8 +1388,9 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.JsxAttribute;
|
||||
readonly parent: JsxAttributes;
|
||||
readonly name: Identifier;
|
||||
readonly initializer?: StringLiteral | JsxExpression;
|
||||
readonly initializer?: JsxAttributeValue;
|
||||
}
|
||||
export type JsxAttributeValue = StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment;
|
||||
export interface JsxSpreadAttribute extends ObjectLiteralElement {
|
||||
readonly kind: SyntaxKind.JsxSpreadAttribute;
|
||||
readonly parent: JsxAttributes;
|
||||
@@ -3746,8 +3747,8 @@ 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, initializer: JsxAttributeValue | undefined): JsxAttribute;
|
||||
updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute;
|
||||
createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes;
|
||||
updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes;
|
||||
createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute;
|
||||
@@ -11339,9 +11340,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, initializer: JsxAttributeValue | 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, initializer: JsxAttributeValue | 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. */
|
||||
|
||||
11
tests/baselines/reference/api/typescript.d.ts
vendored
11
tests/baselines/reference/api/typescript.d.ts
vendored
@@ -1388,8 +1388,9 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.JsxAttribute;
|
||||
readonly parent: JsxAttributes;
|
||||
readonly name: Identifier;
|
||||
readonly initializer?: StringLiteral | JsxExpression;
|
||||
readonly initializer?: JsxAttributeValue;
|
||||
}
|
||||
export type JsxAttributeValue = StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment;
|
||||
export interface JsxSpreadAttribute extends ObjectLiteralElement {
|
||||
readonly kind: SyntaxKind.JsxSpreadAttribute;
|
||||
readonly parent: JsxAttributes;
|
||||
@@ -3746,8 +3747,8 @@ 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, initializer: JsxAttributeValue | undefined): JsxAttribute;
|
||||
updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined): JsxAttribute;
|
||||
createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes;
|
||||
updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes;
|
||||
createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute;
|
||||
@@ -7481,9 +7482,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, initializer: JsxAttributeValue | 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, initializer: JsxAttributeValue | 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. */
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/jsx/a.tsx(7,16): error TS1145: '{' or JSX element expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/a.tsx (1 errors) ====
|
||||
declare var React: any;
|
||||
|
||||
<div>
|
||||
<div attr=<div /> />
|
||||
<div attr=<div>foo</div> />
|
||||
<div attr=<><div>foo</div></> />
|
||||
<div attr= />
|
||||
~
|
||||
!!! error TS1145: '{' or JSX element expected.
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//// [a.tsx]
|
||||
declare var React: any;
|
||||
|
||||
<div>
|
||||
<div attr=<div /> />
|
||||
<div attr=<div>foo</div> />
|
||||
<div attr=<><div>foo</div></> />
|
||||
<div attr= />
|
||||
</div>
|
||||
|
||||
|
||||
//// [a.jsx]
|
||||
<div>
|
||||
<div attr=<div />/>
|
||||
<div attr=<div>foo</div>/>
|
||||
<div attr=<><div>foo</div></>/>
|
||||
<div attr/>
|
||||
</div>;
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/jsx/a.tsx ===
|
||||
declare var React: any;
|
||||
>React : Symbol(React, Decl(a.tsx, 0, 11))
|
||||
|
||||
<div>
|
||||
<div attr=<div /> />
|
||||
>attr : Symbol(attr, Decl(a.tsx, 3, 8))
|
||||
|
||||
<div attr=<div>foo</div> />
|
||||
>attr : Symbol(attr, Decl(a.tsx, 4, 8))
|
||||
|
||||
<div attr=<><div>foo</div></> />
|
||||
>attr : Symbol(attr, Decl(a.tsx, 5, 8))
|
||||
|
||||
<div attr= />
|
||||
>attr : Symbol(attr, Decl(a.tsx, 6, 8))
|
||||
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/conformance/jsx/a.tsx ===
|
||||
declare var React: any;
|
||||
>React : any
|
||||
|
||||
<div>
|
||||
><div> <div attr=<div /> /> <div attr=<div>foo</div> /> <div attr=<><div>foo</div></> /> <div attr= /></div> : any
|
||||
>div : any
|
||||
|
||||
<div attr=<div /> />
|
||||
><div attr=<div /> /> : any
|
||||
>div : any
|
||||
>attr : any
|
||||
><div /> : any
|
||||
>div : any
|
||||
|
||||
<div attr=<div>foo</div> />
|
||||
><div attr=<div>foo</div> /> : any
|
||||
>div : any
|
||||
>attr : any
|
||||
><div>foo</div> : any
|
||||
>div : any
|
||||
>div : any
|
||||
|
||||
<div attr=<><div>foo</div></> />
|
||||
><div attr=<><div>foo</div></> /> : any
|
||||
>div : any
|
||||
>attr : any
|
||||
><><div>foo</div></> : any
|
||||
><div>foo</div> : any
|
||||
>div : any
|
||||
>div : any
|
||||
|
||||
<div attr= />
|
||||
><div attr= /> : any
|
||||
>div : any
|
||||
>attr : true
|
||||
|
||||
</div>
|
||||
>div : any
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/jsx/a.tsx(7,16): error TS1145: '{' or JSX element expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/a.tsx (1 errors) ====
|
||||
declare var React: any;
|
||||
|
||||
<div>
|
||||
<div attr=<div /> />
|
||||
<div attr=<div>foo</div> />
|
||||
<div attr=<><div>foo</div></> />
|
||||
<div attr= />
|
||||
~
|
||||
!!! error TS1145: '{' or JSX element expected.
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//// [a.tsx]
|
||||
declare var React: any;
|
||||
|
||||
<div>
|
||||
<div attr=<div /> />
|
||||
<div attr=<div>foo</div> />
|
||||
<div attr=<><div>foo</div></> />
|
||||
<div attr= />
|
||||
</div>
|
||||
|
||||
|
||||
//// [a.js]
|
||||
React.createElement("div", null,
|
||||
React.createElement("div", { attr: React.createElement("div", null) }),
|
||||
React.createElement("div", { attr: React.createElement("div", null, "foo") }),
|
||||
React.createElement("div", { attr: React.createElement(React.Fragment, null,
|
||||
React.createElement("div", null, "foo")) }),
|
||||
React.createElement("div", { attr: true }));
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/jsx/a.tsx ===
|
||||
declare var React: any;
|
||||
>React : Symbol(React, Decl(a.tsx, 0, 11))
|
||||
|
||||
<div>
|
||||
<div attr=<div /> />
|
||||
>attr : Symbol(attr, Decl(a.tsx, 3, 8))
|
||||
|
||||
<div attr=<div>foo</div> />
|
||||
>attr : Symbol(attr, Decl(a.tsx, 4, 8))
|
||||
|
||||
<div attr=<><div>foo</div></> />
|
||||
>attr : Symbol(attr, Decl(a.tsx, 5, 8))
|
||||
|
||||
<div attr= />
|
||||
>attr : Symbol(attr, Decl(a.tsx, 6, 8))
|
||||
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/conformance/jsx/a.tsx ===
|
||||
declare var React: any;
|
||||
>React : any
|
||||
|
||||
<div>
|
||||
><div> <div attr=<div /> /> <div attr=<div>foo</div> /> <div attr=<><div>foo</div></> /> <div attr= /></div> : any
|
||||
>div : any
|
||||
|
||||
<div attr=<div /> />
|
||||
><div attr=<div /> /> : any
|
||||
>div : any
|
||||
>attr : any
|
||||
><div /> : any
|
||||
>div : any
|
||||
|
||||
<div attr=<div>foo</div> />
|
||||
><div attr=<div>foo</div> /> : any
|
||||
>div : any
|
||||
>attr : any
|
||||
><div>foo</div> : any
|
||||
>div : any
|
||||
>div : any
|
||||
|
||||
<div attr=<><div>foo</div></> />
|
||||
><div attr=<><div>foo</div></> /> : any
|
||||
>div : any
|
||||
>attr : any
|
||||
><><div>foo</div></> : any
|
||||
><div>foo</div> : any
|
||||
>div : any
|
||||
>div : any
|
||||
|
||||
<div attr= />
|
||||
><div attr= /> : any
|
||||
>div : any
|
||||
>attr : true
|
||||
|
||||
</div>
|
||||
>div : any
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/compiler/jsxAttributeMissingInitializer.tsx(1,21): error TS1005: '{' expected.
|
||||
tests/cases/compiler/jsxAttributeMissingInitializer.tsx(1,21): error TS1145: '{' or JSX element expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/jsxAttributeMissingInitializer.tsx (1 errors) ====
|
||||
const x = <div foo= ></div>;
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
!!! error TS1145: '{' or JSX element expected.
|
||||
const y = 0;
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,1): error TS2657: JSX expressions must have one parent element.
|
||||
tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,17): error TS1005: '{' expected.
|
||||
tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,23): error TS1005: ';' expected.
|
||||
tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,23): error TS2304: Cannot find name 'right'.
|
||||
tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,41): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`?
|
||||
tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,57): error TS1109: Expression expected.
|
||||
tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,58): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx (7 errors) ====
|
||||
==== tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx (1 errors) ====
|
||||
declare var React: any;
|
||||
declare var 日本語;
|
||||
declare var AbC_def;
|
||||
@@ -48,20 +42,8 @@ tests/cases/conformance/jsx/jsxEsprimaFbTestSuite.tsx(40,58): error TS1109: Expr
|
||||
<div><br />7x invalid-js-identifier</div>;
|
||||
|
||||
<LeftRight left=<a /> right=<b>monkeys /> gorillas</b> />;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2657: JSX expressions must have one parent element.
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
~~~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'right'.
|
||||
~
|
||||
!!! error TS1382: Unexpected token. Did you mean `{'>'}` or `>`?
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
|
||||
<a.b></a.b>;
|
||||
|
||||
|
||||
@@ -72,8 +72,7 @@ baz
|
||||
<a>{/* this is a comment */}</a>;
|
||||
<div>@test content</div>;
|
||||
<div><br />7x invalid-js-identifier</div>;
|
||||
<LeftRight left/>, <a />;
|
||||
right = <b>monkeys /> gorillas</b> / > ;
|
||||
<LeftRight left=<a /> right=<b>monkeys /> gorillas</b>/>;
|
||||
<a.b></a.b>;
|
||||
<a.b.c></a.b.c>;
|
||||
(<div />) < x;
|
||||
|
||||
@@ -77,6 +77,7 @@ baz
|
||||
<LeftRight left=<a /> right=<b>monkeys /> gorillas</b> />;
|
||||
>LeftRight : Symbol(LeftRight, Decl(jsxEsprimaFbTestSuite.tsx, 3, 11))
|
||||
>left : Symbol(left, Decl(jsxEsprimaFbTestSuite.tsx, 39, 10))
|
||||
>right : Symbol(right, Decl(jsxEsprimaFbTestSuite.tsx, 39, 21))
|
||||
|
||||
<a.b></a.b>;
|
||||
>a : Symbol(a, Decl(jsxEsprimaFbTestSuite.tsx, 5, 11))
|
||||
|
||||
@@ -118,21 +118,15 @@ baz
|
||||
>div : any
|
||||
|
||||
<LeftRight left=<a /> right=<b>monkeys /> gorillas</b> />;
|
||||
><LeftRight left=<a /> : any
|
||||
><LeftRight left= : any
|
||||
><LeftRight left=<a /> right=<b>monkeys /> gorillas</b> /> : any
|
||||
>LeftRight : any
|
||||
>left : true
|
||||
>left : any
|
||||
><a /> : any
|
||||
>a : any
|
||||
>right=<b>monkeys /> gorillas</b> /> : boolean
|
||||
>right : any
|
||||
><b>monkeys /> gorillas</b> /> : boolean
|
||||
><b>monkeys /> gorillas</b> / : number
|
||||
><b>monkeys /> gorillas</b> : any
|
||||
>b : any
|
||||
>b : any
|
||||
> : any
|
||||
> : any
|
||||
|
||||
<a.b></a.b>;
|
||||
><a.b></a.b> : any
|
||||
|
||||
@@ -57,10 +57,8 @@ tests/cases/conformance/jsx/25.tsx(1,39): error TS1109: Expression expected.
|
||||
tests/cases/conformance/jsx/26.tsx(1,4): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`?
|
||||
tests/cases/conformance/jsx/27.tsx(1,5): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`?
|
||||
tests/cases/conformance/jsx/28.tsx(1,2): error TS17008: JSX element 'a' has no corresponding closing tag.
|
||||
tests/cases/conformance/jsx/28.tsx(1,6): error TS1005: '{' expected.
|
||||
tests/cases/conformance/jsx/28.tsx(1,6): error TS1145: '{' or JSX element expected.
|
||||
tests/cases/conformance/jsx/28.tsx(2,1): error TS1005: '</' expected.
|
||||
tests/cases/conformance/jsx/29.tsx(1,1): error TS2657: JSX expressions must have one parent element.
|
||||
tests/cases/conformance/jsx/29.tsx(1,6): error TS1005: '{' expected.
|
||||
tests/cases/conformance/jsx/29.tsx(1,7): error TS1003: Identifier expected.
|
||||
tests/cases/conformance/jsx/29.tsx(2,1): error TS1005: '</' expected.
|
||||
tests/cases/conformance/jsx/3.tsx(1,1): error TS1109: Expression expected.
|
||||
@@ -70,7 +68,7 @@ tests/cases/conformance/jsx/3.tsx(1,6): error TS1109: Expression expected.
|
||||
tests/cases/conformance/jsx/3.tsx(1,7): error TS1109: Expression expected.
|
||||
tests/cases/conformance/jsx/30.tsx(1,4): error TS1381: Unexpected token. Did you mean `{'}'}` or `}`?
|
||||
tests/cases/conformance/jsx/31.tsx(1,4): error TS1003: Identifier expected.
|
||||
tests/cases/conformance/jsx/4.tsx(1,6): error TS1005: '{' expected.
|
||||
tests/cases/conformance/jsx/4.tsx(1,6): error TS1145: '{' or JSX element expected.
|
||||
tests/cases/conformance/jsx/5.tsx(1,2): error TS17008: JSX element 'a' has no corresponding closing tag.
|
||||
tests/cases/conformance/jsx/5.tsx(1,5): error TS1005: '</' expected.
|
||||
tests/cases/conformance/jsx/6.tsx(1,6): error TS17002: Expected corresponding JSX closing tag for 'a'.
|
||||
@@ -110,7 +108,7 @@ tests/cases/conformance/jsx/9.tsx(1,10): error TS2304: Cannot find name 'a:b'.
|
||||
==== tests/cases/conformance/jsx/4.tsx (1 errors) ====
|
||||
<a b=d />;
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
!!! error TS1145: '{' or JSX element expected.
|
||||
==== tests/cases/conformance/jsx/5.tsx (2 errors) ====
|
||||
<a>;
|
||||
~
|
||||
@@ -292,21 +290,16 @@ tests/cases/conformance/jsx/9.tsx(1,10): error TS2304: Cannot find name 'a:b'.
|
||||
~
|
||||
!!! error TS17008: JSX element 'a' has no corresponding closing tag.
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
!!! error TS1145: '{' or JSX element expected.
|
||||
|
||||
|
||||
!!! error TS1005: '</' expected.
|
||||
==== tests/cases/conformance/jsx/29.tsx (4 errors) ====
|
||||
==== tests/cases/conformance/jsx/29.tsx (2 errors) ====
|
||||
<a b=<}>;
|
||||
~~~~~~~~~
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
||||
|
||||
|
||||
!!! error TS2657: JSX expressions must have one parent element.
|
||||
|
||||
!!! error TS1005: '</' expected.
|
||||
==== tests/cases/conformance/jsx/30.tsx (1 errors) ====
|
||||
<a>}</a>;
|
||||
|
||||
@@ -150,8 +150,8 @@ var x = <div>one</div> /* intervening comment */, /* intervening comment */ <div
|
||||
<a b>;
|
||||
</>;
|
||||
//// [29.jsx]
|
||||
<a b/>, <>;
|
||||
</>;
|
||||
<a b=<>;
|
||||
</>/>;
|
||||
//// [30.jsx]
|
||||
<a>}</a>;
|
||||
//// [31.jsx]
|
||||
|
||||
@@ -250,9 +250,8 @@ var x = <div>one</div> /* intervening comment */ <div>two</div>;;
|
||||
=== tests/cases/conformance/jsx/29.tsx ===
|
||||
<a b=<}>;
|
||||
><a b=<}>; : any
|
||||
><a b= : any
|
||||
>a : any
|
||||
>b : true
|
||||
>b : any
|
||||
><}>; : any
|
||||
> : any
|
||||
|
||||
|
||||
10
tests/cases/conformance/jsx/jsxAttributeInitializer.ts
Normal file
10
tests/cases/conformance/jsx/jsxAttributeInitializer.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// @jsx: preserve, react
|
||||
// @filename: a.tsx
|
||||
declare var React: any;
|
||||
|
||||
<div>
|
||||
<div attr=<div /> />
|
||||
<div attr=<div>foo</div> />
|
||||
<div attr=<><div>foo</div></> />
|
||||
<div attr= />
|
||||
</div>
|
||||
Reference in New Issue
Block a user