TypeScript development for code another team can pick up
The code we write for you is yours, and someday someone else may maintain it. TypeScript eases that handover, because the code states what shape its data should have.
Reviewed by: Rahul Jaiswar, founder
What TypeScript is
TypeScript is JavaScript with a type system, developed by Microsoft. Types are checked when the code compiles and removed before it runs, so they catch mistakes during development without changing how the program behaves.
Looking for a CRM built with TypeScript?
Twenty, an open-source CRM, is written mainly in TypeScript. When judging any TypeScript CRM, check whether strict mode is on and how its API types are generated, because custom fields added later should come through typed rather than as loose data.
Microsive CRM is built on Twenty.
What types don’t do
Types disappear at runtime. Data arriving from a form, a webhook or another company’s API is not checked by TypeScript at all. That needs validation code, which the first pitfall below covers.
Where we use it
Microsive ATS uses TypeScript. We also build client websites and web apps with it.
What we check
We validate data where it arrives, whether from a form, a webhook or another API, rather than trusting the type we declared. Types are checked while the code is written; the data itself turns up at runtime.
Where it pays off, and where it doesn’t
It pays off when several developers touch the code, when a new team will take it over, and when the same data crosses layers: a form, an API, a database and an invoice. A renamed field then shows up as editor errors instead of production bugs.
Plain JavaScript can be the faster choice for a one-off script or a prototype built to test an idea in days. If the team has no TypeScript experience and the deadline is close, fighting the compiler late in a project costs real time.
Questions to ask a TypeScript team
- Is strict mode on, and does the build fail on type errors?
- Where does the code use
anyorascasts, and why? - How is incoming data validated at runtime?
- Are database types generated from the schema or written by hand?
TypeScript pitfalls
- Casts that silence real errors.
as SomeTypetells the compiler to trust the code. Treat casts as review items. - Types drifting from the database. Generated types, for example from Prisma, stay in step with migrations.
- Slow checks. In large repositories, type checking can become the slowest step of a release. Plan incremental builds early, and check whether the native compiler can take over type checking.
TypeScript is used alongside Next.js. For custom software in general, see the software overview.
Want TypeScript code your next developer can read?
Tell us what you’re building and who will maintain it after handover, or which JavaScript codebase you’d like moved to TypeScript.