Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

avoids emitting duplicate import declarations in case of multiple type imports #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down