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

# 변수

예를 들어 타입스크립트에게 [`process` 변수](https://nodejs.org/api/process.html) 에 대해 알려주기 위해 이렇게 할 수 있습니다:

```typescript
declare var process: any;
```

> 하지만 [커뮤니티에서 `node.d.ts` 를 관리하고 있기 때문에](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/index.d.ts) `process` 에 대해서 이런 식으로 정의할 필요가 없습니다.

따라서 `process` 변수를 Typescript 에서 따로 선언하지 않고 사용할 수 있습니다:

```typescript
process.exit();
```

우리는 아래와 같이 interface 를 쓰는 것을 추천합니다:

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

이는 글로벌 변수들을 *extend* 할 수 있게 하면서도, 타입스크립트가 글로벌 변수의 변경사항에 대해 알 수 있게 합니다. 예를 들어, 다음의 예제는 필요에 의해 process 에 `exitWithLogging` 함수를 추가한 예제입니다:

```typescript
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, and the optional `goal` query parameter:

```
GET https://radlohead.gitbook.io/typescript-deep-dive/type-system/intro/variables.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
