user1067920's answer was a good starting point, but I wanted to use vite, but you can't configure the vite tsconfig path. I found a plugin vite-plugin-tsconfig.
My goals:
- I want
tsconfig.json to include tests, so my IDE will show errors for tests - I want my build output to exclude tests
I had one issue with vite-plugin-tsconfig. The plugin works by replacing tsconfig.json with a file you specify in the config:
import tsconfig from "vite-plugin-tsconfig"; ... tsconfig({ filename: "tsconfig.build.json", }),
If I do what user1067920 suggests, "extends": "./tsconfig.json", would be a circular reference.
My solution
I have 4 tsconfig files 😂️:
tsconfig.node.json (unchanged, config used for vite (build process)) tsconfig.json
{ "extends": "./tsconfig.base.json", }
{ "extends": "./tsconfig.base.json", "exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"], }
{ "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, "noImplicitAny": true, "noUncheckedIndexedAccess": true, /* shadcn/ui as per https://ui.shadcn.com/docs/installation/vite */ "baseUrl": ".", "paths": { "@/*": ["./src/*"] } }, "exclude": ["node_modules"], "include": ["src"], "references": [{ "path": "./tsconfig.node.json" }] }