<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>__arlion.log</title>
        <link>https://velog.io/</link>
        <description>____adsa</description>
        <lastBuildDate>Wed, 16 Sep 2020 15:07:37 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>__arlion.log</title>
            <url>https://images.velog.io/images/__arlion/profile/9dee507b-b935-4728-b9bd-66f5559a7fc5/social.png</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. __arlion.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/__arlion" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[How (and why) you should use TypeScript with Node and Express.]]></title>
            <link>https://velog.io/@__arlion/How-and-why-you-should-use-TypeScript-with-Node-and-Express</link>
            <guid>https://velog.io/@__arlion/How-and-why-you-should-use-TypeScript-with-Node-and-Express</guid>
            <pubDate>Wed, 16 Sep 2020 15:07:37 GMT</pubDate>
            <description><![CDATA[<p><img src="https://images.velog.io/images/__arlion/post/94a697da-ddfc-4e23-a8f1-9bafaf4fa15b/1_fzcYZIhdZjuQaT8gTk1YAQ.png" alt="">
During the beginning of my career, I was a desktop developer, where strong typed languages dominate the market.
When I migrated to web development, I was fascinated by every new feature on languages like JavaScript and Python. The fact that I didn’t have to declare the type of variables brought me productivity and my work became more fun.
So the first time I heard about TypeScript, the idea seemed like a step backwards in the evolution of the language.<img src="https://images.velog.io/images/__arlion/post/4c52758d-118c-4440-a242-910d5a6a4dbd/a.jpeg" alt="">
Did I change my mind?
Yes, but it depends on the case. For personal projects, in which I work alone, I still prefer the productivity of plain JavaScript. But, for larger projects, where you work as a team, I recommend using TypeScript. Throughout this article I will explain how and why.<img src="https://images.velog.io/images/__arlion/post/9ee9482d-84da-4581-a506-8b7f26d56960/aa.png" alt="">
TypeScript
If you still do not know what TypeScript is, I recommend reading this overview: <a href="https://www.tutorialspoint.com/typescript/typescript_overview.htm">https://www.tutorialspoint.com/typescript/typescript_overview.htm</a>
And the official 5-minute tutorial:
<a href="https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html">https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html</a>
But we can say, superficially, that it is ECMAScript 6 with strong typing.
Productivity vs maintenance
By definition, “TypeScript is JavaScript for application-scale development”. That is, the work we have with the initial setup of the project is compensated with the maintainability of complex projects. Let’s point out why this happens:
Type safe = less errors
By defining types in your code, you allow the IDE to acknowledge errors in the use of classes and functions that would only be perceived at runtime.
Example:<img src="https://images.velog.io/images/__arlion/post/c8aaa295-dcfc-46a1-930a-cb44029c0470/aaaa.png" alt="">
Here I am using Visual Studio Code which points put two errors:
On line 6: we are trying to pass a string parameter to a function that only accepts numbers.
On line 9: we are trying to assign, to a string, the result of a function that returns a number.
These two errors would go unnoticed, without Typescript, resulting in some bug on the final application.
The IDE exposes the project modules more easily
In complex projects we have hundreds of classes distributed across multiple files. When we define types, the IDE is able to relate objects and functions to the files that gave origin to them.
When using control + click on a method or class, imported from another file, the IDE will automatically navigate to the imported file, highlighting the line where the reference was defined.
<img src="https://images.velog.io/images/__arlion/post/0ba6a92c-96f3-4b33-96a9-a15329e1a706/aaaaa.png" alt="">
We can use autocomplete in classes that have been imported from other files.
<img src="https://images.velog.io/images/__arlion/post/6e039360-14ce-4940-99d6-38dd87a53bac/1_BYJTKDDgDeCtusx4iUoGaA.png" alt="">The difficulty of maintenance is one of the main reasons why Java and C # developers avoid migrating large projects to JS. We can say that Typescript is an enterprise language that overcomes this barrier.</p>
]]></description>
        </item>
    </channel>
</rss>