Topic
Static type checking
Static type checking analyzes a program's types before the program executes. A checker compares operations with declared or inferred value types and reports incompatible uses, helping reveal mistakes such as accessing a property that a known object shape does not contain.
At a glance
- When it runs
- Before program execution
- Example tool
- TypeScript type checker
Overview
Static type checking analyzes a program's types before the program executes. A checker compares operations with declared or inferred value types and reports incompatible uses, helping reveal mistakes such as accessing a property that a known object shape does not contain.
What types express
Types describe properties of values and how they can be used. Inference derives information from code, while annotations record constraints explicitly. Both give the checker information for evaluating an operation.
Limits of the guarantee
A type check is not a full proof of application correctness. Runtime inputs can still be invalid, and a correctly typed program can implement the wrong behavior or business rule.
Sources and review
MOOR's explanatory text is supported by the following source links.
- Static type checking introduction — TypeScript
- The basics — TypeScript