Strict mode is a set of compiler checks that catch null access, implicit any and unsafe class behaviour. The migration is usually incremental: turn on the flags, measure the errors and fix the highest-risk modules first.
Key takeaways
strictbundles several checks, includingstrictNullChecksandnoImplicitAny.noUncheckedIndexedAccessmakes array and record access returnT | undefined.exactOptionalPropertyTypesdistinguishes a missing property from a property set toundefined.- Prefer the simplest boundary that keeps data and authorisation on the server.
What matters in practice
noImplicitOverridecatches methods that accidentally override a base class member.- Strict mode is most valuable at boundaries: API data, forms, environment variables and persistence.
How to implement it
- Record the baseline. Run
tsc --noEmitwith the new flags and count errors by folder. - Start with shared types. Fix the types that leak into many files first.
- Add runtime validation. Do not replace a runtime check with a type assertion.
- Fix null handling. Use early returns, guards and explicit error states.
- Enable flags one at a time. Keep the build green and merge in small batches.
- Add a CI gate. Prevent new errors from entering the codebase.
A working example
// tsconfig.json
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"exactOptionalPropertyTypes": true
}
}
Production checklist
| Area | Check |
|---|---|
| Baseline | Error count by package and owner |
| Boundaries | Runtime schemas for external data |
| Null handling | Early returns and exhaustive checks |
| Generics | Constraints that preserve inference |
| CI | tsc --noEmit on every pull request |
| Documentation | A short note on the flags and the migration order |
Common mistakes
- Turning on all flags and leaving hundreds of errors open.
- Using non-null assertions to silence
strictNullChecks. - Casting an API response instead of validating it.
- Enabling strict mode only in the editor and not in CI.
When this is the wrong tool
Every tool has a boundary. If the team is small, the use case is simple and the operational cost is high, a simpler stack may be better. The right choice is the one you can debug, secure and hand over without the original author.
Rollout plan
- Prove one slice. Use TypeScript strict mode for one real route or feature, not the whole product.
- Set the boundary. Write down what stays on the server, what runs on the client and how data crosses the boundary.
- Add the safety net. Types, validation, tests and error handling around the new slice.
- Measure. Check bundle size, latency, error rate and the developer experience before expanding.
- Document and hand over. Record the pattern, the pitfalls and the version constraints.
Testing strategy
| Layer | What to test | Why |
|---|---|---|
| Types | Strict compile and no unjustified any | Catches contract drift early |
| Unit | Pure logic, validation and state transitions | Fast feedback |
| Integration | API, database and auth boundaries | Most production failures live here |
| End-to-end | The critical user journey | Proves the wiring |
| Operations | Logs, errors, retries and rollback | A release is not finished at deploy |
Operational checklist
- Pin the runtime and dependency versions; test upgrades in a branch.
- Keep secrets on the server and validate every external payload.
- Add structured logs with a request ID, but never log tokens or personal data.
- Set a performance or bundle budget and check it in CI.
- Write a short runbook for the most likely failure.
Frequently asked questions
It should not change runtime output, but it can expose assumptions that were already wrong. Fix the code, not the compiler.
A small app can take a day; a large app can take weeks. Measure the error count and migrate by module.
checkJs and JSDoc can catch some issues, but the full benefit comes from TypeScript files. Migrate the highest-risk modules first.
Install the official types, or write a narrow declaration for the part you use. Avoid ambient any declarations that hide the real API.
Sources and further reading
- TypeScript strict compiler options (typescriptlang.org)
- TypeScript handbook (typescriptlang.org)
Related reading
Need an implementation review?
Send the repository or the design. I will review the boundary, the failure modes and the parts that will be expensive to change later.
How to cite this guide: Nur Hossain Repon, “TypeScript strict mode: complete developer guide (2026)”, Nhrepon Portfolio, reviewed October 2026, https://nhrepon.com/posts/typescript-strict-mode-complete-developer-guide-2026.





Comments
No comments yet.