add knowledge

This commit is contained in:
Jev Kuznetsov
2026-04-23 12:06:00 +02:00
parent 82985f1976
commit 846eca59d2
10 changed files with 577 additions and 6 deletions
+53
View File
@@ -0,0 +1,53 @@
# 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`
```bash
mypy src/
```
Configure in `pyproject.toml`:
```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`
```bash
tsc --noEmit # type-check without emitting JS
```
`tsconfig.json`:
```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; `mypy` is CI-standard