Add the package to your "devDependencies"
:
npm install --save-dev @tsconfig/vite-react
yarn add --dev @tsconfig/vite-react
Add to your tsconfig.json
:
"extends": "@tsconfig/vite-react/tsconfig.json"
The tsconfig.json
:
{
"$schema": "https://json.schemastore.org/tsconfig",
"_version": "3.0.0",
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
}
}
You can find the code here.