Type Inference and Strict Mode
Purpose: understand how TypeScript guesses types and how strict mode protects you. Benefit: less typing, more safety.
TypeScript often infers types automatically. ## Inference ```ts let count = 10; // inferred as number let title = "Hi"; // inferred as string ``` You do not always need to write types. ## Strict mode In tsconfig.json: ```json { "compilerOptions": { "strict": true } } ``` Strict mode: - prevents undefined mistakes - enforces better typing - catches more bugs ## Example ```ts let userName: string; userName = "Tom"; // userName = null; // error in strict mode ``` ## Remember - inference reduces noise - strict mode increases safety - both together are powerful