Skip to content

Commit

Permalink
Merge pull request #5 from Windvis/only-remove-type-imports
Browse files Browse the repository at this point in the history
Only remove type imports
  • Loading branch information
mansona authored Jan 29, 2025
2 parents 532e210 + fdf4822 commit 694283d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
13 changes: 13 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 694283d

Please sign in to comment.