In Angular, we strongly believe in consistency and best practices. For example, we adopted TypeScript in its early days because we wanted all developers using the framework to take advantage of compile-time type checking. This way, we enabled an excellent development experience for everyone with better editor support, allowing people to ship apps with fewer issues.
In Angular v10 we announced a strict opt-in mode that allows us to perform more build-time optimizations and help you deliver faster apps with fewer defects. This mode is still only an opt-in because it comes with its trade-offs — stricter type checking and extra configuration. We want to hear from you which of these trade-offs will make you more productive and allow you to deliver better apps.
To opt into the strict mode, you need to create a new Angular CLI app, specifying the --strict
flag:
ng new my-app --strict
The command above will generate a workspace with the following settings enabled on top of the defaults:
strict
, forceConsistentCasingInFileNames
, noImplicitReturns
, noFallthroughCasesInSwitch
strictTemplates
and strictInjectionParameters
no-any
TSLint rule to prevent declarations of type any
Let us look at each one of these in detail.
#web-development #angular #typescript #javascript