ENATIV Logo
ENATIV
Back
© 2026 ENATIV
ProjectsServicesKnowledge hubContact
contact@enativ.pl
  1. Knowledge hub
  2. ›
  3. Frontend
  4. ›
  5. TypeScript

TypeScript

JavaScript with syntax for types: the compiler checks the shape of data and plain JavaScript comes out.

FrontendUsing since 2015 · Featured project: Budzowska Fiutowski i Partnerzy

Category
Frontend
Using since
2015
Featured project
Budzowska Fiutowski i Partnerzy

In practice

I treat TypeScript as a project default, because types catch errors where data changes hands: between a form, an API and a database. On Gaia Lens the frontend moved from JavaScript to TypeScript, and the contact form in ENATIV Portfolio shares one schema between browser and server. A one-afternoon script stays plain JavaScript.

What is TypeScript?

TypeScript is JavaScript with syntax for types. Any working JavaScript is also valid TypeScript, so a project can move over gradually. The compiler checks types and removes them from the output, so the browser and the server run plain JavaScript.

The type system is structural: compatibility depends on the shape of an object, not the name of its type. Types disappear at compile time, so they check nothing while the program runs. Outside data, such as a form or an API response, must be validated separately.

Type system
Structural
Types after compiling
Removed from the output

How I work with TypeScript

I start with the places where data enters the application from outside, because that is where types without a runtime check mislead most easily. The compiler guards the inside of the code, and validation guards the borders. Inside I annotate less, at the edges more, because the compiler infers types wherever it can.

  1. The outer border

    Data from a form or an API route goes through a Zod schema, and the type follows from the schema. On ENATIV Portfolio the contact form and the API route use one schema, so they cannot drift apart.

  2. Strict mode from day one

    I switch strict mode on in the first commit and do not silence the compiler with comments. That is how ENATIV Portfolio runs: strict mode is on, and the code has no comments that switch type checking off.

  3. Migration without a rewrite

    I move existing JavaScript over gradually, starting where errors cost the most. On Gaia Lens the frontend moved to TypeScript once extending the old code kept getting heavier.

When it fits, and when it doesn't

TypeScript adds setup and learning, so I ask whether that cost pays back.

A good fit when

  • An application several people will develop, or for over a year.
  • A project with an API, forms and a database, where data changes shape.
  • Code shared between the frontend and the backend, such as validation schemas.
  • Existing JavaScript that is getting hard to change.

Not a fit when

  • A one-afternoon script or a prototype that will end up in the bin.
  • A few lines of script on a page, with no logic of its own.
  • A short project where nobody will get to use the types.

Plain JavaScript stays in those cases. On projects with React and Next.js I pick TypeScript by default.

Frequently asked questions

A little at the start, because you have to describe the shape of the data and set up the compiler. It pays back on changes: the compiler points at what broke after a type change before a user sees it. On a one-afternoon script it never arrives, so I skip TypeScript there.
It can, without pausing the work, because a working JavaScript file is also valid TypeScript and the compiler can accept JavaScript files. I move the code gradually, starting where errors cost the most. On Gaia Lens the migration covered the whole frontend.
Not on their own, because types vanish at compile time and check nothing while the program runs. I validate outside data separately with a Zod schema and derive the type from that schema. That is how the contact form on ENATIV Portfolio works: one schema serves both the form and the API route.
Content changes need no developer, because an editor works in the CMS panel. Code changes do, so before I choose TypeScript I ask who will develop the project after launch. If nobody will, I consider a simpler tool, so you are not left with code nobody can touch.
No. It catches type mismatches, but it will not check whether the logic does what you need, or whether outside data has the promised shape. So I treat types as a safety net next to validation and code review, not a replacement for them.

On this page

  • In practice
  • What is TypeScript?
  • How I work with TypeScript
  • When it fits, and when it doesn't
  • Frequently asked questions

Related topics

  • TypeScript
  • React
  • Next.js
  • React Native
  • Payload CMS

Related services

  • Web ApplicationsModern, fast and scalable web applications using React and Next.js.
  • Mobile AppsNative iOS and Android applications built with React Native and Expo.

Is your JavaScript code hard to change?

Describe where errors show up most often and who works in the code. I will point to the places where I would start typing, and say whether it makes sense for your project.

Describe your projectSee Budzowska Fiutowski i Partnerzy