Appearance

Visual style

Mode
Theme
Accent
Advanced
Text sizeScales the whole site
16 px
Reduce motionReduce animations or match your system
Separate light and darkChoose a theme, accent and font for each
50

Technology · Frontend

TypeScript development

TypeScript is a typed superset of JavaScript developed by Microsoft. Its handbook describes it as adding static types that are checked at compile time and then erased, so the output is plain JavaScript that runs anywhere JavaScript runs.

In practice

How I use TypeScript

Every project I start is TypeScript in strict mode: Next.js and Astro frontends, Hono APIs on Cloudflare Workers, and the shared npm packages consumed across Ekonavi's apps. On the static sites I build, content itself is typed, so a missing image or a broken internal link fails the build instead of reaching production.

Runtime validation with Zod

I validate all data that crosses a trust boundary and rely on type inference everywhere else.

  • Request bodies, query strings, webhook payloads and environment variables are parsed with Zod.
  • The TypeScript type is derived from the schema with z.infer, so there is one definition.
  • Inside the application, functions take already-validated domain types and don’t re-check them.
import { z } from "zod";

export const CreateOrder = z.object({
  productId: z.string().min(1),
  email: z.string().email(),
  quantity: z.number().int().positive().max(10),
});
export type CreateOrder = z.infer<typeof CreateOrder>;

Typed content models

On static sites, I give content a schema too. This portfolio is an example: every service, technology, industry, project and article is validated at build time, and relationships between them are typed references. If a case study points at a technology page that doesn’t exist, the build fails with the exact file and field.

Shared types across a monorepo

In multi-app repositories, shared packages export their types alongside their code. When a contract changes, tsc across the workspace lists every app that needs updating before anything is deployed. This is the main reason I prefer a monorepo for products with several frontends and APIs.

Trade-offs

Where TypeScript shines, and where it doesn't

Strengths

  • Catches whole classes of bugs (undefined fields, wrong shapes, missed cases) before runtime.
  • Makes refactors across a monorepo safe: change a shared type and every consumer that breaks is listed.
  • Editor tooling doubles as documentation for APIs and content models.

Limitations

  • Types are erased at runtime. Data from users, APIs and webhooks still needs runtime validation.
  • Overly clever generic types slow down both the compiler and the next developer.

Evidence

Projects using TypeScript

All work →

Sources

Official documentation

General descriptions on this page are based on the official documentation linked below. Experience notes are my own.

FAQ

TypeScript questions

Is TypeScript worth it for a small business website?

Yes, mostly for the content layer. A typed content model means a typo in a product slug or a missing image fails the build instead of shipping a broken page. The cost is negligible once a project template is set up.

Does TypeScript validate API data?

No. TypeScript only checks code at compile time. For data arriving at runtime (form submissions, webhook payloads, third-party API responses) I parse it with Zod and derive the TypeScript type from the schema, so the two can't drift.

What is Zod and why use it with TypeScript?

Zod is a TypeScript-first schema library that validates data at runtime and infers static types from the same schema. Because TypeScript's types disappear at runtime, Zod is what actually checks form input, API requests, webhook payloads and environment variables, with one definition for both the check and the type.

Need a TypeScript developer?

If your project needs TypeScript, send a short description of what you're building and where it's stuck. I'll reply with how I'd approach it.