How to setup TypeScript and use in a normal JavaScript project for learning purposes.
mkdir lab-tscd lab-tsgit inittouch .gitignore. Addnode_modulesanddistto the file.npm init --yes
npm install typescript
npx tsc --init
Inside tsconfig.json, set the following:
"rootDir": "./src""outDir": "./dist"
- Create a folder
src. - Create a file
src/index.ts. - Write a
console.log('Hello!');statement inside the file. npx tsc- Check the build output in the
buildfolder. node build/index.js