๐ง๐๐ฝ๐ฒ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐ฆ๐๐ฟ๐ถ๐ฐ๐ ๐ ๐ผ๐ฑ๐ฒ ๐๐๐ถ๐ฑ๐ฒ
TypeScript is relaxed by default. This leads to crashes.
Use strict mode to stop these bugs. Add one line to your tsconfig.json:
"strict": true
This setting turns on 8 safety checks.
It helps you:
- Stop null and undefined errors.
- Define your types clearly.
- Set class properties.
- Handle errors safely.
You fix problems before your code runs. Your app stays stable.
Do not turn on all flags at once for old projects. You will see too many errors.
Follow this path:
- Turn on one flag.
- Fix the errors.
- Commit your changes.
- Move to the next flag.
Add these extra flags for more safety:
- noUncheckedIndexedAccess
- noImplicitOverride
Start every new project with strict mode. It saves time.
Source: https://dev.to/krunalkanojiya/how-to-enable-strict-mode-and-why-you-should-always-use-it-4fc1