Skip to content

Commit

Permalink
🤖 Pick PR #54425 (fix(54411): Compiled code contain j...) into releas…
Browse files Browse the repository at this point in the history
…e-5.1 (#54489)

Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
  • Loading branch information
TypeScript Bot and a-tarasyuk authored Jun 1, 2023
1 parent 7275ded commit b547906
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/transformers/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
10 changes: 10 additions & 0 deletions tests/baselines/reference/jsxSpreadTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//// [a.tsx]
declare const React: any;

const t1 = <div {...<span />} />;
const t2 = <div {...<span className="foo" />} />;


//// [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" })));
11 changes: 11 additions & 0 deletions tests/baselines/reference/jsxSpreadTag.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
=== /a.tsx ===
declare const React: any;
>React : Symbol(React, Decl(a.tsx, 0, 13))

const t1 = <div {...<span />} />;
>t1 : Symbol(t1, Decl(a.tsx, 2, 5))

const t2 = <div {...<span className="foo" />} />;
>t2 : Symbol(t2, Decl(a.tsx, 3, 5))
>className : Symbol(className, Decl(a.tsx, 3, 25))

19 changes: 19 additions & 0 deletions tests/baselines/reference/jsxSpreadTag.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
=== /a.tsx ===
declare const React: any;
>React : any

const t1 = <div {...<span />} />;
>t1 : error
><div {...<span />} /> : error
>div : any
><span /> : error
>span : any

const t2 = <div {...<span className="foo" />} />;
>t2 : error
><div {...<span className="foo" />} /> : error
>div : any
><span className="foo" /> : error
>span : any
>className : string

8 changes: 8 additions & 0 deletions tests/cases/compiler/jsxSpreadTag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @jsx: react
// @target: es2015
// @filename: /a.tsx

declare const React: any;

const t1 = <div {...<span />} />;
const t2 = <div {...<span className="foo" />} />;

0 comments on commit b547906

Please sign in to comment.