DEV Community

Discussion on: TypeScript Tutorial: A step-by-step guide to learn TypeScript

Collapse
 
macsikora profile image
Pragmatic Maciej • Edited

Thank you for the article. I want to correct some mistakes. The first which I have spotted, and it is very common is:

Wrong information about OOP

TypesScript is an Object oriented programming language whereas JavaScript is a scripting language.

TS is multi-paradigm language in the same way JS is, JS has also OOP features and at this level TS is in any way more object oriented than JS itself. Statement that TS is OOP and JS is not, would never be correct, as objects exists in the language from beginning. But before ES6 there was no class keyword, and no classical class based OOP syntax, now it's history though.

That said below quote is also outdated information:

Typescript supports object-oriented programming and adds new features to improve upon Javascript’s OOP functionality. Typescript supports the use of classes by using the class keyword

Wrong information about void type

Another mistake is:

Void is a subtype of undefined

Lets check if this is true:

type IsVoidSubTypeUndefined = void extends undefined ? true : false;
// above evaluates to false
Enter fullscreen mode Exit fullscreen mode

It means void is not a subtype of undefined type. undefined is really a unit type in the same way void is, there is no relation between these types.

Mistake about instanceof

This operator can check for custom types not defined by Javascript. Below, we first write a custom type, make an instance of it, and check that it is indeed the right variable.

Its not valid, instanceof is valid JS operator, it works only with objects created by new. Its not any kind of TS feature, saying that it has something with

custom types not defined by Javascript

is incorrect.

Also I very dislike the whole Step 9 as it mixes JS operators which exists in the runtime with TS operators existing only at compilation. In Step 2 you describe some types in some random way, and surprisingly there is no info about Record and Union types which are the basic tool for every TS programmer.

In summary I want to thank you for the effort, but I am very sorry to say in my opinion some information's in the article could be double checked and verified.