Skip to content

Type-checking

← All terms · Concepts and methodology

The process of verifying that the data types used in a program (like ensuring a number isn't treated as text) are strictly correct, preventing runtime crashes.

What it is

In dynamic languages like JavaScript, a variable meant to hold an integer can accidentally be assigned text, causing the program to crash when run. Type-checking (via tools like TypeScript) enforces these constraints statically before the code runs. If a function expects a number, the type-checker throws an explicit error during development if you try to pass it a string.

When you would use it

You rely on type-checking to significantly reduce unpredictable bugs in large applications, ensuring that different modules pass data to each other in the exact expected format.

Common operations

  • Defining strict interfaces for API responses to guarantee data structures.
  • Catching basic logic errors in the IDE before the code is compiled.

Related terms

Where this is taught