Hi Everyone, I found two ways to run a typescript file
The solution that I found out after facing an issue after switching from javascript to Typescript:-
FirstWay:-
- Make a file with the extension .ts like you make js file name.js same as name.ts
- if you want to run just use this in the terminal like =>> this command =>(tsc filename.ts)
- It will automatically generate a new file with the converted code of typescript into javascript like new.ts=>new.js
- then run your file as always you run like (node new.js) if you are using vs code
- This is a very long process so try the Second way it is easy as I m a beginner I face this issue so I thought to share this problem
Second Way:-
- first install :-npm i typescript --save-dev
- initialize npx tsc --init
- make a file using a .ts extension like filename.ts
- Run this command in the terminal:- npx ts-node filename.ts