I've been in the process of converting a Next JS project from JavaScript to TypeScript. Intentionally making mistakes to test the type checking, for example:
export class Knot {
position: Vector2;
locked: number;
deletable: boolean;
isLast: boolean;
isActive: boolean;
handles: { in: Vector2, out: Vector2 };
constructor(position: Vector2, locked: boolean, isLast: boolean, isActive: boolean = false, deletable: boolean = true) {
this.position = position
this.locked = locked //0 = not locked, 1 = y is locked, 2 = x is locked, 3 = z is locked
this.deletable = deletable
this.isLast = isLast
this.isActive = isActive
}
}
Noticing that the locked
variable is being assigned a boolean value when it is declared as a number. My editor shows an error, but surprisingly, it doesn't throw any errors when I run npm run build
.
I've double-checked, and I don't have the ignoreBuildErrors: true
setting configured anywhere within the project.
The project is using turborepo. I'm unsure if this setup affects the type checking behavior.
Here is a snippet from my tsconfig
:
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Next.js",
"extends": "./base.json",
"compilerOptions": {
"target": "es5",
"noImplicitAny": false,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strictNullChecks": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["src", "next-env.d.ts"],
"exclude": ["node_modules"]
}