<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gregor Plavčak on Medium]]></title>
        <description><![CDATA[Stories by Gregor Plavčak on Medium]]></description>
        <link>https://medium.com/@GregorPlavcak?source=rss-1ac35ff89e18------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ttijo8QDLlyQn7m1.jpg</url>
            <title>Stories by Gregor Plavčak on Medium</title>
            <link>https://medium.com/@GregorPlavcak?source=rss-1ac35ff89e18------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:42:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@GregorPlavcak/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to create a new TypeScript project]]></title>
            <link>https://medium.com/@GregorPlavcak/how-to-create-a-new-typescript-project-a15cea2c7a45?source=rss-1ac35ff89e18------2</link>
            <guid isPermaLink="false">https://medium.com/p/a15cea2c7a45</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Gregor Plavčak]]></dc:creator>
            <pubDate>Sat, 03 Nov 2018 14:54:14 GMT</pubDate>
            <atom:updated>2018-11-03T15:11:25.044Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to create a TypeScript project</h3><p>In the following tutorial, we will learn how to create a <strong>TypeScript</strong> project using Visual Studio Code with the Node package manager (npm).</p><p><strong>What you should know?<br> </strong>Basic knowledge of programming, using of Visual Studio Code (VS Code) and executing of shell commands.</p><p><strong>What do you need?</strong><br> <a href="https://code.visualstudio.com/">Visual Studio Code</a> — popular source code editor with a lot of plugins<br> <a href="https://nodejs.org/en/">Node.js</a> — JavaScript interpreter for running JavaScript code on a server</p><p><strong>What is TypeScript?<br> </strong>TypeScript is a superset of JavaScript language. More about TypeScript you can read at official pages. <a href="https://www.typescriptlang.org/">https://www.typescriptlang.org</a></p><h3>1. Install Visual Studio Code</h3><p>We will start by installing the Visual Studio Code (VS Code). You can download the installation package from the official page (<a href="https://code.visualstudio.com/">https://code.visualstudio.com</a>).</p><p>VS Code is available for all popular platforms (Mac OS, Windows, and Linux).</p><p>List of shortcuts is available here <a href="https://code.visualstudio.com/docs/getstarted/keybindings">Key Bindings for Visual Studio Code</a> or printable version:</p><ul><li><a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf">Windows [pdf]</a></li><li><a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf">Mac OS [pdf]</a></li><li><a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf">Linux [pdf]</a></li></ul><h3>2. Install Node.js</h3><p>Next, we need to install Node.js executable. With Node.js installation comes also Node package manager (npm), which enormously simplifies installation of additional Node.js packages. Installations for different platforms are available on an official Node.js page. <a href="https://nodejs.org/">https://nodejs.org</a></p><h3>3. Create a project folder</h3><p>Using the command line, create a new folder where you will add your project files.</p><pre>$ mkdir ts-project</pre><h3>4. Open folder in Visual Studio Code</h3><p>You can run VS Code and browse to a newly created folder or you can run VS Code from the command line.</p><pre>$ cd ts-project $ code .</pre><h3>5. Open command line in VS Code</h3><p>We will use command line tools to compile TypeScript source code and to run our scripts. You can open a new terminal window by selecting <strong><em>Terminal &gt; New Terminal</em></strong> from the top menu.</p><h3>6. Install TypeScript compiler</h3><p>At this point, we will use <strong>npm</strong> to install TypeScript compiler. We will be using the compiler from the command line so we will install it globally (notice the -g flag). This way we will have TypeScript compiler available from the command line system-wide.</p><pre>$ npm install typescript -g</pre><p>For VS Code you can follow detailed instructions on using TypeScript Compiler on an official documentation for VS Code. <a href="https://code.visualstudio.com/docs/languages/typescript">https://code.visualstudio.com/docs/languages/typescript</a></p><p>At this point, we are ready to start coding.</p><h3>7. Create TypeScript compiler configuration</h3><p>Before we can transform TypeScript source code into JavaScript we need to provide some basic settings to the TypeScript compiler. On the root of the project folder, we will create a new file named <strong>tsconfig.json.</strong></p><pre>{ <br>  &quot;compilerOptions&quot;: { <br>    &quot;target&quot;: &quot;es5&quot;, <br>    &quot;module&quot;: &quot;commonjs&quot;, <br>    &quot;declaration&quot;: true, <br>    &quot;sourceMap&quot;: true, <br>    &quot;outDir&quot;: &quot;dist&quot;, <br>    &quot;strict&quot;: true <br>  }, <br>  &quot;include&quot;: [&quot;src/**/*&quot;] <br>}</pre><p>We are telling the compiler to compile our TypeScript code into JavaScript <strong>Ecma 5</strong> specification compatible scripts. With the “module” setting we did specify that our code will be running on a server (<strong>commonjs</strong>) rather in a browser. Also, the compiler will create source map and declaration files.</p><p>We set to include everything under <strong>src</strong> folder (include attribute) and to output compiled files into <strong>dist</strong> folder.</p><h3>8. Hello World</h3><p>Now we will create a simple TypeScript program, which will write to the system out stream. Create a new file <strong>startup.ts</strong> in <strong>src</strong> folder.</p><pre>class Startup { <br>  <br>  public static main():number {<br>   console.log(&#39;Hello World&#39;); <br>   return 0; <br>  } <br>}</pre><pre>Startup.main();</pre><p>Our project’s folder structure should look like this:</p><h3>9. Compile and run</h3><p>Now we can compile our TypeScript source code with a command line.</p><pre>$ tsc</pre><p>For more compiler options, click <a href="https://www.typescriptlang.org/docs/handbook/compiler-options.html">TypeScript Compiler Options</a>.</p><p>We can see that a new folder <strong>dist</strong> has been created, which contains three files: <em>startup.d.ts</em>, <em>startup.js.map, </em>and <em>startup.js.</em></p><p>Using node.js we can run the compiled script.</p><pre>$ node dist\startup.js</pre><h3>Conclusion</h3><p>In this tutorial, we created a basic TypeScript project. We compiled and run a simple script with Node.js.</p><p>This is a simplified use of TypeScript. Projects, like Angular, has a complicated build system that hides simplicity of bare TypeScript.</p><p><em>Originally published at </em><a href="https://plavc.wordpress.com/2018/11/03/how-to-create-a-new-typescript-project/"><em>plavc.wordpress.com</em></a><em> on November 3, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a15cea2c7a45" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>