diff --git a/packages/babel-plugin-transform-flow-strip-types/src/index.js b/packages/babel-plugin-transform-flow-strip-types/src/index.js index c64abb9a52fe..cae92de95b28 100644 --- a/packages/babel-plugin-transform-flow-strip-types/src/index.js +++ b/packages/babel-plugin-transform-flow-strip-types/src/index.js @@ -57,7 +57,14 @@ export default function ({ types: t }) { node = node.expression; } while (t.isTypeCastExpression(node)); path.replaceWith(node); - } + }, + + ImportSpecifier(path) { + const { node } = path; + if (node.importKind !== null) { + path.remove(); + } + }, } }; } diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/actual.js b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/actual.js index 36cfd7f425e9..f602db2cbc4d 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/actual.js +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/actual.js @@ -97,5 +97,9 @@ import type2, { foo3 } from "bar"; import type * as namespace from "bar"; export type { foo }; export type { foo2 } from "bar"; +import {type T} from "foo"; +import {type T2, V1} from "foo"; +import {typeof V2} from "foo"; +import {typeof V3, V4} from "foo"; export interface foo5 { p: number } export interface foo6 { p: T } diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/expected.js b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/expected.js index 62bf507aaecf..a6c982a6a32f 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/expected.js +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/expected.js @@ -90,3 +90,8 @@ var identity; import type from "foo"; import type2, { foo3 } from "bar"; + +import "foo"; +import { V1 } from "foo"; +import "foo"; +import { V4 } from "foo";