How to setup TypeScript and use in a normal JavaScript project for learning purposes.
mkdir lab-ts
cd lab-ts
git init
touch .gitignore
. Addnode_modules
anddist
to 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
build
folder. node build/index.js