From 8bd104f3c4e2683479a1d263c00ba648fa642c75 Mon Sep 17 00:00:00 2001 From: Michael Bashurov Date: Sat, 27 Feb 2021 12:12:55 +0200 Subject: [PATCH] Fix a bug with invalid print output when empty array is passed to t.tsInterfaceDeclaration 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 --- packages/babel-generator/src/generators/typescript.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-generator/src/generators/typescript.ts b/packages/babel-generator/src/generators/typescript.ts index 14375b0beac5..f0284d824c9d 100644 --- a/packages/babel-generator/src/generators/typescript.ts +++ b/packages/babel-generator/src/generators/typescript.ts @@ -435,7 +435,7 @@ export function TSInterfaceDeclaration( this.space(); this.print(id, node); this.print(typeParameters, node); - if (extendz) { + if (extendz?.length > 0) { this.space(); this.word("extends"); this.space();