What Is Static Typing? Catching Type Errors Before Runtime
Static typing means the types of variables and expressions are checked at compile time, before the program runs, so many type errors are caught early.
In a statically typed language, the type of every value is known and checked during compilation. If you pass a string where a number is expected, the compiler rejects the program before it ever runs. Languages like Java, Go, Rust, and TypeScript are statically typed. The payoff is catching a whole class of bugs early; the cost is more upfront ceremony.
When types are checked
Static typing verifies types at compile time, as part of the build. A type mismatch is a compile error, not a runtime crash. The program that survives compilation is guaranteed not to make those specific type mistakes when it runs.
Benefits of static typing
- Many bugs caught at build time instead of in production.
- Better tooling: autocomplete, refactoring, and inline docs from types.
- Self-documenting code where signatures state expectations.
- Confidence when refactoring large codebases.
Static vs dynamic typing
Static typing checks types before running; dynamic typing checks them as the program runs. Static catches errors earlier and aids tooling, but is more verbose and rigid. Dynamic is more flexible and concise, but defers type errors to runtime.
The cost of static types
You write more type annotations and sometimes fight the type checker. Compilation also takes time. The trade is upfront effort and slower builds in exchange for fewer runtime surprises.
A quick example
In TypeScript, declaring function area(r: number) and calling area("3") is a compile error. The build fails, so the mistake never reaches runtime.
Static typing in CI
Type checking is a build step, and type errors fail the pipeline deterministically, exactly as intended. They are not flaky and never need a retry. On large codebases type checking can be slow and memory-heavy; larger runners (Latchkey) speed it up and auto-retry transient OOM or toolchain blips.
Key takeaways
- Static typing checks types at compile time, catching many errors before the program runs.
- It improves tooling and refactoring safety at the cost of verbosity and build time.
- Type errors fail builds deterministically and should be fixed, not retried.