<?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: Evaldas</title>
    <description>The latest articles on DEV Community by Evaldas (@evaldasburlingis).</description>
    <link>https://dev.to/evaldasburlingis</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%2F153497%2F847ca117-3883-4da6-b121-c0463eba9277.jpeg</url>
      <title>DEV Community: Evaldas</title>
      <link>https://dev.to/evaldasburlingis</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/evaldasburlingis"/>
    <language>en</language>
    <item>
      <title>To new developers</title>
      <dc:creator>Evaldas</dc:creator>
      <pubDate>Thu, 17 Sep 2020 16:24:42 +0000</pubDate>
      <link>https://dev.to/evaldasburlingis/to-new-developers-20jj</link>
      <guid>https://dev.to/evaldasburlingis/to-new-developers-20jj</guid>
      <description>&lt;p&gt;The programming world is huge. In fact it is so huge and wide that it is impossible to learn everything. And the good thing is that you don't need to learn everything. Being a developer means being good at googling things. And that's it. There are plenty of web developers with 10+ years of experience and they still are googling things how to capitalize the first letter of a string. &lt;/p&gt;

&lt;h2&gt;
  
  
  Main things you should keep in mind
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Noone knows everything&lt;/li&gt;
&lt;li&gt;Being a developer means being good at googling things&lt;/li&gt;
&lt;li&gt;If you don't know something, don't be afraid to ask&lt;/li&gt;
&lt;li&gt;If you copy code that works and you don't understand why, don't beat yourself about it. Move on and you will understand why it works later. And hey, if it works it works!&lt;/li&gt;
&lt;li&gt;Don't try to memorize something!!! Google whenever you need something!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>newbie</category>
    </item>
    <item>
      <title>Typescript for beginners: adding typescript to your projects with parceljs</title>
      <dc:creator>Evaldas</dc:creator>
      <pubDate>Wed, 16 Sep 2020 08:11:55 +0000</pubDate>
      <link>https://dev.to/evaldasburlingis/typescript-for-beginners-adding-typescript-to-your-projects-with-parceljs-6c</link>
      <guid>https://dev.to/evaldasburlingis/typescript-for-beginners-adding-typescript-to-your-projects-with-parceljs-6c</guid>
      <description>&lt;p&gt;There are many ways to add typescript to your project. Some require a huge amount of configuration and some are as easy as adding several code lines. I think one of the easiest ways to do so is to use a bundling tool like parceljs. With it, you can add typescript in a matter of minutes with pretty much no config required.&lt;/p&gt;

&lt;p&gt;## What the heck is parceljs?&lt;/p&gt;

&lt;p&gt;Parceljs is a super-fast web application bundler that works straight out of the box. I'm sure everyone has heard about webpack and while it is more powerful, it is a lot harder to set it up correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ready? Let's add typescript to our project
&lt;/h2&gt;

&lt;p&gt;!!! Before we do anything, make sure that you have &lt;code&gt;nodejs&lt;/code&gt; and &lt;code&gt;npm&lt;/code&gt; installed !!!&lt;/p&gt;

&lt;p&gt;To check whether we have those technologies installed use command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node --version
 // v12.18.4
npm --version
// 6.14.6
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you don't have them installed, please go to :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/en/"&gt;https://nodejs.org/en/&lt;/a&gt; to install nodejs&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"&gt;https://docs.npmjs.com/downloading-and-installing-node-js-and-npm&lt;/a&gt; guide to install npm&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the terminal create a new folder and move to it&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mkdir my-awesome-ts-project &amp;amp;&amp;amp; cd my-awesome-ts-project&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The next step is to add &lt;code&gt;package.json&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;npm init -y

// we will get
{
  "name": "my-awesome-ts-project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We are almost done, the next step would be to add parceljs and typescript with &lt;code&gt;npm install --save-dev typescript parcel-bundler&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And that's it! Now you can create your &lt;code&gt;.html&lt;/code&gt; and &lt;code&gt;.ts&lt;/code&gt; files. Add script tag and voulia, typescript is ready!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Document&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"app.ts"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;One more thing, you will need to add one more line in &lt;code&gt;package.json&lt;/code&gt; to start your local development with parceljs.&lt;/p&gt;

&lt;p&gt;Add this line to &lt;code&gt;scripts{}&lt;/code&gt; section &lt;code&gt;"start": "parcel index.html"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Your final &lt;code&gt;package.json&lt;/code&gt; will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;my-awesome-ts-project&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="s2"&gt;,
  &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;version&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;,
  &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="s2"&gt;,
  &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;,
  &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;scripts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;: {
    &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;echo&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error: no test specified&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &amp;amp;&amp;amp; exit 1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;parcel index.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;author&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;license&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ISC&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;devDependencies&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;parcel-bundler&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^1.12.4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;typescript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^4.0.2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And that's it, now just run the command &lt;code&gt;npm run start&lt;/code&gt; and it will start the local development server.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;app.ts&lt;/code&gt; file will be compiled into javascript automatically, so you can write typescript like there's no tomorrow.&lt;/p&gt;

</description>
      <category>typescript</category>
    </item>
    <item>
      <title>Typescript for beginners: array</title>
      <dc:creator>Evaldas</dc:creator>
      <pubDate>Tue, 15 Sep 2020 07:51:11 +0000</pubDate>
      <link>https://dev.to/evaldasburlingis/typescript-for-beginners-array-10fo</link>
      <guid>https://dev.to/evaldasburlingis/typescript-for-beginners-array-10fo</guid>
      <description>&lt;p&gt;In typecript we have two ways to work with arrays.&lt;/p&gt;

&lt;p&gt;First way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Define our variable &lt;code&gt;let cities&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Write our type to check &lt;code&gt;: string[]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Give value to our variable &lt;code&gt;= ["London", "New York", "Dubai"]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;: string[]&lt;/code&gt; this means that we want to check if our array contains &lt;code&gt;string&lt;/code&gt; type values.  If the array contains only numbers we write it as &lt;code&gt;: number[]&lt;/code&gt; and so on. &lt;strong&gt;If our array contains mixed types we will use &lt;code&gt;any[]&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;cities&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;London&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;New York&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dubai&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;years&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Second way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Define our variable &lt;code&gt;let cities&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Write our type to check &lt;code&gt;: Array&amp;lt;string&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Give value to our variable &lt;code&gt;= ["London", "New York", "Dubai"]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;cities&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;London&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;New York&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dubai&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;years&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There is no difference between one way or another apart from syntax. Some might say that using the second way is a bit more clear, but that's one man's opinion.&lt;/p&gt;

</description>
      <category>typescript</category>
    </item>
    <item>
      <title>Typescript for beginners: boolean</title>
      <dc:creator>Evaldas</dc:creator>
      <pubDate>Mon, 14 Sep 2020 07:51:05 +0000</pubDate>
      <link>https://dev.to/evaldasburlingis/typescript-for-beginners-boolean-549h</link>
      <guid>https://dev.to/evaldasburlingis/typescript-for-beginners-boolean-549h</guid>
      <description>&lt;p&gt;Boolean is the data type that has two possible values. It is either true or false. &lt;/p&gt;

&lt;p&gt;To do type checking on the variable we can write a statement as follows&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isTrue&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Step-by-step: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Define variable &lt;code&gt;const isTrue&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add typescript type check &lt;code&gt;: boolean&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Define value &lt;code&gt;true&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To check whether function is returning boolean we can do it as fallows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;isOlder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;isOlder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;isOlder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;span class="nx"&gt;isOlder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// error 'Argument of type boolean is not assignable to parameter of type number'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Step-by-step:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Define function &lt;code&gt;function isOlder(argument : typecheck) : type to return {...}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Typescript for beginners: number</title>
      <dc:creator>Evaldas</dc:creator>
      <pubDate>Sun, 13 Sep 2020 05:03:27 +0000</pubDate>
      <link>https://dev.to/evaldasburlingis/typescript-for-beginners-number-3657</link>
      <guid>https://dev.to/evaldasburlingis/typescript-for-beginners-number-3657</guid>
      <description>&lt;p&gt;One time I've been working with Rest API and there was this one property, that was supposed to be a number. Instead, it wasn't, it was a string and it broke my function. At the time I wasn't using typescript and it took some time to find a problem. With typescript, it would have been so much quicker!&lt;/p&gt;

&lt;p&gt;Typescript basic type number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function addTax(num: number) : number {
    const tax : number = num * .21;

    return num + tax
}
addTax(100) // 121
addTax("100") // 10021 // error "Argument of type 'string' is not assignable to parameter of type 'number"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>typescript</category>
    </item>
    <item>
      <title>Typescript for beginners: string</title>
      <dc:creator>Evaldas</dc:creator>
      <pubDate>Sat, 12 Sep 2020 09:37:43 +0000</pubDate>
      <link>https://dev.to/evaldasburlingis/typescript-for-beginners-string-4c00</link>
      <guid>https://dev.to/evaldasburlingis/typescript-for-beginners-string-4c00</guid>
      <description>&lt;p&gt;As programmers we are using strings to work with textual data all the time.&lt;/p&gt;

&lt;p&gt;In typescript we have a word &lt;code&gt;string&lt;/code&gt; to check if the type is string.&lt;/p&gt;

&lt;p&gt;In the function below we are checking whether the argument supplied is a string and we are making sure that we return a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getName(name: string) : string { 
return `Hi, my name is ${name}` 
} 

getName("Paul") // Hi, my name is Paul
getName() // error "Expected 1 arguments, but got 0."
getName(true) // error "Argument of type 'boolean' is not assignable to parameter of type string"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To break it down into smaller bits, this functions reads as follows:&lt;br&gt;
&lt;code&gt;function getName(argument : type to check) : type we want to return {.....}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We can also type check variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let postCode : string = "LT-3422"; 
postCode = 4232// error "Type 'number' is not assignable to type 'string'".
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>typescript</category>
    </item>
    <item>
      <title>JavaScript snippet: get trailing information after ("/", "-", "etc")</title>
      <dc:creator>Evaldas</dc:creator>
      <pubDate>Fri, 11 Sep 2020 18:24:10 +0000</pubDate>
      <link>https://dev.to/evaldasburlingis/javascript-snippet-get-trailing-information-after-etc-3pbp</link>
      <guid>https://dev.to/evaldasburlingis/javascript-snippet-get-trailing-information-after-etc-3pbp</guid>
      <description>&lt;p&gt;Recently I've been working on a job board website. It has URL structure as follows: "job/shopify-rails-junior-dev-4d5as18184das". Everything after last dash(-) is id in the database about this specific job ad. To extract it I wrote a short and simple function that allows you to get everything after the last slash, dash, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Javascript:
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const test1 = "/shopify/php-programmer-4781"
const test2 = "/shopify/rails/1351"

function getTrailingId(punctuation, str)  {
    const trailingId = str.substr(str.lastIndexOf(punctuation) + 1)
    return trailingId
}

getTrailingId("-", test1) // 4781
getTrailingId("/", test2) // 1351
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Typescript:
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const test1 : string = "/shopify/php-programmer-4781"
const test2 : string = "/shopify/rails/1351"

function getTrailingId(punctuation: string, str: string) : string {
   const trailingId : string = str.substr(str.lastIndexOf(punctuation) + 1)
   return trailingId
}

getTrailingId("-", test1) // 4781
getTrailingId("/", test2) // 1351

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>snippet</category>
    </item>
    <item>
      <title>Typescript for beginners: how to ignore code</title>
      <dc:creator>Evaldas</dc:creator>
      <pubDate>Fri, 11 Sep 2020 10:15:01 +0000</pubDate>
      <link>https://dev.to/evaldasburlingis/typescript-for-beginners-how-to-ignore-code-4han</link>
      <guid>https://dev.to/evaldasburlingis/typescript-for-beginners-how-to-ignore-code-4han</guid>
      <description>&lt;p&gt;Typescript is one of the best things that have happened in JavaScript world. It is a solid tool that checks for errors before they have happened. But sometimes we want to turn it off for some code.&lt;/p&gt;

&lt;p&gt;There are several ways to ignore code in typescript:&lt;/p&gt;

&lt;h3&gt;
  
  
  Ignore code line with &lt;code&gt;@ts-ignore&lt;/code&gt; rule:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;this will ignore the code that is one line below&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// @ts-ignore
const myAge : number = "25" // no typescript error
const isTrue : boolean = 4; // error
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Usually this would throw an error about variable myAge not being type of number, but with &lt;code&gt;@ts-ignore&lt;/code&gt; this error will be ignored.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ignore code block with &lt;code&gt;@ts-nocheck&lt;/code&gt;:
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// @ts-nocheck
const myAge : number = "25" // no error
const isTrue : boolean = 4; // no error
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🚨🚨&lt;code&gt;@ts-nocheck&lt;/code&gt; will ignore the file, so if you want to ignore typescript checking on one function put it in separate file🚨🚨&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This typescript rule should be used at the top of the file and it will ignore all code in the file.&lt;/p&gt;

&lt;p&gt;**Typescript is meant to be helpful and allows us to write more robust, better structured code. Also it helps us to catch errors early, so use &lt;code&gt;@ts-ignore&lt;/code&gt; and &lt;code&gt;@ts-nocheck&lt;/code&gt; rules with caution.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
