Skip to content

Latest commit

 

History

History
50 lines (32 loc) · 1.42 KB

File metadata and controls

50 lines (32 loc) · 1.42 KB

TYPESCRIPT

DESCRIPTION

EXAMPLE AND INSTRUCTIONS TO CONFIGURE:

  • TYPESCRIPT: A SYNTACTIC SUPERSET OF JAVASCRIPT WHICH ADDS OPTIONAL STATIC TYPING TO THE LANGUAGE.

PREREQUISITES

  • NODEMON: FOLLOW THE INSTRUCTIONS HERE.

REQUIRED PACKAGES

npm install -D typescript
npm install -D @types/node

CONFIGURATIONS

  • CREATE tsconfig.json:

    npx tsc --init --allowSyntheticDefaultImports true --lib ES2021 --module ES2020 --moduleResolution node --target ES2021 --rootDir ./folderSource --outDir ./folderDist --removeComments true --resolveJsonModule true --types node
  • RESTART VSCODE.

  • IF YOU ARE USING GIT, ADD folderDist AS A NEW LINE IN .gitignore.

EXAMPLE WITH TYPESCRIPT AND NODE

npx tsc # TRANSPILE ALL _.ts_ FILES IN _folderSource_ TO _.js_ FILES IN _folderDist_
node ./folderDist/folderTopics/folderTypescript/exampleTypescript.js

CONFIGURATIONS TO RUN TYPESCRIPT WITH NODEMON

CREATE THE COMMAND npm run tsc-nodemon BY ADDING THE FOLLOWING LINES TO THE script ENTRY IN package.json:

"tsc-nodemon": "nodemon --exec \"tsc --skipLibCheck && node %npm_config_jsfile%\"",

EXAMPLE WITH TYPESCRIPT AND NODEMON

npm run tsc-nodemon --jsfile=./folderDist/folderTopics/folderTypescript/exampleTypescript.js