Closed ak-adversus closed 3 months ago
Start a new pull request in StackBlitz Codeflow.
Looks like some react babel transforms is affecting it:
I'll move this to the plugin-react repo for now, but it could be other dependencies affecting this.
Oh it looks like someone already opened an issue for this https://github.com/vitejs/vite-plugin-react/issues/348. I'll close this in favour of that then.
Describe the bug
Vite breaks when trying to run the pre-transform step on the following code:
This throws the following error
From the error log, it seems that at some point, the parentheses wrapping the object have been removed, which causes the broken syntax.
I have tested this on the vanilla-ts and react-ts templates, but it's only broken in the react-ts template, i don't know about any other framework.
Reproduction
https://stackblitz.com/edit/vitejs-vite-fdiygv
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
Full error log!
```shell 11.15.08 [vite] Internal server error: Transform failed with 1 error: C:/Users/name/project/src/main.tsx:6:2: ERROR: Expected ";" but found "as" Plugin: vite:esbuild File: C:/Users/name/project/src/main.tsx:6:1 Expected ";" but found "as" 4 | const brokenFunction = () => { 5 | foo: 'bar' 6 | } as {foo: 'bar';}; | ^ 7 | 8 | const Broken = () => { at failureErrorWithLog (C:\Users\name\project\node_modules\esbuild\lib\main.js:1651:15) at C:\Users\name\project\node_modules\esbuild\lib\main.js:849:29 at responseCallbacks.Validations