Skip to content

Commit eb6af06

Browse files
Merge pull request #7 from TSenter/main
feat: Allow declared fields
2 parents fc3be01 + 7c6807e commit eb6af06

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ 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, { onlyRemoveTypeImports: true }]);
7+
const babelTsTransform = createConfigItem([
8+
bts,
9+
{ allowDeclareFields: true, onlyRemoveTypeImports: true },
10+
]);
811

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

test/index.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,32 @@ export default class Baz {}
139139
`;
140140
expect(await removeTypes(contents)).toEqual(expected);
141141
});
142+
143+
it('removes declared properties', async () => {
144+
const contents = `export default class Baz {
145+
declare foo: string;
146+
}
147+
`;
148+
149+
const expected = `export default class Baz {}
150+
`;
151+
152+
expect(await removeTypes(contents)).toEqual(expected);
153+
});
154+
155+
it('keeps declared properties with decorators', async () => {
156+
const contents = `export default class Baz {
157+
@service
158+
declare foo: string;
159+
}
160+
`;
161+
162+
const expected = `export default class Baz {
163+
@service
164+
foo;
165+
}
166+
`;
167+
168+
expect(await removeTypes(contents)).toEqual(expected);
169+
});
142170
});

0 commit comments

Comments
 (0)