> For the complete documentation index, see [llms.txt](https://artfulbits-se.gitbook.io/typescript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://artfulbits-se.gitbook.io/typescript/type-system/intro/variables.md).

# Variables

Наприклад, щоб повідомити TypeScript про [`process` variable](https://nodejs.org/api/process.html) you *можете* зробити:

```ts
declare var process: any;
```

> Вам *потрібно* робити це для `process`, оскільки вже існує [community maintained `node.d.ts`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/index.d.ts).

Це дозволяє вам використовувати змінну `process` без скарг TypeScript:

```ts
process.exit();
```

Ми рекомендуємо використовувати інтерфейс, де це можливо, наприклад:

```ts
interface Process {
    exit(code?: number): void;
}
declare var process: Process;
```

Це дозволяє іншим людям *розширити* природу цих глобальних змінних, водночас повідомляючи TypeScript про такі зміни. наприклад Розглянемо наступний випадок, коли ми додаємо функцію `exitWithLogging` для обробки для нашої коду:

```ts
interface Process {
    exitWithLogging(code?: number): void;
}
process.exitWithLogging = function() {
    console.log("exiting");
    process.exit.apply(process, arguments);
};
```

Далі розглянемо інтерфейси трохи докладніше.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://artfulbits-se.gitbook.io/typescript/type-system/intro/variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
