gukbi

TypeScript

Compile & Run

Install

npm i typescript @types/node

Init

npx tsc --init

Code

// app.ts
function greet(name:string):string {
    return `Hello, ${name}!`;
}
console.log(greet("TypeScript"));

Compile

npx tsc app.ts

Run

node app.js

Just Run

Install

npm i ts-node typescript @types/node

Init

npx tsc --init

Code

// app.ts
function greet(name:string):string {
    return `Hello, ${name}!`;
}
console.log(greet("TypeScript"));

Run

npx ts-node app.ts