Skip to content

Commit 5c01648

Browse files
committed
Translate docs/quick/library.md.
1 parent 6e9b0e2 commit 5c01648

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/quick/library.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
TypeScriptで書かれたモジュールを使用することは、コンパイル時の安全性とオートコンプリートが得られるので、非常に楽しいことです。
66

7-
TypeScript modules can be consumed both in the nodejs (as is) browser (with something like webpack).
7+
TypeScriptのモジュールは、Node.jsではそのまま使用でき、ブラウザでもWebpackなどを使うことで利用できるようになります。
88

99
高品質のTypeScriptモジュールの作成は簡単です。以下の望ましいフォルダ構造を仮定します。
1010

@@ -26,37 +26,37 @@ package
2626
└─ ... All your compiled files (Generated)
2727
```
2828

29-
* `src/index.ts`: Here you would export anything you expect to be consumed from your project. E.g `export { Foo } from './foo';`. Exporting from this file makes it available for consumption when someone does `import { /* Here */ } from 'example';`
29+
* `src/index.ts`: ここでは、他のプロジェクトから使用できるようにしたいすべてのものをexportします。たとえば、`export { Foo } from './foo';`などを書きます。このファイルからexportしたオブジェクトは、このライブラリを使用する他の人が `import { /* Here */ } from 'example';` のように書いてimportすることができるようになります。
3030

3131
* `tsconfig.json`について
32-
* `compilerOptions``"outDir": "lib"`と、`"declaration": true``"declarationMap" : true`を設定します < これはlibフォルダに`.js` (JavaScript) `.d.ts` (declarations for TypeSafety) and `.d.ts.map` (enables `declaration .d.ts` => `source .ts` IDE navigation)生成します
32+
* `compilerOptions``"outDir": "lib"`と、`"declaration": true``"declarationMap" : true`を設定します < これは、libフォルダに`.js` (JavaScript)`.d.ts` (型安全性のための型宣言)と`.d.ts.map` (このファイルは、IDE上で`declaration .d.ts` => `source .ts`というナビゲーションを可能にします)が生成されます
3333
* `include: ["src"]`を設定します < これは`src`ディレクトリからのすべてのファイルを対象に含めます
3434

3535
* `package.json`について
36-
* `"main": "lib/index"` <これはNode.jsに`lib/index.js`をロードするように指示します
37-
  * `"types": "lib/index"` <これはTypeScriptに`lib/index.d.ts`をロードするように指示します
36+
* `"main": "lib/index"` < これはNode.jsに`lib/index.js`をロードするように指示します
37+
  * `"types": "lib/index"` < これはTypeScriptに`lib/index.d.ts`をロードするように指示します
3838

3939

4040
パッケージの例:
4141
* `npm install typestyle` [for TypeStyle](https://www.npmjs.com/package/typestyle)
4242
* 使用法:`import { style } from 'typestyle';`は、完全な型安全性を提供します
4343

44-
### Managing Dependencies
44+
### Dependenciesの管理
4545

4646
#### devDependencies
4747

48-
* If your package depends on another package while you are developing it (e.g. `prettier`) you should install them as a `devDependency`. This way they will not pollute the `node_modules` of your module's consumers (as `npm i foo` does not install `devDependencies` of `foo`).
49-
* `typescript` is normally a `devDependency` as you only use it to build your package. The consumers can use your package with or without TypeScript.
50-
* If your package depends on other JavaScript authored packages and you want to use it with type safety in your project, put their types (e.g. `@types/foo`) in `devDependencies`. JavaScript types should be managed *out of bound* from the main NPM streams. The JavaScript ecosystem breaks types without semantic versioning too commonly, so if your users need types for these they should install the `@types/foo` version that works for them. If you want to guide users to install these types you can put them in `peerDependencies` mentioned next.
48+
* パッケージの開発中にのみ他のパッケージに依存している場合(例: `prettier`)、依存するパッケージは`devDependency`に追加します。こうすることで、あなたのパッケージを使用するユーザーの`node_modules`には開発用の依存パッケージをインストールしないようにできます(`npm i foo`というコマンドを実行した場合には、`foo`のdevDependencies`はインストールされないためです)。
49+
*`typescript`は通常パッケージのビルド時にのみ使用されるため、`devDependency`に追加します。パッケージのユーザーはTypeScriptなしでもあなたのパッケージを利用できます。
50+
* あなたのパッケージがJavaScriptで作られた他のパッケージに依存していて、あなたのプロジェクトでは型安全性を活用したい場合には、依存しているパッケージの型パッケージ(例: `@types/foo`)`devDependencies`に追加してください。JavaScriptの型は、メインのNPMエコシステムの*外側で*管理されています。JavaScriptエコシステムでは、セマンティックバージョニングを使用していない場合には特に、型が破壊されるのは日常茶飯事です。そのため、ユーザーが型を使用したい場合には、自分でパッケージに適したバージョンの型`@types/foo`をインストールする必要があります。型パッケージをインストールするようにユーザーに支持したい場合には、次のセクションに示すように、パッケージを`peerDependencies`に追加します。
5151

5252
#### peerDependencies
5353

54-
If your package depends on a package that it heavily *works with* (as opposed to *works using*) e.g. `react`, put them in `peerDependencies` just like you would with raw JS packages. To test them locally you should also put them in `devDependencies`.
54+
あなたのパッケージが依存するパッケージで、(*インストールしないと動作しない*というわけではなく)同時にインストールしたときに*よりよく動作する*というようなパッケージがある場合には、生のJSパッケージでするのと同じように、そのパッケージを`peerDependencies`に追加してください(たとえば、`react`など)。ローカルでテストする場合にも、`devDependencies`に追加する必要があります。
5555

56-
Now:
57-
* When you are developing the package you will get the version of the dependency you specified in your `devDependencies`.
58-
* When someone installs your package they will *not* get this dependency (as `npm i foo` does not install `devDependencies` of `foo`) but they will get a warning that they should install the missing `peerDependencies` of your package.
56+
このように設定を行うことで、次のように動作するようになります。
57+
* パッケーの開発中は、`devDependencies`で指定したバージョンのパッケージがインストールされます。
58+
* 他のユーザーがあなたのパッケージをインストールした場合には、`devDependencies`で指定されたパッケージはインストール*されません*が、あなたのパッケージの`peerDependencies`に指定されているパッケージが存在しない場合には、ユーザーにそのパッケージをインストールするべきであるという警告が表示されます。
5959

6060
#### dependencies
6161

62-
If your package *wraps* another package (meant for internal use even after compilation) you should put them in `dependencies`. Now when someone installs your package they will get your package + any of its dependencies.
62+
あなたのパッケージが他のパッケージの*ラッパー*である場合(つまり、TypeScriptのコンパイル後にも内部で他のライブラリを使用する場合)には、そのパッケージは`dependencies`に追加しなければなりません。そうすることで、あなたのパッケージをインストールしたユーザーはあなたのパッケージに加えて、その依存パッケージを同時にインストールできるようになります。

0 commit comments

Comments
 (0)