Back to technologies

TypeScript

TypeScript adds types to JavaScript. Types describe the data each part of an app expects and help catch some mismatches before it runs.

What you can build or improve

Data contracts

Define the fields shared by the interface and server, such as the information a quote needs to contain.

Gradual modernization

Add types first where mistakes tend to happen: amounts, status values, and response formats.

When we’d choose it

We’d choose it when several screens or services rely on the same data and we want to change those rules without checking every file by hand.

Why use it

When a required field is renamed, the type checker can flag the screens and functions that still use the old name.

What to consider

Types are checked during development. The running app still needs to validate what comes in from a form or an outside provider.

Illustrative example

Quote form

If pricing changes to store the currency and amount separately, TypeScript helps find places where the app still expects a single number.

Official documentation

Tools and how they fit together

Types help coordinate changes across modules. External data still needs to be validated when it arrives.

Data contracts

Data contracts

Describe the fields an API exchanges and use types in the code that calls it. That makes outdated uses easier to catch during review.

  • TypeScript
  • OpenAPI
Validation at runtime

Validation at runtime

Check the actual contents of a form or message before using them. A type alone can’t stop an invalid value from arriving.

  • Zod
  • TypeScript
Checks before release

Checks before release

Run the type checker and repository rules on proposed changes. If you use Vite, run tsc separately to check types.

  • tsc
  • ESLint
  • GitHub Actions

Questions before you decide

Do we have to convert all our JavaScript at once?

No. We can start with a module that changes often and expand coverage as the rest of the code evolves.

Which part should we type first?

Start with a boundary that changes often, such as a quote format shared by the server and several screens.

Can it replace tests?

No. A program can accept all the right types and still calculate a discount incorrectly. Test that rule with concrete examples.

What technology fits your project?

Tell us your idea