### Related plugins - [x] [plugin-react](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react) - [ ] [plugin-react-swc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc) - [ ] [plugin-react-oxc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-oxc) - [ ] [plugin-rsc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc) ### Describe the bug ```tsx type A = { register: (callback: unknown) => void; }; const a = { register: (callback: unknown) => { console.log(callback); }, }; export function Test() { const funA = async <T,>(arg1: T) => { console.log(arg1) } (a as A).register(funA); return ( <div> <h1>Test</h1> </div> ); } ``` generated code: ```js const a = { register: (callback) => { console.log(callback); } }; export function Test() { const funA = (async (arg1) => { console.log(arg1); })( a ).register(funA); return /* @__PURE__ */ jsxDEV("div", { children: /* @__PURE__ */ jsxDEV("h1", { children: "Test" }, void 0, false, { fileName: "/project/workspace/src/Test.tsx", lineNumber: 36, columnNumber: 7 }, this) }, void 0, false, { fileName: "/project/workspace/src/Test.tsx", lineNumber: 35, columnNumber: 5 }, this); } ``` Error: Uncaught ReferenceError: Cannot access 'funA' before initialization at Test (Test.tsx:14:21) Corrected code should be ```js const a = { register: (callback) => { console.log(callback); } }; export function Test() { const funA = (async (arg1) => { console.log(arg1); }); a.register(funA); return /* @__PURE__ */ jsxDEV("div", { children: /* @__PURE__ */ jsxDEV("h1", { children: "Test" }, void 0, false, { fileName: "/project/workspace/src/Test.tsx", lineNumber: 36, columnNumber: 7 }, this) }, void 0, false, { fileName: "/project/workspace/src/Test.tsx", lineNumber: 35, columnNumber: 5 }, this); } ``` If you add a semicolon at the end of the funA declaration, everything works fine. ```tsx const funA = async <T,>(arg1: T) => { console.log(arg1) }; (a as A).register(funA); ``` ### Reproduction https://codesandbox.io/p/devbox/9hq6fr ### Steps to reproduce _No response_ ### System Info ```shell codsandbox ``` ### Used Package Manager npm ### Logs _No response_ ### Validations - [x] Follow our [Code of Conduct](https://github.com/vitejs/vite-plugin-react/blob/main/CODE_OF_CONDUCT.md) - [x] Read the [Contributing Guidelines](https://github.com/vitejs/vite-plugin-react/blob/main/CONTRIBUTING.md). - [x] Read the [docs](https://vite.dev/guide). - [x] Check that there isn't [already an issue](https://github.com/vitejs/vite-plugin-react/issues) that reports the same bug to avoid creating a duplicate. - [x] Make sure this is a Vite issue and not a framework-specific issue. - [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite-plugin-react/discussions) or join our [Discord Chat Server](https://chat.vite.dev/). - [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.