Compile TypeScript with npm

Npm package.json scripts can be used to run various commands. Here, we will learn how to run the TypeScript compiler to generate JavaScript output from TypeScript source files. Before we start, make sure you have Node.js and npm installed.


In a new folder, create a file named script.ts. Then, add some sample code so we can test whether the JavaScript output is being…