We're going to take a look at TypeScript's strictPropertyInitialization
compiler option and how it helps us prevent using uninitialized class instance properties. If the strictPropertyInitialization
flag is enabled, the type checker verifies that each instance property declared in a class either
undefined
,The strictPropertyInitialization
option is part of the family of compiler options that is enabled automatically when the strict
flag is set. As with all the other strict compiler options, you can set strict
to true and selectively opt out of strict property initialization checks by setting strictPropertyInitialization
to false
.