<?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: jo</title>
    <description>The latest articles on DEV Community by jo (@jokatty).</description>
    <link>https://dev.to/jokatty</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%2F901531%2Fabc7c155-a645-46a7-880a-735d3e6ee700.jpeg</url>
      <title>DEV Community: jo</title>
      <link>https://dev.to/jokatty</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jokatty"/>
    <language>en</language>
    <item>
      <title>Migrating a nodejs, webpack project from JavaScript to TypeScript</title>
      <dc:creator>jo</dc:creator>
      <pubDate>Thu, 11 Aug 2022 13:35:00 +0000</pubDate>
      <link>https://dev.to/jokatty/migrating-a-nodejs-webpack-project-from-javascript-to-typescript-2ckm</link>
      <guid>https://dev.to/jokatty/migrating-a-nodejs-webpack-project-from-javascript-to-typescript-2ckm</guid>
      <description>&lt;p&gt;Hi, I'm not used to writing blog posts but recently I was looking for ways to migrate my nodeJs project from Javascript to typescript. I realised there are not many articles for projects that uses webpack.This is my attempt to share my learnings in this topic.&lt;/p&gt;

&lt;p&gt;Here are few simple steps:&lt;/p&gt;

&lt;p&gt;Add tsconf.js file in the root of your project. Add following configuration to this file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "compilerOptions": {
        "outDir": "./dist",
        "allowJs": true,
        "target": "es5"
    },
    "include": [
        "./src/**/*"
    ],
    "exclude": [
        "node_modules"
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;npm install awesome-typescript-loader.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i awesome-typescript-loader
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add following to your &lt;code&gt;webpack.config.js&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module{
rules:[{ test: /\.(t|j)sx?$/, use: { loader: 'awesome-typescript-loader' } },]

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

&lt;/div&gt;



&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; resolve: {
        extensions: ['.ts', '.js'],
    },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the source file name from &lt;code&gt;.js to .ts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Changing the file extension to .ts will highlight some type errors in your file. I would recommend going through a basic tutorial for typescript to understand why you are getting those type errors. And how to fix them. &lt;/p&gt;

&lt;p&gt;Once you have fixed the highlighted errors in your source files run your build tool as you normally do.&lt;/p&gt;

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