1.2 KiB
1.2 KiB
Type Checking
Catch type mismatches at analysis time, not at runtime. Especially valuable in large codebases and across refactors.
Tools by Language
| Language | Tool | Notes |
|---|---|---|
| Python | mypy, pyright |
not built-in; add type hints manually |
| JavaScript/TS | tsc, flow |
TypeScript is the dominant choice |
| Go | built-in | the compiler enforces types |
| C++ | built-in + clang-tidy |
compiler + static analysis |
Python — mypy
mypy src/
Configure in pyproject.toml:
[tool.mypy]
python_version = "3.12"
strict = true
ignore_missing_imports = true
Start with strict = false and tighten incrementally. Add # type: ignore sparingly — only where third-party stubs are missing.
TypeScript — tsc
tsc --noEmit # type-check without emitting JS
tsconfig.json:
{
"compilerOptions": {
"strict": true,
"noEmit": true,
"target": "ES2022"
}
}
Tips
- Type checking and linting are separate concerns — run both
- In Python, annotate function signatures first; body annotations add less value
pyright(Pylance) gives faster feedback in VS Code;mypyis CI-standard