From b547906da5c134ce2c485ee51c6119f88649ede1 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Thu, 1 Jun 2023 12:57:22 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Pick=20PR=20#54425=20(fix(54411)?= =?UTF-8?q?:=20Compiled=20code=20contain=20j...)=20into=20release-5.1=20(#?= =?UTF-8?q?54489)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Oleksandr T --- src/compiler/transformers/jsx.ts | 2 +- tests/baselines/reference/jsxSpreadTag.js | 10 ++++++++++ .../baselines/reference/jsxSpreadTag.symbols | 11 +++++++++++ tests/baselines/reference/jsxSpreadTag.types | 19 +++++++++++++++++++ tests/cases/compiler/jsxSpreadTag.ts | 8 ++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/jsxSpreadTag.js create mode 100644 tests/baselines/reference/jsxSpreadTag.symbols create mode 100644 tests/baselines/reference/jsxSpreadTag.types create mode 100644 tests/cases/compiler/jsxSpreadTag.ts diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 52fa0bc564f74..3447a2249524c 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -480,7 +480,7 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B continue; } finishObjectLiteralIfNeeded(); - expressions.push(attr.expression); + expressions.push(Debug.checkDefined(visitNode(attr.expression, visitor, isExpression))); continue; } properties.push(transformJsxAttributeToObjectLiteralElement(attr)); diff --git a/tests/baselines/reference/jsxSpreadTag.js b/tests/baselines/reference/jsxSpreadTag.js new file mode 100644 index 0000000000000..2fbf28534213e --- /dev/null +++ b/tests/baselines/reference/jsxSpreadTag.js @@ -0,0 +1,10 @@ +//// [a.tsx] +declare const React: any; + +const t1 =
} />; +const t2 =
} />; + + +//// [a.js] +const t1 = React.createElement("div", Object.assign({}, React.createElement("span", null))); +const t2 = React.createElement("div", Object.assign({}, React.createElement("span", { className: "foo" }))); diff --git a/tests/baselines/reference/jsxSpreadTag.symbols b/tests/baselines/reference/jsxSpreadTag.symbols new file mode 100644 index 0000000000000..93057b1ff6568 --- /dev/null +++ b/tests/baselines/reference/jsxSpreadTag.symbols @@ -0,0 +1,11 @@ +=== /a.tsx === +declare const React: any; +>React : Symbol(React, Decl(a.tsx, 0, 13)) + +const t1 =
} />; +>t1 : Symbol(t1, Decl(a.tsx, 2, 5)) + +const t2 =
} />; +>t2 : Symbol(t2, Decl(a.tsx, 3, 5)) +>className : Symbol(className, Decl(a.tsx, 3, 25)) + diff --git a/tests/baselines/reference/jsxSpreadTag.types b/tests/baselines/reference/jsxSpreadTag.types new file mode 100644 index 0000000000000..c3647817a71d9 --- /dev/null +++ b/tests/baselines/reference/jsxSpreadTag.types @@ -0,0 +1,19 @@ +=== /a.tsx === +declare const React: any; +>React : any + +const t1 =
} />; +>t1 : error +>
} /> : error +>div : any +> : error +>span : any + +const t2 =
} />; +>t2 : error +>
} /> : error +>div : any +> : error +>span : any +>className : string + diff --git a/tests/cases/compiler/jsxSpreadTag.ts b/tests/cases/compiler/jsxSpreadTag.ts new file mode 100644 index 0000000000000..d572d05783039 --- /dev/null +++ b/tests/cases/compiler/jsxSpreadTag.ts @@ -0,0 +1,8 @@ +// @jsx: react +// @target: es2015 +// @filename: /a.tsx + +declare const React: any; + +const t1 =
} />; +const t2 =
} />;