Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Setting Up TypeScript | Section
TypeScript for Backend Development

bookSetting Up TypeScript

Свайпніть щоб показати меню

To work with TypeScript, you need to install it and configure your project.

TypeScript does not run directly in Node.js. Instead, it compiles into regular JavaScript, which can then be executed.

Installing TypeScript

You can install TypeScript globally using npm:

npm install -g typescript

After installation, you can check the version:

tsc -v

Creating a TypeScript File

Create a new file with the .ts extension:

12
const message: string = "Hello, TypeScript"; console.log(message);
copy

Compiling TypeScript to JavaScript

To convert a TypeScript file into JavaScript, use the TypeScript compiler:

tsc index.ts

This will generate a new file:

index.js

You can then run it with Node.js:

node index.js

Using a tsconfig File

In real projects, TypeScript is configured using a tsconfig.json file.

You can generate it with:

tsc --init

This file defines how TypeScript compiles your code.

For now, you don't need to change much inside it. The default configuration is enough to get started.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 2

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 1. Розділ 2
some-alt