Typescript is now well supported in most of the popular tooling and the benefits over native javascript are documented all over the internet. For anyone looking to port a complex application it can still be daunting as most typescript documentation focuses front end development. Documentation about typescript is fairly thin on the ground and most of it focuses on starting a new application. When it comes to migrating an application to typescript, you’ll find most examples focus on a fairly simple express application which does not relate to your project.

If you are planning to migrate to Typescript then below are a couple of pointers. Upgrade Node

  • Ideally you should using at least 6.x LTS however since you are going to be making some big changes, it’s a good time to update to the latest LTS version. Move to ES6+
  • NodeJS has supported ES6 for some time and it means you can take advantage of native features such as promises etc without the need to use native libraries.
  • The typescript compiler will compile down to ES5 or ES6 however it does not manage polyfills so you would need to use babel. If you use Node v6+ you can compile directly to es2016 Keep your tsconfig/tslint simple
  • You may be tempted to put in all the rules that you want to enforce on day one. Don’t!. just add what you need to, to get things moving. You can tighten the screws later as you get more experience and coverage. Migration to Typescript should be done in stages
  • Do not attempt to change your entire code base over night. Make small changes, test them and then push them through the build process to make sure everything end to end works.

Migration will probably highlight areas of code that need to be refactored

  • Javascript allows a lot of flexibility and can be great for getting things out of the door, however the lack of enforced types can leave you with some

Migration will most likely require you change the way to build your application -You can run side by side compilation and tools like webstorm handle this really nicely however on a large product it can get really messy when you are porting a set of existing js files to ts files. -If you build to a distribution folder rather than side by side, you’ll need to update the way you run and debug locally, your deployment scripts and if using docker, your docker file will likely need to be updated. These changes can be a pain but once made you can move forward quickly.

You don’t need to be an expert with typescript to get started. -Once your build routines are setup, you can start updating your project by simple changing the extension from js to ts. On doing that you’ll notice some errors but most of them can be fixed with just a couple of minor changes to the code -If your team have experience with c# then the learning curve is almost negligble Once you’ve migrated to typescript you very likely see a reduction in the time debugging a lot of issues