Static Type Checking
Subject: Computer and Technology noun /ˈstæt.ɪk ˈtaɪp ˌtʃɛk.ɪŋ/ 1 definition
- programming-languages
- type-systems
- static-analysis
- compiler-design
-
Definition (noun)
Entry #257 · UpdatedStatic Type Checking is a program analysis process in which a compiler or standalone analyzer verifies the types of variables, expressions, and function signatures before a program runs. Using explicit type annotations, type inference, or both, it detects incompatible assignments, invalid operations, and mismatched arguments without executing the code. Unlike dynamic type checking, which inspects value types at runtime, its verification is bounded by what the language's type system can determine from source structure alone rather than arbitrary runtime values.
Common Forms
Nominal Type Checking: Validates compatibility strictly through declared type names and explicit inheritance or trait relationships, as used in Java, C#, and Rust.
Structural Type Checking: Evaluates compatibility by comparing the fields, methods, and signatures a type exposes rather than its declared name, as used in TypeScript and Go interfaces.
Inference-Based Type Checking: Deduces expression and variable types automatically from usage context and constraint solving instead of requiring explicit annotations everywhere, as in Haskell and OCaml.
Gradual Type Checking: Applies static checks selectively to typed parts of a codebase alongside untyped or dynamically typed regions, enabling incremental adoption in TypeScript and Python tooling such as mypy.
Example
Before merging a pull request, running
tsc --noEmitin CI flags a call toformatPrice(cents: number)that passes an unparsed"1999"string from an HTTP query parameter. Catching this mismatch prior to execution prevents a runtimeTypeErrorwhen the function later invokes.toFixed(2)on the value in production.