File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,19 @@ console.log(y);
1818 ` ) ;
1919 } ) ;
2020
21+ it ( 'should remove unused variables in function declaration' , async ( ) => {
22+ const result = await applyTransform (
23+ transformer ,
24+ `export function hello() { var a = 1; debugger; }` ,
25+ ) ;
26+
27+ expect ( result ) . toMatchInlineSnapshot ( `
28+ "export function hello() {
29+ debugger;
30+ }"
31+ ` ) ;
32+ } ) ;
33+
2134 it ( 'should not remove used variables' , async ( ) => {
2235 const result = await applyTransform (
2336 transformer ,
Original file line number Diff line number Diff line change @@ -27,15 +27,20 @@ function main() {
2727
2828 {
2929 const targetFilePath = path . join ( __dirname , 'remove-unused-vars-test2.ts' ) ;
30- writeFileSync ( targetFilePath , `function hello() { var a = 1; debugger; }` ) ;
30+ writeFileSync (
31+ targetFilePath ,
32+ `export function hello() { var a = 1; debugger; }` ,
33+ ) ;
3134
3235 execSync (
3336 `npx --yes @hypermod/cli@latest --packages javascript#remove-unused-vars --experimental-loader ${ targetFilePath } ` ,
3437 { stdio : 'inherit' } ,
3538 ) ;
3639
3740 const targetFileOutput = readFileSync ( targetFilePath , 'utf-8' ) ;
38- const expectedFileOutput = `function hello() { debugger; }` ;
41+ const expectedFileOutput = `export function hello() {
42+ debugger;
43+ }` ;
3944
4045 if ( targetFileOutput !== expectedFileOutput ) {
4146 throw new Error (
You can’t perform that action at this time.
0 commit comments