Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(54411): Compiled code contain jsx code #54425

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" />} />;