Published: 28 May 2024 › Updated: 28 May 2024

Problem I face :-I am a beginner idk how to run a typescript file
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
Leave Problem I face :-I am a beginner idk how to run a typescript file to:
Read more #beginner posts
Best Posts From jedex99
We have not curated any of jedex99's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.