Skip to content

Commit b547906

Browse files
TypeScript Bota-tarasyuk
TypeScript Bot
andauthored
🤖 Pick PR #54425 (fix(54411): Compiled code contain j...) into release-5.1 (#54489)
Co-authored-by: Oleksandr T <[email protected]>
1 parent 7275ded commit b547906

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

‎src/compiler/transformers/jsx.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B
480480
continue;
481481
}
482482
finishObjectLiteralIfNeeded();
483-
expressions.push(attr.expression);
483+
expressions.push(Debug.checkDefined(visitNode(attr.expression, visitor, isExpression)));
484484
continue;
485485
}
486486
properties.push(transformJsxAttributeToObjectLiteralElement(attr));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [a.tsx]
2+
declare const React: any;
3+
4+
const t1 = <div {...<span />} />;
5+
const t2 = <div {...<span className="foo" />} />;
6+
7+
8+
//// [a.js]
9+
const t1 = React.createElement("div", Object.assign({}, React.createElement("span", null)));
10+
const t2 = React.createElement("div", Object.assign({}, React.createElement("span", { className: "foo" })));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== /a.tsx ===
2+
declare const React: any;
3+
>React : Symbol(React, Decl(a.tsx, 0, 13))
4+
5+
const t1 = <div {...<span />} />;
6+
>t1 : Symbol(t1, Decl(a.tsx, 2, 5))
7+
8+
const t2 = <div {...<span className="foo" />} />;
9+
>t2 : Symbol(t2, Decl(a.tsx, 3, 5))
10+
>className : Symbol(className, Decl(a.tsx, 3, 25))
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== /a.tsx ===
2+
declare const React: any;
3+
>React : any
4+
5+
const t1 = <div {...<span />} />;
6+
>t1 : error
7+
><div {...<span />} /> : error
8+
>div : any
9+
><span /> : error
10+
>span : any
11+
12+
const t2 = <div {...<span className="foo" />} />;
13+
>t2 : error
14+
><div {...<span className="foo" />} /> : error
15+
>div : any
16+
><span className="foo" /> : error
17+
>span : any
18+
>className : string
19+
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @jsx: react
2+
// @target: es2015
3+
// @filename: /a.tsx
4+
5+
declare const React: any;
6+
7+
const t1 = <div {...<span />} />;
8+
const t2 = <div {...<span className="foo" />} />;

0 commit comments

Comments
 (0)