Help us understand the problem. What is going on with this article?

nuxt+Typescriptで「Property 'component' does not exist on type 'RouteConfig'」のエラーを直す

image.png

nuxtで普通にTypescriptのプロジェクトを作成すると,いきなりエラー出てびっくりした.

エラーメッセージはこんな感じ

・・・
・・・
Property 'component' does not exist on type 'RouteConfig'.

    12 |   chunkName?: string
    13 |   chunkNames?: Record<string, string>
  > 14 |   component?: RouteConfig['component'] | string
       |                           ^
    15 | }
    16 | 
    17 | export interface NuxtConfigurationRouter extends RouterOptions {
・・・
・・・

調べてみると,すでに解決済みっぽい

Githubのissueにこんなものがあった.

vue-router breaks nuxt/types #7502

解決方法としては,

tsconfig.jsonの中にある@nuxt/typesをちょっとだけ書き換える

変更後

・・・
    "types": [
      "@types/node",
      "@nuxt/types@0.7.9+"
    ]
・・・

これだけ.

誰かの参考になれば

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away