File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
66import 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
1013import bsd from '@babel/plugin-syntax-decorators' ;
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments