I have a folder called "__ tests __".
I want it to be validated as typescript, but I don't want to build that folder. ( I don't want it to go to dist folder )
How would I do that?
It's like I have to include it, but not really...
My ts.config.json:
{
    "compilerOptions": {
        "module": "CommonJS",
        "target": "ES2017",
        "noImplicitAny": true,
        "preserveConstEnums": true,
        "outDir": "./dist",
        "sourceMap": true,
        "esModuleInterop": true,
        "resolveJsonModule": true
    },
    "include": ["src/**/*", "src/**/*.json", "__tests__/**/*"],
    "exclude": ["node_modules", "**/*.spec.ts"]
}
                You can simply use the option noEmit in your use case to not emit the output.
{
  "compilerOptions": {
    // ...
    "noEmit": true,
  }
}
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"
  }
}
npm run test:typeCheck
npm build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With