Migrating a nodejs, webpack project from JavaScript to TypeScript


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.

Here are few simple steps:

Add tsconf.js file in the root of your project. Add following configuration to this file

    "compilerOptions": {
        "outDir": "./dist",
        "allowJs": true,
        "target": "es5"
    "include": [
    "exclude": [

npm install awesome-typescript-loader.

npm i awesome-typescript-loader

Add following to your webpack.config.js file

rules:[{ test: /.(t|j)sx?$/, use: { loader: 'awesome-typescript-loader' } },]


 resolve: {
        extensions: ['.ts', '.js'],

Change the source file name from .js to .ts

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.

Once you have fixed the highlighted errors in your source files run your build tool as you normally do.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

A guide to preparing for the IT conference season

Next Post

Purchase fulfilment with Checkout, or “Wait, what was I paid for?”

Related Posts