# グローバル変数の宣言

例えば、[`process`変数](https://nodejs.org/api/process.html)についてTypeScriptに伝える場合：

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

> すでに [コミュニティ](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/index.d.ts) が`node.d.ts`をメンテナンスしているので、`process`のためにこれを行う必要はありません。

これにより、TypeScriptのエラーが発生することなく`process`変数を使うことができます：

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

可能な限りインターフェースを使用することをおすすめします。例：

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

これにより、他の人がこれらのグローバル変数を拡張し、その変更についてTypeScriptに伝えることができます。例えば余興にexitWithLogging関数を追加する次のような場合を考えてみましょう。

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

次はインターフェースを少し詳しく見ていきましょう。


---

# Agent Instructions: 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://typescript-jp.gitbook.io/deep-dive/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.
