O'Reilly logo

Cross-platform Desktop Application Development: Electron, Node, NW.js, and React by Dmitry Sheiko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting up the development environment for TypeScript

TypeScript makes alluring promises regarding one's development experience. Why not fiddle with the code to see it in practice? First, we have to create a dedicated directory for upcoming samples. We initialize the project by running npm init -y and install typescript as a dev dependency:

npm i -D typescript

In the manifest scripts section, we add a command to compile sources with TypeScript:

package.json

{ 
... 
"scripts": { 
    "build": "tsc" 
  }, 
... 
} 

We need to let TypeScript know what exactly we want from it. We will describe that in the configuration file:

tsconfig.json

 { "compilerOptions": { "target": "ES6", "module": "CommonJS", "moduleResolution": "node", "sourceMap": true, "outDir": ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required