TypeScript or nothing

One language from the phone to the database. Why every project I take on is TypeScript end to end, and why I stopped apologising for it.

Prabir Singh, profile photoPrabir Singh·
·Updated ·9 min read
Editorial illustration: Matching blue components fit a shared template while a mismatched piece stays outside.
In this article
  1. 01One language, phone to database
  2. 02The compiler is the cheapest teammate you'll ever hire
  3. 03Mobile isn't an exception
  4. 04The pushback, and my honest answer
  5. 05Where I'd actually loosen up
  6. 06Try breaking the boundary, not just the build
  7. 07Frequently asked questions
  8. 08One language, one owner, fewer 2am surprises

I don't take untyped work anymore. Not the frontend, not the backend, not the mobile app. If a project can't be TypeScript from the phone to the database, I'm probably not the right person for it, and I'll say so on the first call.

That sounds rigid. It's the opposite. One language across the whole stack is the single biggest reason a small team, or one stubborn person, can move like a bigger one. Untyped codebases don't fail loudly. They fail at 2am, quietly, one undefined at a time.

One language, phone to database

Picture the shape of a project I'd take on. Four surfaces, one language, and the same types flowing through all of them.

SurfaceWhat I useWhat the types buy you
Web frontendReact with Next.js or TanStack StartProps and data that match the API, checked in the editor
MobileExpo and React NativeThe same models and validation as the web, no second copy
BackendHono or a framework route handlerTyped params, typed bodies, typed responses
DatabaseDrizzle ORM on PostgreSQLThe schema is a type, so typed queries track the declared schema

A developer who fixes a bug on the web can fix the same class of bug on mobile without switching mental gears. That's not a small convenience. It's the difference between one person covering the whole stack and needing three.

Types that cross the wire

The real payoff lives at the seams. When your API and your client share types, a change on the backend shows up as a red squiggle on the frontend before you run anything.

// packages/types
// JSON carries the timestamp as an ISO string, not a Date instance.
export type Post = { id: string; title: string; publishedAt: string }
 
// backend returns Post
// frontend consumes Post
// rename `title` to `heading` and both sides break in your editor, not in prod

Rename a field on the server and the client won't compile until you fix it. No stale DTO. No "works on my machine." The compiler catches many contract mismatches before integration tests run. It does not replace those tests or validate a response at runtime.

The schema is a type

Drizzle describes itself as a TypeScript ORM where you define the schema in TypeScript. That sounds like a feature bullet. In practice it means the database stops being a foreign country. A renamed column breaks the query that uses it, in the editor, on a Tuesday afternoon, instead of in a customer's checkout on a Saturday night.

The compiler is the cheapest teammate you'll ever hire

Here's the reframe that changed how I talk about this with founders. Types aren't overhead. They're machine-checked documentation for the assumptions you express. They can still disagree with external data or an unapplied database migration.

Small teams need it most

Big companies have QA departments, code review rotations, and someone whose whole job is the integration suite. A founder with two developers has none of that. The compiler fills the gap for free, every time you hit save, without asking for equity.

Strict from day one

I turn on strict in every new project before I write the first component. The TypeScript docs describe it as enabling a wide range of checks for stronger guarantees of correctness. Turning it on later means fixing hundreds of errors at once. Turning it on at the start means fixing them one at a time, as they happen, when they're cheap.

The proof is in the boring week

The best evidence for TypeScript isn't a benchmark. It's the refactor week where nothing breaks. On the BIM browser viewer, the type spine runs from the Drizzle schema through Zod at every boundary to typed React components, with no any anywhere. That's what lets one engineer own both a server conversion pipeline and a 3D viewer without losing sleep over either.

Mobile isn't an exception

People treat mobile like a different country with its own rules. It isn't, not anymore. The Expo docs put it plainly: Expo has first-class support for TypeScript. I write the React Native app in the same language, share validation and types with the web through a shared package, and ship to iOS and Android from one codebase for both app stores.

"An app version later" stops being a rewrite

When the hard parts, the types and the business logic, already exist in a shared package, "later" takes days instead of a fresh build. On a racket sports platform the Expo app, the web apps, and the Hono API live in one Turborepo and speak the same TypeScript. I've written about running every app from one repo if you want the plumbing.

Where the shared package pays off

Validation is the quiet winner. A Zod schema written once checks the form on the phone, the form on the web, and the request on the server. Change the rule in one place and three surfaces agree by Monday.

The pushback, and my honest answer

I hear the same objections on almost every first call. They deserve real answers, not a sermon.

"TypeScript slows us down at the start"

It does, a little. You write types you didn't write before. Then it pays that back with interest the first time you refactor without fear, and every time after that. Fast at the start and slow forever is a bad trade. I'll take the reverse.

"Our team only knows JavaScript"

TypeScript is JavaScript with a safety net. A JavaScript developer is productive in it quickly, and the editor does half the teaching through autocomplete and red squiggles. The grumbling usually lasts until the first time the compiler catches a bug they would have shipped.

"We'll add types later"

Later rarely comes, and when it does, it arrives as a migration project with its own budget line. Types added on day one cost minutes. Types added in year two cost sprints.

Where I'd actually loosen up

I'm a die-hard, not a zealot. A throwaway script, a one-off data migration, a prototype you'll delete on Friday: reach for plain JavaScript and move on. The rule is for code that has to live, get maintained, and get handed to someone else. That's most of what anyone pays me to build.

any is a pressure valve, not a lifestyle

any exists for a reason. Used once, deliberately, at a genuine boundary, with a comment explaining why, it's a pressure valve. Sprayed across a codebase, it's a confession that the types got hard and nobody wanted to fight them. I fight them.

Reach for unknown instead

When data genuinely comes from outside, a webhook, a file upload, a third-party API, type it unknown and validate it before anything trusts it. unknown forces you to check. any lets you skip the check and pretend. One of those is honest.

Try breaking the boundary, not just the build

Imagine a booking API returns quantity: "2" instead of quantity: 2. A TypeScript assertion can silence the editor; it cannot turn the string into a number. The TypeScript handbook makes that distinction explicit: assertions disappear during compilation.

Here is a small boundary you can actually test:

import { z } from "zod";
 
const BookingInput = z.object({
  slotId: z.string().min(1),
  quantity: z.number().int().positive(),
});
 
export function parseBooking(input: unknown) {
  return BookingInput.safeParse(input);
}

Try a valid booking, a string quantity, zero, and a missing slot. Only the first should succeed. Then test something the schema cannot decide: a real slot belonging to another merchant. That needs server-side authorisation. A valid shape is not permission to buy someone else's inventory.

One more wrinkle: the mobile app installed last month does not recompile when you deploy today's API. Keep old clients compatible, or version the contract deliberately. Shared types make changes visible inside one repository; runtime validation, compatibility tests and database constraints protect the deployed system. The compiler is an excellent colleague. It still doesn't carry a production pager.

Frequently asked questions

Isn't this just personal preference?

Partly, and I won't pretend otherwise. But the shared-types-across-the-wire argument is structural, not aesthetic. On any project with a client and a server, end-to-end types catch a category of bug that discipline alone never catches reliably.

Does TypeScript help on small projects?

Most, actually. Small teams can't afford a QA department, so the compiler becomes one. The fewer people you have, the more you want the machine catching mistakes while you sleep.

What about React Native and Expo specifically?

Same story, same benefits. Expo's tooling supports TypeScript out of the box, and sharing a types package between your web and mobile clients is where the one-language stack stops being a nice idea and starts saving real money.

Do you ever inherit JavaScript projects?

Yes, and I migrate them incrementally. The official guide to migrating from JavaScript is built for exactly that: enable allowJs, rename one file to .ts, fix what lights up, repeat. You don't need a big-bang rewrite to start getting value.

Does TypeScript make the app faster for users?

No. Types are erased at build time, so the user's phone runs plain JavaScript either way. The speed TypeScript buys is development speed: fewer regressions, safer refactors, and less time spent hunting a typo across three apps.

Which backend do you pair it with?

Usually Hono, because its type inference carries route params and validated bodies straight into the handler. I've written up why I reach for Hono over Express, and the full list lives on my stack page.

One language, one owner, fewer 2am surprises

One language from the phone to the database means one person can hold the whole system in their head, and the compiler catches the mistakes before your users do. That's not dogma. It's an edge you keep for the life of the product. If you're weighing the frontend half, I compared Next.js and TanStack Start. And if you've got something to build, tell me what it is and I'll tell you honestly whether a typed stack fits it.

Was this useful?

No account needed. One like per browser; click again to undo.

ShareXLinkedInFacebook
Prabir Singh, profile photo

Prabir Singh

Full-stack engineer in Mumbai. Twenty years in sales taught me why people buy; seven years of code taught me how to build what they'll pay for. I still read error messages the way I once read objections: as the most honest feedback of the day. More about me or start a project.

Keep reading