Skip to content

Commit f92e3a1

Browse files
Update fixture
use id<string> as default value and call inside the body
1 parent 78a3b69 commit f92e3a1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ts-instantiation-default-param.expect.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ function id<T>(x: T): T {
66
return x;
77
}
88

9-
export function Component<T = string>({value = id<string>('hi')}: {value?: T}) {
9+
export function Component<T = string>({fn = id<string>}: {fn?: (x: T) => T}) {
10+
const value = fn('hi');
1011
return <div>{String(value)}</div>;
1112
}
1213

@@ -27,11 +28,12 @@ function id(x) {
2728

2829
export function Component(t0) {
2930
const $ = _c(4);
30-
const { value: t1 } = t0;
31+
const { fn: t1 } = t0;
32+
const fn = t1 === undefined ? id : t1;
3133
let t2;
32-
if ($[0] !== t1) {
33-
t2 = t1 === undefined ? id("hi") : t1;
34-
$[0] = t1;
34+
if ($[0] !== fn) {
35+
t2 = fn("hi");
36+
$[0] = fn;
3537
$[1] = t2;
3638
} else {
3739
t2 = $[1];

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ts-instantiation-default-param.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ function id<T>(x: T): T {
22
return x;
33
}
44

5-
export function Component<T = string>({value = id<string>('hi')}: {value?: T}) {
5+
export function Component<T = string>({fn = id<string>}: {fn?: (x: T) => T}) {
6+
const value = fn('hi');
67
return <div>{String(value)}</div>;
78
}
89

0 commit comments

Comments
 (0)