Validate typescript, but don't build it
You can simply use the option noEmit
in your use case to not emit the output.
{ "compilerOptions": { // ... "noEmit": true, }}
Update for only emitting in test case
I think you can also go for creating the new configuration for testing files to include
only your test code extending from the current one.
tsconfig.test.json
{ "extends": "./tsconfig.json", { "compilerOptions": { "noEmit": true, }, "include": [ "__tests__", // your test file ], }}
package.json
{ "scripts": { "build": "tsc", "test:typeCheck": "tsc --project tsconfig.test.json" }}
- Type check your test folder without emitting:
npm run test:typeCheck
- Run build to emit files normally:
npm build