@hatano99jp

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

next.jsでbuild時のみ型エラー

解決したいこと

next.jsのバージョン13.4.19にてAPPルーティングを使用しています
/product/[id]/page.tsx
にページを作成したところnpm run devではエラーはないのですが
build時にエラーがでます。
neverで型があたっているところに別の型が代入されるというエラーに見えるのですが
正しい回避方法がわからずご教示いただけると助かります

発生している問題・エラー

Type error: Type 'OmitWithTag<typeof import("xxxx app/src/app/product/[id]/page"), "metadata" | "default" | "config" | "generateStaticParams" | "revalidate" | ... 6 more ... | "generateMetadata", "">' does not satisfy the constraint '{ [x: string]: never; }'.
  Property 'getStaticPaths' is incompatible with index signature.
    Type '() => { paths: { params: { id: string; }; }[]; fallback: boolean; }' is not assignable to type 'never'.

   6 | 
   7 | // Check that the entry is a valid entry
>  8 | checkFields<Diff<{
     |             ^
   9 |   default: Function
  10 |   config?: {}
  11 |   generateStaticParams?: Function```

該当するソースコード

import { GetStaticPaths, GetStaticProps } from "next";

export default function Page({ params }: { params: { id: string } }) {

  return <div>My Post: {params.id}hoge</div>;
}


export const getStaticPaths: GetStaticPaths = async () => {

  // すべての可能なidを含むパスを生成
  const paths = ["aaaa", "bbbb", "cccc"].map((id) => ({
    params: { id },
  }));

  return { paths, fallback: false };
};


0 likes

1Answer

Comments

  1. @hatano99jp

    Questioner

    解決しました!
    ありがとうございます。

Your answer might help someone💌