bdebon / choiceof.dev

Developers have to cope with pretty hard choices every day. This is a collection of the most complex and funny choices. What will be yours?
https://choiceof.dev
GNU General Public License v3.0
473 stars 93 forks source link

Bug: strict mode does not show any error when nx serve #53

Open bdebon opened 2 years ago

bdebon commented 2 years ago

Expected behavior: When strict mode enabled, the compilation should yell something it there is a strict error.

Current behavior: Compilation during nx serve does not say anything. It does say something when you build with nx build.

I have no clue why it behaves like this, it's the first time I have such a thing in a Nx project. I could find any quick answer to that...

booleans-oss commented 2 years ago

Strict mode is only related to Typescript, hence erroring with type issues. And when using Typescript, static type-checking only happens once you build/compile your project (no runtime type-checking mainly because it wasn't designed to do so).

With Next.js, it is the same behavior. When you start your app (next start or in the case of choiceof.dev, nx serve), it only starts the app but doesn't compile it. In fact, when starting your Next.js app, all types are removed so Typescript has no idea if something. Runtime errors would only be syntax errors, or React errors. It is only at build-time (next build) that Next.js has a step for type-checking.

I think this is an issue for you since you went from strict:false to strict:true, so new type errors can be anywhere in the existing project. But now since you've fixed the project, ESLint and TSServer in your IDE will do a sufficient job of showing errors but only when you open the file.