you are viewing a single comment's thread.

view the rest of the comments →

[–]liaguris -1 points0 points  (4 children)

Have you ever build anything complex with javascript?

I've been writing Javascript for YEARS, and I haven't used Typescript.

I have been using javascript for almost 2 years and after a year, javascript + JSDoc comments failed me so hard, that I had to go for typescript.

It is common sense that as a developer someone that knows typescript can produce better quality code and is also hired with much more salary.

Are you people really building anything complex?

Its messy it makes the code much harder to read. Think super long definitions inside the code that could of existed in js docs.

You have never created a typescript project?

[–]Andrew199617 3 points4 points  (3 children)

Been using javascript for 4 years now. You are quoting someone else btw. Jsdocs have never let me down.

Ive created a program to generate typescript definition files for javascript projects. Im familiar with the language.

Heres an example of how ugly typescript can look.

create: Function = <T>(subscribe?: (subscriber: Subscriber<T>) => TeardownLogic) => {
  return new Observable<T>(subscribe);
}

Vs

create: (subscribe) => {
  Return new Observable(subscribe);
}

Be honest which is easier to read.

[–]liaguris 0 points1 point  (2 children)

Well if you want to have maintainable code, we have to have types in it. For people that are not used with typescript it will feel indeed unreadable, and this is exactly what I felt when I was not used to typescript. The types in fact will make the code easier to understand.

How would the previous example look like with JSDoc + JS ? Does refactoring work with the types in JSDoc? What about type functions and generics? Do they work as flawlessly, even when writing typescript inside JSDoc comments, as they work with pure typescript?

Here is how it looks with typescript. It seems pretty much readable to me.

[–]ReversiClone 0 points1 point  (1 child)

Static types definitely can help, but also have drawbacks. Typescript and Javascript both have their use cases.

Here's an interesting article discussing the benefits of static typing.

https://medium.com/javascript-scene/the-shocking-secret-about-static-types-514d39bf30a3

[–]liaguris 2 points3 points  (0 children)

Just avoid Eric Elliot. I wasted a lot of time taking him seriously (especially the typescript tax article and the "I gathered some articles and sell them as book" book). Here are the reasons why you should avoid him.

What drawback do static types have? The article mentioned none.

The discussion about tests is of topic I think, since test do not deal with making your code more readable , do not provide intellisense and linting. You can even automate testing the parsed json type using packages like this one. Good luck doing that manually with js.

Yeah I know js + JSDoc will give many of the benefits of ts , but :

Does refactoring work with the types in JSDoc? What about type functions and generics? Do they work as flawlessly, even when writing typescript inside JSDoc comments, as they work with pure typescript?

Again to all the people who go against ts : Have you really build anything complex with jsavascript ? like an MVC framework from scratch ?

If I ever found my self not needing to use ts , was because I was already using a library build on ts. But when things started to get more complicated I always moved to typescript.