Skip to content

Latest commit

 

History

History
93 lines (58 loc) · 1.56 KB

File metadata and controls

93 lines (58 loc) · 1.56 KB

TypeScript

How to install TypeScript

Download Node.js

# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash

# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"

# Download and install Node.js:
nvm install 22

# Verify the Node.js version:
node -v # Should print "v22.15.0".
nvm current # Should print "v22.15.0".

# Verify npm version:
npm -v # Should print "10.9.2".

Install TypeScript

npm install -g typescript

Check Version

tsc -v

Configure tsconfig.json

  1. First install tsc for typescript :
  sudo apt install node-typescript
  1. Generate New tsconfig.json file :
    tsc --init
  1. Configure the file :

Search and Comment out

    "rootDir": "./module1/src/", 

Example : if your path root_directory/module1/src/index.ts

    "outDir": "./module1/dist",

Example : if your path root_directory/module1/dist/index.js

  1. After setup all config then open terminal on root directory and just type tsc and enter. It will generate or updated the js of ts

ts-node-dev install

visit : https://www.npmjs.com/package/ts-node-dev

To see instant changes data in terminal by typescript.

Install Globally

sudo npm i -g ts-node-dev

Run the specific file

ts-node-dev --respawn --transpile-only module1/src/1.11-Ternary-optiona.ts

here my file path loaction is : /var/www/html/typescript-technocrat/module1/src/1.11-Ternary-optiona.ts