This is a minimal reproduction of a TypeScript compatibility issue.
@vitejs/plugin-react-swc version 4.x uses string literal export names in its type definitions:
export { pluginForCjs as "module.exports" };This syntax was introduced in TypeScript 5.5, but this project uses TypeScript 5.3.3.
Important: The error only occurs when vite.config.ts is included in the TypeScript compilation (via tsconfig.json include array). When TypeScript checks the config file, it also type-checks the imported plugin types, which triggers the incompatibility.
-
Install dependencies:
npm install
-
Run the build:
npm run build
-
You'll see these errors:
node_modules/@vitejs/plugin-react-swc/index.d.ts(58,44): error TS1003: Identifier expected. node_modules/@vitejs/plugin-react-swc/index.d.ts(58,61): error TS1128: Declaration or statement expected.
npm install typescript@^5.5.0npm install @vitejs/plugin-react-swc@^3.9.0Note: This loses Vite 7 compatibility.
checker({
typescript: false, // Temporary workaround
})- Source of the problematic export: https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc/src/index.ts#L321
- TypeScript 5.5 Release Notes (String Literal Export Names)