I just had a presentation at work from a backend PHP dev who’d done a couple of tutorials on Typescript and thought it was great!
His presentation ended with the comment that our company should start using Typescript in all our frontend projects to a chorus of “yay!” from all the junior devs in the company who’re super-psyched to start getting Typescript experience.
Now I work for an agency, we specialise in making web apps for big clients quickly. I don’t think it’s the best place to be introducing Typescript as a staple of our toolset and here’s why.
Typescript is great for stabilising mature apps
Typescript started really getting popular around three or four years back. Think about the timing and the kind of web applications that dominated the space: Netflix, facebook, YouTube, Spotify.
All apps in a very mature phase of development.
So many developers dream about working for these companies only to find that it’s super-boring because they’re basically working on a behemoth project, without any space for exciting coding work. At this level Netflix is working on making their codebase strict, stable and… strongly typed.
Typescript is great choice for Netflix and here’s why:
- It’ll prevent devs from introducing buggy code.
- The types will allow devs to quickly understand helper functions already built into the app.
- The extra housekeeping required when changing anything major will prevent them from ripping whole sections of the app apart to refactor code already well built.
In my last job I once complained to the lead dev that Typescript was making development on our app too rigid and he replied; I agree, but I haven’t decided whether that’s a good or bad thing.
Maybe you want your app to be rigid.
The only thing I’d argue with is that probably, early on, you don’t.
What do users and investors want from an app?
Under a tight schedule an app is built for features not for cleanliness. Clean code is important but not more important than functionality. If I use an app with some broken types that works, as a user I don’t care.
Before we start to think about how clean our codebase is let’s get our apps working and out the door. Many things that Typescript considers a “bug” are: an un-typed object parameter, a number defined as a string, a missing return type on a