Skip to content

Commit 694283d

Browse files
authored
Merge pull request #5 from Windvis/only-remove-type-imports
Only remove type imports
2 parents 532e210 + fdf4822 commit 694283d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { format, Options as PrettierOptions } from 'prettier';
44

55
// @ts-expect-error We're only importing so we can create a config item, so we don't care about types
66
import bts from '@babel/plugin-transform-typescript';
7-
const babelTsTransform = createConfigItem(bts);
7+
const babelTsTransform = createConfigItem([bts, { onlyRemoveTypeImports: true }]);
88

99
// @ts-expect-error We're only importing so we can create a config item, so we don't care about types
1010
import bsd from '@babel/plugin-syntax-decorators';

test/index.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ export default class Foo extends Component {
123123
this.prop2 = prop2;
124124
}
125125
}
126+
`;
127+
expect(await removeTypes(contents)).toEqual(expected);
128+
});
129+
130+
it("doesn't remove unused imports", async () => {
131+
const contents = `import Foo from 'foo';
132+
133+
export default class Baz {}
134+
`;
135+
136+
const expected = `import Foo from 'foo';
137+
138+
export default class Baz {}
126139
`;
127140
expect(await removeTypes(contents)).toEqual(expected);
128141
});

0 commit comments

Comments
 (0)