npm init --force
npm install typescript --save-dev
npm install typings --save-dev
.\node_modules\.bin\typings install dt~node --global --save
Create or update:
tsconfig.json
allows runningtsc
to build all TypeScript files.package.json
contains npm module dependencies and scripts.typings.json
contains TypeScript typing definition dependencies..gitignore
prevents Git from storing intermediate files produced by build..vscode/tasks.json
define VS Codebuild
task..vscode/launch.json
defines VS Codelaunch
task.src\program.ts
is the application entry point.
git clone https://github.com/olegsych/template.nodets.git
cd template.nodets
npm install
How it works:
- The
npm install
command installs module dependencies and runs theinstall
script defined in thepackage.json
. - The
install
script invokes runs thetypings install
command from thetypings
module restored bynpm
. - The
typings install
command installs TypeScript definitions defined in thetypings.json
.
- VS Code:
Ctrl+Shift+B
- Shell:
npm run build
How it works:
npm
runs thebuild
script defined inpackage.json
to invoke thetsc
command from thetypescript
module.tsc
looks fortsconfig.json
in the current directory and usesoutDir
property to maketsc
generate.js
files in thebuild
subfolder,sourceMaps
to generate.js.map
along with them.
Shell: node build/program.js
How it works:
tsc
compilessrc/program.ts
tobuild/program.js
based on thetsconfig.json
settingsnode
runs the JavaScript inindex.js
VS Code: F5
How it works:
.vsconfig/launch.json
definesLaunch
configurationprogram
property to indicate which.ts
file contains the application entry point,sourceMaps
property to make debugger use.js.map
files,outDir
property to specify where to find them.