LoginSignup
0
0

More than 3 years have passed since last update.

@nuxt/contentの型補完が効かないとき

Posted at

はじめに

@nuxt/contentを活用するとmarkdownで簡単にページが作れるようになります。
今回TypeScriptで書きましたが、下記のエラーで若干迷ったのでメモです。

Property '$content' does not exist on type 'Context'.

これは単純に型定義が足りていないことによる結果です。

型定義を追加する。

Nuxt.jsのプラグインに対応する型定義を読み込むには、tsconfig.jsonのtypesに次のような感じで追記します。

tsconfig.json
{
  "compilerOptions": {
    "types": [
      "@nuxt/types",
+     "@nuxt/content"
    ]
  }
}

参考

Property $axios does not exist on type 'CombinedVueInstance plugin nuxt · Issue #335 · nuxt/typescript

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0