I have a question for you, have you enabled the strict flag in your TS Config Compiler Option? If not, why and would you consider enabling it in the future?
This single option enables stricter type checks of your Typescript codebase for much better Type safety. These options can be enabled and disabled for each individual option, but with the strict compiler option, you toggle all of them with a single compiler flag.
Another point to note about the strict compiler option is that future versions of Typescript may introduce stricter checking, and by using strict , you will be opting for those as well. Keep that in mind when upgrading to newer versions of Typescript.
alwaysStrict - This ensures that your TS files are parsed in the ECMAScript strict mode, and typescript will emit “use strict” for each source file after transpilation.
strictNullChecks - Ensures that null and undefined are treated as their own types instead of being effectively ignored. This forces you to handle any null or undefined values before being used.
strictBindCallApply - It ensures that built-in methods of functions call, bind, and apply are called with the correct arguments for the underlying function.
strictFunctionTypes - Ensures that function parameters are checked more strictly.
strictPropertyInitialization - Ensure that class properties are set in the constructor.
noImplicitAny - When false, typescript will implicitly infer some types as any when no annotations are present. Turning on this ensures you Typescript will implicitly infer a type as any which can compromise type safety as the any type can spill over to other areas of code quite easily.
noImplicitThis - Throws an error when this expression is inferred as the any type.
useUnknownInCatchVariable - Instead of using any for the type of an error inside the catch statement, Typescript will use unknown, allowing for a more comprehensive error handling.
What do you think about the strict compiler option?
Leave a comment
0 subscriptions will be displayed on your profile (edit)
Skip for now
For your security, we need to re-authenticate you.
Click the link we sent to , or click here to sign in.