Установка
Установка Node.js
// Windows
choco install -y nodejs.install
// macOS
brew install node
Установка TypeScript
npm install -g typescript
yarn global add typescript
pnpm add -g typescript
# Обновление
npm update -g typescript
# Проверка версии
tsc -v
Hello World
- Создай директорию
HelloWorld - Создай файл
hello.ts - Напиши код:
let message: string = 'Hello World'
console.log(message)
- Скомпилируй:
tsc hello.ts - Запусти:
node hello.js
ℹ️ Компиляция
Компиляция создаёт .js файл из TypeScript. Перекомпилируй после каждого изменения, или используй Nodemon или режим наблюдения tsc --watch.