The --strict mode

TypeScript allows us to use the --strict compilation flag to enable all strict type checking options. Enabling --strict enables --noImplicitAny, --noImplicitThis, --alwaysStrict, --strictPropertyInitialization, and --strictNullChecks:

  • The --strictNullChecks compilation flag enables non-nullable types.
  • The --noImplicitAny flag forces us to explicitly declare the type of a variable when the type inference system is not able to automatically infer the correct type.
  • The --alwaysStrict flag forces the TypeScript parse to use the strict mode.
  • The --noImplicitThis flag forces us to explicitly declare the type of the this operator in functions when the type inference system is not able to automatically infer the correct type.

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.