From 4bd67bdde0651c4b5eed6b27c35f6f2bc5df44ad Mon Sep 17 00:00:00 2001 From: tsr07843 Date: Thu, 9 Oct 2025 15:26:38 -0400 Subject: [PATCH 1/2] feat: Allow declared fields --- src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 9580a7f..39c9f10 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,10 @@ 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, { onlyRemoveTypeImports: true }]); +const babelTsTransform = createConfigItem([ + bts, + { allowDeclareFields: true, 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'; From 7c6807edccab367f28ca817cae8b684d248e1234 Mon Sep 17 00:00:00 2001 From: tsr07843 Date: Thu, 9 Oct 2025 15:26:45 -0400 Subject: [PATCH 2/2] chore: Add tests --- test/index.test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/index.test.ts b/test/index.test.ts index 58e9380..312093a 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -139,4 +139,32 @@ export default class Baz {} `; expect(await removeTypes(contents)).toEqual(expected); }); + + it('removes declared properties', async () => { + const contents = `export default class Baz { + declare foo: string; +} +`; + + const expected = `export default class Baz {} +`; + + expect(await removeTypes(contents)).toEqual(expected); + }); + + it('keeps declared properties with decorators', async () => { + const contents = `export default class Baz { + @service + declare foo: string; +} +`; + + const expected = `export default class Baz { + @service + foo; +} +`; + + expect(await removeTypes(contents)).toEqual(expected); + }); });