Skip to content

Commit 0becaba

Browse files
committed
Ignore TSInterfaceDeclaration
The following was not supported: ```ts function A() { interface C { id: number; } return 0; } ``` Message: > Todo: (BuildHIR::lowerStatement) Handle TSInterfaceDeclaration statements (2:4) Playground: https://playground.react.dev/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEAggBQCURwAOsUXpjgjGgIaJEDC1dR-DACbIimKAFsARiwDcfIgF95MBDljEADHMwKQCoA This PR fixes that.
1 parent 29552c7 commit 0becaba

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,7 @@ function lowerStatement(
13321332
return;
13331333
}
13341334
case "TypeAlias":
1335+
case "TSInterfaceDeclaration":
13351336
case "TSTypeAliasDeclaration": {
13361337
// We do not preserve type annotations/syntax through transformation
13371338
return;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
## Input
3+
4+
```javascript
5+
function Foo() {
6+
type X = number;
7+
interface Bar {
8+
baz: number;
9+
}
10+
return 0;
11+
}
12+
13+
export const FIXTURE_ENTRYPOINT = {
14+
fn: Foo,
15+
params: [],
16+
};
17+
18+
```
19+
20+
## Code
21+
22+
```javascript
23+
function Foo() {
24+
return 0;
25+
}
26+
27+
export const FIXTURE_ENTRYPOINT = {
28+
fn: Foo,
29+
params: [],
30+
};
31+
32+
```
33+
34+
### Eval output
35+
(kind: ok) 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function Foo() {
2+
type X = number;
3+
interface Bar {
4+
baz: number;
5+
}
6+
return 0;
7+
}
8+
9+
export const FIXTURE_ENTRYPOINT = {
10+
fn: Foo,
11+
params: [],
12+
};

0 commit comments

Comments
 (0)