Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/ja/guide/lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
:::

```sh
npm i -D @nuxtjs/eslint-config-typescript
# または
yarn add -D @nuxtjs/eslint-config-typescript
# または
npm i -D @nuxtjs/eslint-config-typescript
```

そして、 ESLint設定ファイル `.eslintrc.js` を作成または編集して `@nuxtjs/eslint-config-typescript` を extends に入れます :
Expand Down
26 changes: 23 additions & 3 deletions docs/ja/guide/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ npm install @nuxt/typescript-runtime
"start": "nuxt-ts start"
},
"dependencies": {
"@nuxt/typescript-runtime",
"nuxt"
"@nuxt/typescript-runtime": "latest",
"nuxt": "latest"
},
"devDependencies": {
"@nuxt/typescript-build"
"@nuxt/typescript-build": "latest"
}
```

Expand All @@ -42,3 +42,23 @@ Nuxt.js の edge バージョン(**nuxt-edge**)を使用しているなら
:::

これで、**nuxt.config** ファイル、ローカルの **modules** および **serverMiddlewares** で TypeScript を使用できるようになりました。

::: warning

`@nuxt/typescript-runtime` はプログラムによる使用をサポートしていません(`@nuxt/cli` を拡張しているため)。

上級ユーザーは、サーバーエントリーポイントに次のコードを追加することができます( [source](https://github.com/nuxt/typescript/blob/master/packages/typescript-runtime/src/index.ts) を参照してください):

```js
import { register } from 'ts-node'

register({
project: 'tsconfig.json',
compilerOptions: {
module: 'commonjs'
}
})
```

ただし、この方法は**推奨またはサポートされていません**。
:::
26 changes: 26 additions & 0 deletions docs/ja/guide/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ export default {
}
```

また、以下の型宣言を追加し Vue ファイルの型を提供する必要があります:

`vue-shim.d.ts`:
```ts
declare module "*.vue" {
import Vue from 'vue'
export default Vue
}
```

::: tip
`@nuxt/typescript-build` は `@nuxt/types` を同梱しているため、それぞれをインストールする必要はありません。
:::
Expand All @@ -71,6 +81,22 @@ export default {
さまざまなコンパイラオプションについては、公式の [TypeScript ドキュメント](https://www.typescriptlang.org/docs/handbook/compiler-options.html)を確認してください。
:::

::: warning

独自のサーバーフレームワークで Nuxt をプログラムにより使用している場合、ビルドを行う前に Nuxt の準備ができるまで待機する必要があることに注意してください:

```js

// Make sure to wait for Nuxt to load @nuxt/typescript-build before proceeding
await nuxt.ready()
...
if (config.dev) {
const builder = new Builder(nuxt)
await builder.build()
}
```
:::

これで **layouts**、**components**、**plugins** と **middlewares** で TypeScript が使えるように設定できました。

[**CookBook**](../cookbook/components/) セクションで Nuxt プロジェクトの TypeScript レシピをみることができます。
Expand Down