TypeScript adds type checking to JavaScript. Start with a compiler installed locally in your project and compile a small file before running its JavaScript output.
What you need
- Node.js and npm
- An editor such as VS Code
- A project folder; the official TypeScript Playground is an alternative
Set up your environment
- Create a folder named
typescript-practiceand open a terminal inside it. - Run
npm init -y, thennpm install --save-dev typescript. - Create hello.ts with the example below. Check
npx tsc --version. - Compile the file to JavaScript and run the generated hello.js with Node.js. A tsconfig.json can be added when you move to a multi-file project.
Your first check
Save as hello.ts
const greeting: string = 'Hello from w1coding.com';
console.log(greeting);Run or verify
npx tsc hello.ts --target es2020
node hello.jsExpected result: The generated JavaScript prints Hello from w1coding.com.
Common setup problems
- Node.js executes the generated JavaScript in this workflow; TypeScript types are checked by tsc.
- Use the local compiler through npx to avoid unintentionally mixing project compiler versions.
Official documentation
Guide reviewed 17 November 2026. Check the linked vendor documentation for current supported versions and operating systems.