Skip to content

Commit

Permalink
Ignore TSInterfaceDeclaration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikeee committed Jul 11, 2024
1 parent 29552c7 commit 0becaba
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,7 @@ function lowerStatement(
return;
}
case "TypeAlias":
case "TSInterfaceDeclaration":
case "TSTypeAliasDeclaration": {
// We do not preserve type annotations/syntax through transformation
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

## Input

```javascript
function Foo() {
type X = number;
interface Bar {
baz: number;
}
return 0;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
};

```

## Code

```javascript
function Foo() {
return 0;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
};

```
### Eval output
(kind: ok) 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function Foo() {
type X = number;
interface Bar {
baz: number;
}
return 0;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
};

0 comments on commit 0becaba

Please sign in to comment.