Skip to content

Commit 91bf1a9

Browse files
committed
translate file into ja
1 parent 6d8ff94 commit 91bf1a9

File tree

1 file changed

+67
-68
lines changed

1 file changed

+67
-68
lines changed
Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
2-
title: Declaration Reference
2+
title: 宣言リファレンス
33
layout: docs
4-
permalink: /docs/handbook/declaration-files/by-example.html
5-
oneline: "How to create a d.ts file for a module"
4+
permalink: /ja/docs/handbook/declaration-files/by-example.html
5+
oneline: "モジュール用の.d.tsファイルの作り方"
66
---
77

8-
The purpose of this guide is to teach you how to write a high-quality definition file.
9-
This guide is structured by showing documentation for some API, along with sample usage of that API,
10-
and explaining how to write the corresponding declaration.
8+
本ガイドの目的は、すぐれた宣言ファイルの書き方を示すことです。
9+
本ガイドは、ある API の仕様と、その API の使い方の例示で構成されており、
10+
それに対応する宣言の記述方法について解説しています。
1111

12-
These examples are ordered in approximately increasing order of complexity.
12+
以下のサンプルは、複雑度がほぼ高い順に並んでいます。
1313

14-
## Objects with Properties
14+
## プロパティを持つオブジェクト
1515

16-
_Documentation_
16+
_仕様_
1717

18-
> The global variable `myLib` has a function `makeGreeting` for creating greetings,
19-
> and a property `numberOfGreetings` indicating the number of greetings made so far.
18+
> グローバス変数`myLib`は、挨拶を作る`makeGreeting`関数と、
19+
> これまで作られた挨拶の数を示すプロパティ`numberOfGreetings`を持っています。
2020
21-
_Code_
21+
_コード例_
2222

2323
```ts
2424
let result = myLib.makeGreeting("hello, world");
@@ -27,9 +27,9 @@ console.log("The computed greeting is:" + result);
2727
let count = myLib.numberOfGreetings;
2828
```
2929

30-
_Declaration_
30+
_宣言_
3131

32-
Use `declare namespace` to describe types or values accessed by dotted notation.
32+
ドット記法でアクセス可能な型や値を記述するには、`declare namespace`を使います。
3333

3434
```ts
3535
declare namespace myLib {
@@ -38,52 +38,52 @@ declare namespace myLib {
3838
}
3939
```
4040

41-
## Overloaded Functions
41+
## オーバーロードされた関数
4242

43-
_Documentation_
43+
_仕様_
4444

45-
The `getWidget` function accepts a number and returns a Widget, or accepts a string and returns a Widget array.
45+
`getWidget`関数は、数値を受け取って Widget を返したり、あるいは文字列を受け取って Widget の配列を返します。
4646

47-
_Code_
47+
_コード例_
4848

4949
```ts
5050
let x: Widget = getWidget(43);
5151

5252
let arr: Widget[] = getWidget("all of them");
5353
```
5454

55-
_Declaration_
55+
_宣言_
5656

5757
```ts
5858
declare function getWidget(n: number): Widget;
5959
declare function getWidget(s: string): Widget[];
6060
```
6161

62-
## Reusable Types (Interfaces)
62+
## 再利用可能な型 (インターフェース)
6363

64-
_Documentation_
64+
_仕様_
6565

66-
> When specifying a greeting, you must pass a `GreetingSettings` object.
67-
> This object has the following properties:
66+
> `GreetingSettings`オブジェクトを渡して、挨拶を指定します。
67+
> このオブジェクトは次のようなプロパティを持っています:
6868
>
69-
> 1 - greeting: Mandatory string
69+
> 1 - greeting: 必須の文字列
7070
>
71-
> 2 - duration: Optional length of time (in milliseconds)
71+
> 2 - duration: 任意の時間の長さ (ミリ秒単位)
7272
>
73-
> 3 - color: Optional string, e.g. '#ff00ff'
73+
> 3 - color: 任意の文字列 (例: '#ff00ff')
7474
75-
_Code_
75+
_コード例_
7676

7777
```ts
7878
greet({
7979
greeting: "hello world",
80-
duration: 4000
80+
duration: 4000,
8181
});
8282
```
8383

84-
_Declaration_
84+
_宣言_
8585

86-
Use an `interface` to define a type with properties.
86+
`interface`を使用して、プロパティを持つ型を定義します。
8787

8888
```ts
8989
interface GreetingSettings {
@@ -95,13 +95,13 @@ interface GreetingSettings {
9595
declare function greet(setting: GreetingSettings): void;
9696
```
9797

98-
## Reusable Types (Type Aliases)
98+
## 再利用可能な型 (タイプエイリアス)
9999

100-
_Documentation_
100+
_仕様_
101101

102-
> Anywhere a greeting is expected, you can provide a `string`, a function returning a `string`, or a `Greeter` instance.
102+
> 挨拶が期待される場所に対して、`string``string`を返す関数、あるいは`Greeter`インスタンスを与えることができます。
103103
104-
_Code_
104+
_コード例_
105105

106106
```ts
107107
function getGreeting() {
@@ -114,34 +114,34 @@ greet(getGreeting);
114114
greet(new MyGreeter());
115115
```
116116

117-
_Declaration_
117+
_宣言_
118118

119-
You can use a type alias to make a shorthand for a type:
119+
型の省略表現を作るために、タイプエイリアスを使うことができます:
120120

121121
```ts
122122
type GreetingLike = string | (() => string) | MyGreeter;
123123

124124
declare function greet(g: GreetingLike): void;
125125
```
126126

127-
## Organizing Types
127+
## 型の整理
128128

129-
_Documentation_
129+
_仕様_
130130

131-
> The `greeter` object can log to a file or display an alert.
132-
> You can provide LogOptions to `.log(...)` and alert options to `.alert(...)`
131+
> `greeter`オブジェクトは、ファイルにログを記録したり、アラートを表示したりすることができます。
132+
> ログオプションは`.log(...)`に、アラートオプションは`.alert(...)`に与えることができます。
133133
134-
_Code_
134+
_コード例_
135135

136136
```ts
137137
const g = new Greeter("Hello");
138138
g.log({ verbose: true });
139139
g.alert({ modal: false, title: "Current Greeting" });
140140
```
141141

142-
_Declaration_
142+
_宣言_
143143

144-
Use namespaces to organize types.
144+
名前空間を使って型を整理します。
145145

146146
```ts
147147
declare namespace GreetingLib {
@@ -156,11 +156,11 @@ declare namespace GreetingLib {
156156
}
157157
```
158158

159-
You can also create nested namespaces in one declaration:
159+
宣言でネストした名前空間を作ることもできます:
160160

161161
```ts
162162
declare namespace GreetingLib.Options {
163-
// Refer to via GreetingLib.Options.Log
163+
// GreetingLib.Options.Logで参照します
164164
interface Log {
165165
verbose?: boolean;
166166
}
@@ -172,13 +172,13 @@ declare namespace GreetingLib.Options {
172172
}
173173
```
174174

175-
## Classes
175+
## クラス
176176

177-
_Documentation_
177+
_仕様_
178178

179-
> You can create a greeter by instantiating the `Greeter` object, or create a customized greeter by extending from it.
179+
> `Greeter`オブジェクトをインスタンス化して greeter を作成したり、それを拡張してカスタマイズした greeter を作成することができます。
180180
181-
_Code_
181+
_コード例_
182182

183183
```ts
184184
const myGreeter = new Greeter("hello, world");
@@ -192,10 +192,10 @@ class SpecialGreeter extends Greeter {
192192
}
193193
```
194194

195-
_Declaration_
195+
_宣言_
196196

197-
Use `declare class` to describe a class or class-like object.
198-
Classes can have properties and methods as well as a constructor.
197+
クラスやクラスライクなオブジェクトを記述するには、`declare class`を使います。
198+
クラスはコンストラクタだけではなく、プロパティやメソッドを持つことができます。
199199

200200
```ts
201201
declare class Greeter {
@@ -206,46 +206,45 @@ declare class Greeter {
206206
}
207207
```
208208

209-
## Global Variables
209+
## グローバル変数
210210

211-
_Documentation_
211+
_仕様_
212212

213-
> The global variable `foo` contains the number of widgets present.
213+
> グローバル変数`foo`には、存在する widget の数が格納されています。
214214
215-
_Code_
215+
_コード例_
216216

217217
```ts
218218
console.log("Half the number of widgets is " + foo / 2);
219219
```
220220

221-
_Declaration_
221+
_宣言_
222222

223-
Use `declare var` to declare variables.
224-
If the variable is read-only, you can use `declare const`.
225-
You can also use `declare let` if the variable is block-scoped.
223+
変数を宣言するには、`declare var`を使います。
224+
変数が読み取り専用の場合には、`declare const`を使用することができます。
225+
また、変数がブロックスコープに制限される場合は、`declare let`を使うこともできます。
226226

227227
```ts
228-
/** The number of widgets present */
228+
/** 存在する widget の数 */
229229
declare var foo: number;
230230
```
231231

232-
## Global Functions
232+
## グローバル関数
233233

234-
_Documentation_
234+
_仕様_
235235

236-
> You can call the function `greet` with a string to show a greeting to the user.
236+
> 文字列を与えて関数`greet`を呼び出すと、ユーザーに挨拶を表示することができます。
237237
238-
_Code_
238+
_コード例_
239239

240240
```ts
241241
greet("hello, world");
242242
```
243243

244-
_Declaration_
244+
_宣言_
245245

246-
Use `declare function` to declare functions.
246+
関数を宣言するには、`declare function`を使用します。
247247

248248
```ts
249249
declare function greet(greeting: string): void;
250250
```
251-

0 commit comments

Comments
 (0)