From 28ea5adcdd1f6e9598271d0491be198b427b69ab Mon Sep 17 00:00:00 2001 From: Alessandro Diez Date: Tue, 18 May 2021 12:04:53 +0200 Subject: [PATCH] avoids emitting duplicate import declarations in case of multiple type imports fixes #281 --- src/transform.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/transform.ts b/src/transform.ts index c6b8712..1651de0 100644 --- a/src/transform.ts +++ b/src/transform.ts @@ -655,6 +655,10 @@ export const transform = { if (replacementNode != null) { if (Array.isArray(replacementNode)) { + // Fixes https://github.com/Khan/flow-to-ts/issues/281 + // Imports with multiple types will be moved to their own node leaving the source node without specifiers; + // do not print it as it will result in an import declaration without specifiers + replacementNode = replacementNode.filter((x) => x.specifiers.length); path.replaceWithMultiple(replacementNode); } else { path.replaceWith(replacementNode);