Files
devops-guide/docs/type-checking.md
T
Jev Kuznetsov 846eca59d2 add knowledge
2026-04-23 12:06:00 +02:00

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; mypy is CI-standard