In my turborepo monorepo, the structure looks like this:
apps
|- app1
|- app2
packages
|- lib
| .... some files
|- tsconfig.json
|- package.json
Within the lib
directory, I intentionally included a file with an obvious error. The editor correctly reports the error while editing:
const a: String = 23;
console.log(a);
I am also importing this erroneous file in one of my apps. Surprisingly, when I attempt to build the project using npm run build
, it builds without any errors despite not having set an option to ignore errors.
The interesting part is that the build only fails if I place this intentionally flawed file within one of the apps. In that case, it does identify the error and halts the build process.
Here is the tsconfig configuration for the lib
:
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"noEmit": true,
"incremental": true,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"moduleResolution": "node"
},
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}
Interestingly, I have a very similar tsconfig file in my apps as well:
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"noEmit": true,
"incremental": true,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"moduleResolution": "node"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}