Compiler flags shape your safety net. `strict` bundles many checks: • noImplicitAny • strictNullChecks • strictBindCallApply • strictFunctionTypes • strictPropertyInitialization Other helpful flags: noUncheckedIndexedAccess, exactOptionalPropertyTypes, useUnknownInCatchVariables, noEmitOnError.
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true
}// strictNullChecks example
function greet(name?: string) {
// name: string | undefined
if (!name) return;
console.log(name.toUpperCase());
}
// noUncheckedIndexedAccess
const list: string[] = [];
const first: string | undefined = list[0]; // must handle undefinedUnderstanding tsconfig & Strict Mode is fundamental to mastering TypeScript. Practice with the examples above and experiment with variations to solidify your knowledge.