Getting ready

To use TypeScript in Node.js, we will need to install the typescript library via NPM and save it in our Express package.json file. You will also want to install TypeScript globally so that we can use the tsc command to manually compile our TypeScript files:

npm install typescript --save
npm install typescript -g

Working with TypeScript will also require us to import type definitions for the various libraries we are using for our project. When first getting started, can seem a bit daunting to convert to using TypeScript. If you are already working with many external libraries, you should check out to the definitelyTyped project, to see whether any of the libraries you are using already have type definitions provided:

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types

In our case, many of the modules we are using in Express already have type definitions available for them that we simply need to install them using NPM:

npm install @types/node @types/express @types/morgan @types/body-parser @types/cookie-parser @types/express-session @types/helmet --save
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.102.79