Skip to content

Commit

Permalink
Fix a bug with invalid print output when empty array is passed to t.t…
Browse files Browse the repository at this point in the history
…sInterfaceDeclaration

If you pass an empty array as `extends` in `t.tsInterfaceDeclaration` you'll get an invalid code printed

```ts
t.tsInterfaceDeclaration(
  t.identifier('x'),
  undefined,
  [],
  t.tsInterfaceBody([])
)
```

You will get
```ts
interface A extends {}
```

Which is an invalid TS, this PR fixes that
  • Loading branch information
saitonakamura committed Feb 27, 2021
1 parent 265424d commit 92d12b8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/babel-generator/src/generators/typescript.ts
Expand Up @@ -435,7 +435,7 @@ export function TSInterfaceDeclaration(
this.space();
this.print(id, node);
this.print(typeParameters, node);
if (extendz) {
if (extendz?.length) {
this.space();
this.word("extends");
this.space();
Expand Down

0 comments on commit 92d12b8

Please sign in to comment.