Advanced TypeScript
Q96 / 100

What does the "--strictPropertyInitialization" flag enforce for class properties?

Correct! Well done.

Incorrect.

The correct answer is A) Class properties must be initialized in the constructor or have a definite assignment assertion / default value, otherwise the type must include undefined

A

Correct Answer

Class properties must be initialized in the constructor or have a definite assignment assertion / default value, otherwise the type must include undefined

Explanation

strictPropertyInitialization ensures that every declared instance property is either assigned in the constructor, given a default, marked with "!" (definite assignment assertion), or its type explicitly allows undefined.

Progress
96/100