My thoughts on the TypeScript debate
Tags: javascript, typescript
Published: 2022-04-28 07:18:11

---
title: My thoughts on the TypeScript debate
published: true
description: Several questions have been posts about using/learning typescript - this post captures my perspective on the debate
tags: javascript, typescript
//cover_image: https://direct_url_to_image.jpg
---

In recent weeks I have seen several posts asking questions such as:

>Should I learn JavaScript or TypeScript?

>Should we be using TypeScript on our project?

For me the answers are obvious but might not meet with wide approval.

##My Opinion
Personally, I have mixed feelings about TypeScript but I do not think it is a bad thing. However, between JS and TS my preferred language remains JavaScript.

I have been writing TypeScript professionally day-in-day-out for the past four years but this is on top of 20 year's experience of writing JavaScript, with varying levels of competence.

To answer the first question "learn JS or TS" the answer has to be JS then TS. Nowadays to become a professional web application developer you need both. You first need a firm foundation in JS before adopting TS. After all, the web browser and [Node](https://nodejs.org/) do not understand TS (unlike [Deno](https://deno.land/)). When debugging code, you might have access to source maps that link the obfuscated JS code to the TS instructions but sometimes to need to delve deep into the JS and get as close to the JS processor as possible to discover the root cause of issues.

I am of the opinion that when developing a project in a team TS makes considerable sense especially when the team is indoctrinated in OOP. One of the worst arguments I came across of adopting TS was "Most of the team are actually C# developers and they do not want to learn JS". My answer would be "keep them backend but not on Node". The justification was that TS, with its strong data typing, is closer to C#, but this is a fallacy. TS provides some additional checking to help the developer identify potentially in appropriate use of variables (given a hint of their expected type) but this is a development-time, not a run-time feature.
I have had to battle this assumption several times and even Microsoft have changed their take on the role of TS in relation to JS. 

TypeScript used to be described as being a superset of JavaScript as it added features to the language - but it does not. TS is little more than a perpetual linter statically checking your code, especially when used in conjunction with an IDE such as Visual Studio Code.
Now MS say "TypeScript is JavaScript with syntax for types", the actual checking being done by running the TSC command, by the IDE or by plugins to the IDE. But don't get me wrong, anything to help the developer identify bugs before the go to test/production has to be a good thing.

One issue I have found it TS pushes the development more along the OOP route than I like. As I extend my coding style to employ more FP (Functional Programming) techniques, I have found that TS can make the function declaration considerably more complicated but perhaps I am doing it wrong.

##In summary
If you plan to work as a frontend developer on a team with more than one FE dev then you should learn TypeScript but this should be built on a good understanding of JavaScript to get the maximum benefit.