TypeScript Developer interview question · Most asked

Which `tsconfig` strictness options matter and what do they catch?

Summary

strict: true enables strictNullChecks, noImplicitAny, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization, useUnknownInCatchVariables, alwaysStrict and noImplicitThis. Extra recommended flags: noUncheckedIndexedAccess, exactOptionalPropertyTypes, noImplicitOverride and noFallthroughCasesInSwitch.

Longer Answer

strictNullChecks is the most valuable: it forces handling null/undefined. noUncheckedIndexedAccess makes arr[i] and record[key] return T | undefined, catching out-of-bounds bugs. When migrating a large JS codebase, enable strict flags incrementally.

Key Points

  • strict: true bundle
  • strictNullChecks is the biggest win
  • noUncheckedIndexedAccess for index safety
  • Adopt incrementally in migrations

More most-asked TypeScript Developer questions

← All TypeScript Developer questions