Skip to content

Commit

Permalink
feat(compiler): Ignore TSInterfaceDeclaration (#30314)
Browse files Browse the repository at this point in the history
## Summary

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.

## How did you test this change?
Added a test.
  • Loading branch information
nikeee authored Jul 11, 2024
1 parent 29552c7 commit 6587fe1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
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 All @@ -1358,7 +1359,6 @@ function lowerStatement(
case "TSEnumDeclaration":
case "TSExportAssignment":
case "TSImportEqualsDeclaration":
case "TSInterfaceDeclaration":
case "TSModuleDeclaration":
case "TSNamespaceExportDeclaration":
case "WithStatement": {
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 6587fe1

Please sign in to comment.