diff --git a/src/index.ts b/src/index.ts index 690657e..9580a7f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import { format, Options as PrettierOptions } from 'prettier'; // @ts-expect-error We're only importing so we can create a config item, so we don't care about types import bts from '@babel/plugin-transform-typescript'; -const babelTsTransform = createConfigItem(bts); +const babelTsTransform = createConfigItem([bts, { onlyRemoveTypeImports: true }]); // @ts-expect-error We're only importing so we can create a config item, so we don't care about types import bsd from '@babel/plugin-syntax-decorators'; diff --git a/test/index.test.ts b/test/index.test.ts index b56feee..58e9380 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -123,6 +123,19 @@ export default class Foo extends Component { this.prop2 = prop2; } } +`; + expect(await removeTypes(contents)).toEqual(expected); + }); + + it("doesn't remove unused imports", async () => { + const contents = `import Foo from 'foo'; + +export default class Baz {} +`; + + const expected = `import Foo from 'foo'; + +export default class Baz {} `; expect(await removeTypes(contents)).toEqual(expected); });