static type checking
Checking that values are used consistently with their declared types by analysing code without running it.
In more detail
Tools such as mypy for Python and the TypeScript compiler read type annotations and report mismatches before the code runs. Annotations usually have no effect at run time; only the checker reads them.
Examples
In Python the usual static type checker is mypy.In this course: In Python, tools such as mypy or Pyright read type hints and report mismatches before tests even run, which makes them a fast first layer in a quality gate. Type hints do nothing at run time; only the checker reads them.Related terms
- type hint — A note in a function heading or variable declaration saying what type a value should be, such as def total(prices: list[float]) -> float:.
- mypy — A static type checker for Python that reads type hints and reports code whose types do not fit together, without running it.
- dynamic typing — A language design where a variable can hold a value of any type and types are only checked while the program runs.
- linter — A tool that reads code or configuration without running it and flags likely mistakes and style problems.
- quality gate — A check, or set of checks, that a change must pass before it can move on, such as being merged or promoted to the next pipeline stage.
- static type system — Rules a compiler uses to check, before the program runs, that every value is used in a way its type allows.
- compiler pipeline — The ordered stages the TypeScript compiler runs: scan and parse into a syntax tree, bind names, check types, then emit JavaScript.
- noEmit — The compiler option that makes tsc check types without writing any output files.
Taught in
- Type Hints — Hands-on Python: Complete Video Course & Book
- Code Review As A Quality Gate — Automated Testing, TDD & Quality Engineering
- What To Automate Away — Automated Testing, TDD & Quality Engineering
- Why TypeScript: Contracts, Erased Types And Soundness — Production TypeScript
- The Compiler Pipeline: tsc, AST And Code Emission — Production TypeScript
- tsconfig.json: target, lib, strict And NodeNext — Production TypeScript
- Verify Your Environment: Running tsc And Bun TypeScript — Production TypeScript
- any Versus unknown: Defensive Typing In Practice — Production TypeScript
- Typeof Guards, Truthiness And Equality Narrowing — Production TypeScript
- Custom Type Predicates: Functions Returning is Type — Production TypeScript
- ECMAScript Modules, CJS Interop And verbatimModuleSyntax — Production TypeScript