<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amir Alikulov</title>
    <description>The latest articles on DEV Community by Amir Alikulov (@amiralikulov).</description>
    <link>https://dev.to/amiralikulov</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F377426%2F284f95e9-1012-4e40-9417-15c648dba73e.jpeg</url>
      <title>DEV Community: Amir Alikulov</title>
      <link>https://dev.to/amiralikulov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amiralikulov"/>
    <language>en</language>
    <item>
      <title>I tried Typescript for 1 year ...</title>
      <dc:creator>Amir Alikulov</dc:creator>
      <pubDate>Fri, 21 Jan 2022 16:07:23 +0000</pubDate>
      <link>https://dev.to/amiralikulov/i-tried-typescript-for-1-year--36h3</link>
      <guid>https://dev.to/amiralikulov/i-tried-typescript-for-1-year--36h3</guid>
      <description>&lt;p&gt;After years of working in Javascript, Typescript is was something on my “things to learn” list. &lt;br&gt;
After working with Typescript for almost 1 year, here are my conclusions: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cemz1Hgx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q03bztho5m1suf3ub76j.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cemz1Hgx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q03bztho5m1suf3ub76j.gif" alt="Image description" width="276" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It’s not that scary. All Javascript is a valid Typescript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;if you are planning to start a new project, do it with typescript. You don’t have to provide 100% types to every function and variable.  You can gradually increase types coverage as you go. TypeScript can determine possible types there are for you. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mqp_ZF69--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vmcmc3bjtg9dk7mls391.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mqp_ZF69--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vmcmc3bjtg9dk7mls391.png" alt="Image description" width="708" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Refactoring code is a breeze&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you have set up your types, refactoring your code now takes less effort. You can even call it a pleasant experience. Compiler &lt;code&gt;tsc&lt;/code&gt; combined with IDE will automatically provides you with errors at specific places where you need to change your code according to types.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m0f0siLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ul81z7474w6ljq6s4mh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m0f0siLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ul81z7474w6ljq6s4mh.png" alt="Image description" width="880" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Less bugs.&lt;/strong&gt; &lt;br&gt;
Typescript only provides compile-time type safety. There is no type checking in runtime. &lt;/p&gt;

&lt;p&gt;(checkout run-time type checking libraries like &lt;a href="https://github.com/colinhacks/zod"&gt;zod&lt;/a&gt;, &lt;a href="https://github.com/ajv-validator/ajv"&gt;ajv&lt;/a&gt;, &lt;a href="https://github.com/jquense/yup"&gt;yup&lt;/a&gt;, &lt;a href="https://github.com/jquense/yup"&gt;joi&lt;/a&gt; )&lt;/p&gt;

&lt;p&gt;So if there is a bug in production, typescript will not help you. However it does prevent you from creating bugs while you are coding or refactoring. 10 minutes invested in typescript will potentially save you hours of debugging in the future.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time-consuming ? Yes and No&lt;/strong&gt;&lt;br&gt;
You will definitely spend more than time developing in Typescript than plain Javascript. &lt;br&gt;
However this time will pay off as you will create less bugs in production. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Replaces tests? Arguably&lt;/strong&gt;&lt;br&gt;
If you project does not have any test, typescript is the least thing you can do. &lt;/p&gt;

&lt;p&gt;There is a good post by &lt;a href="https://twitter.com/swyx"&gt;Shawn Wang&lt;/a&gt; you can read about this. &lt;br&gt;
&lt;a href="https://css-tricks.com/types-or-tests-why-not-both/"&gt;https://css-tricks.com/types-or-tests-why-not-both/&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Tests are best at ensuring happy paths work.&lt;/li&gt;
&lt;li&gt;Types are best at preventing unhappy paths from existing.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;or this talk by &lt;a href="https://twitter.com/garybernhardt"&gt;Gary Bernhardt&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.destroyallsoftware.com/talks/boundaries"&gt;https://www.destroyallsoftware.com/talks/boundaries&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After using Typescript, typing vanilla javascript feels awkward. It seems like a naked and vulnerable code without any protection. &lt;/p&gt;

&lt;p&gt;I guess you can’t go back. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1uEMp9p0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d1919r95yhnd9cbbop3m.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1uEMp9p0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d1919r95yhnd9cbbop3m.jpg" alt="Image description" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
