Skip to content

Commit

Permalink
fix: add parens
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jun 22, 2022
1 parent fcbd54f commit ddf5b28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/core/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const transform = async (
s.overwrite(
value.start!,
value.end!,
s.slice(result.start!, result.end!)
`(${s.slice(result.start!, result.end!)})`
)
newAST = result
}
Expand Down
12 changes: 8 additions & 4 deletions tests/remove-wrapper-function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ test('remove wrapper function', async () => {
}
})
console.log(mutable({} as const))
console.log(() => mutable({} as const))
`
const options: Pick<OptionsResolved, 'parserOptions' | 'transformer'> = {
transformer: [RemoveWrapperFunction(['defineComponent', 'mutable'])],
transformer: [
RemoveWrapperFunction(['defineComponent', 'mutable', 'definePropType']),
],
parserOptions: {},
}
const code = (await transform(source, 'foo.ts', options))?.code
expect(code).toMatchInlineSnapshot(`
"const comp = {
"const comp = ({
render() {
return []
}
}
console.log({} as const)
})
console.log(({} as const))
console.log(() => ({} as const))
"
`)
})

0 comments on commit ddf5b28

Please sign in to comment.