mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
fix(54411): Compiled code contain jsx code (#54425)
This commit is contained in:
parent
23d48364e4
commit
b03926ea78
@ -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));
|
||||
|
||||
10
tests/baselines/reference/jsxSpreadTag.js
Normal file
10
tests/baselines/reference/jsxSpreadTag.js
Normal file
@ -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
tests/baselines/reference/jsxSpreadTag.symbols
Normal file
11
tests/baselines/reference/jsxSpreadTag.symbols
Normal file
@ -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
tests/baselines/reference/jsxSpreadTag.types
Normal file
19
tests/baselines/reference/jsxSpreadTag.types
Normal file
@ -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
tests/cases/compiler/jsxSpreadTag.ts
Normal file
8
tests/cases/compiler/jsxSpreadTag.ts
Normal file
@ -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" />} />;
|
||||
Loading…
x
Reference in New Issue
Block a user