How to do it...

Let's perform the following steps to convert our Express.js main application file to use TypeScript so that we can use the same JavaScript syntax between our frontend and backend applications:

  1. First, we will want to create a new /src directory for all our application files; this makes compilation a bit more straightforward with our source TypeScript files taken from /src, while our compiled JavaScript output will be put into a generated /dist directory:
mkdir src
  1. Then, we will need to convert our app.js file into a new TypeScript-friendly class definition. We'll start with a new /src/App.ts class file, which will import all our needed libraries using the ES6 module style instead of Node.js's usual CommonJS (require) imports. ...

Get MEAN Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.