static type system
Rules a compiler uses to check, before the program runs, that every value is used in a way its type allows.
In more detail
A type describes what a value can be, such as a string or an object with an email property. A static checker reads the source code and reports mismatches as errors without executing anything. Languages such as Java, Go and TypeScript are statically typed.
Example
TypeScript adds a static type system on top of JavaScript: compile-time proof for dynamic codeRelated terms
- static type checking — Checking that values are used consistently with their declared types by analysing code without running it.
- compile time — The moment source code is checked and translated by a compiler, before the program runs, as opposed to run time.
- dynamic typing — A language design where a variable can hold a value of any type and types are only checked while the program runs.
- soundness — The guarantee that a program which passes type checking can never hold a value of the wrong type at run time.
Taught in
- Why TypeScript: Contracts, Erased Types And Soundness — Production TypeScript
- Verify Your Environment: Running tsc And Bun TypeScript — Production TypeScript
- any Versus unknown: Defensive Typing In Practice — Production TypeScript
- Discriminated Unions: Tagged Variants And Pattern Matching — Production TypeScript
- Custom Type Predicates: Functions Returning is Type — Production TypeScript
- Exhaustive Narrowing With never In Production Handlers — Production TypeScript
- Conditional Types: Ternary Types And Type Inference With infer — Production TypeScript
- Mapped Types, Key Remapping With as And Template Literals — Production TypeScript
- The satisfies Operator: Safe Validation Without Widening — Production TypeScript
- The Spine Artifact: Generating Typed Models From OpenAPI — Production TypeScript