DEV Community

Cover image for 5 difficulties of Typescript as a beginner & How to deal with it
banaya
banaya

Posted on

5 difficulties of Typescript as a beginner & How to deal with it

Learning something new about coding is not easy, especially for the code newbie. After I decided to learn Typescript, I found 5 most difficulties that I've found while my learning as a self-taught web development newbie.


5 Most Difficulties about Typescript

1. A lot of "Types"

First of all, I felt what such a lot of "Types" there.
I learnt Javascript before, therefore many of them have been already known. However, I just surprised the amount of Types that Typescript uses.

It's OK, you get used to it while you are learning. To know and understand the "Types" are probably a beginning of your Typescript journey, so I'm sure you will get during your learning.

Here are some Type keywords that I confronted some difficulties:

  1. any (usually we avoid using this)
  2. interface
  3. as
  4. void
  5. tuple

2. Union Type

Union typeis a type that is a combined type with other different kind of types. (e.g. string and number). I understand this concept, but I didn't understand quite well how to use it / how it
works.

3. "?" and "!"

We will use "?" and "!" marks as a postfix in Typescript very often. "?" will be used as showing the optional properties, and "!" shows that a value exists. Since there are bunch of other ways to use these marks in other languages, I get confusing at the beginning of learning.

4. Decorators

Decorators is not Typescript-specific method, however, below two features invokes the difficulties to me.

  1. The expressions for each decorator are evaluated top-to-bottom.
  2. The results are then called as functions from bottom-to-top. (from TypeScript doc)

These makes me checking the order of result/output in console many times for now, but I believe I would learn soon.

5. How to write "clean" code

After I learn a syntax of Typescript, I realize that "how to write clean code with Typescript" since it breaks the rule of "DRY".

Inheritance is one of the key to solve this. However, using this is very hard for me.

Generics is another type that makes me confusing. Since it uses <> mark after the function name, and it denotes types, I sometimes get lost what represents what.

Image description

How To Deal With them?

1. Search, Search, and Search!!

If you meet some unknown methods, just googling it. For me (as a person English is not the first language) some documents are a bit difficult to understand. But don't worry. Many documents / articles explain very easily, which makes you understand.

The official document is easy to understand in most of time, but sometimes not for me.
I found another document, created and organized by Tutorials Teacher, and their document are much more easy to understand the concept. Tutorials Teacher - Typescript

2. Trying to output

Creating something is the best partner of understanding. During taking a video tutorial, I do not understand how to use Typescript at all. After moving to the creation pert in the tutorial each piece of puzzle are fits! (even copying teacher's creation at that time). Of course you have to understand why all codes happened!!


Please let me know if you have any advice. I have a lot of to learn to stay in Tech industry, so it would be great to share your thoughts and comments.

Thanks for reading.

Top comments (0)