TypeScript vs. JavaScript
Ayo Alfonso

Interesting and funny article. I’m using TypeScript for 2 years. One important feature is missing : implicit typing, so that we don’t need to write `var a: number = 2;` but simply `var a = 2;` i.e. pure js. Use explicit typing only when it is necessary, for instance for an argument of a function without default value.

Another point: Js and other dynamic typing languages enable to write `let a = 2; … a = ‘a’;`. This is not intuitive. We can indicate this in Ts: `let a: number|string = 2; … a = ‘a’;`. It’s explicit, no surprise. We can extend this behavior with `null` to allow to set a variable null only if its type is `*|null`.

Indeed it’s more complicated to learn and to use, especially with external Js libraries, cf. previous comment on immutable. Ts is not just a language, it’s an ecosystem: IDE (e.g. VSCode), build process (to compile Ts down to ES5 for instance), `npm/@type` or typings…

So, Ts means more ‘honesty’, more security in the code (compile time checkings to prevent run time errors) but also less liberty. Same issue using JsLint on Js code (and TsLint on Ts code). It’s a choice to make.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.