JunyaAndooo / distribution-site-by-next

distribution-site-by-next
1 stars 1 forks source link

search.tsxでのコンパイルエラー #17

Closed sano-suguru closed 4 years ago

sano-suguru commented 4 years ago

getinitialPropsに代入する非同期メソッドの引数でPropsを受け取らなければならないが型が一致してないように見える

image

Creating an optimized production build  

Failed to compile.

~/distribution-site-by-next/src/pages/search.tsx
ERROR in /Users/sano/Desktop/distribution-site-by-next/src/pages/search.tsx(8,7):
8:7 Type '{ (prop: WithRouterProps): JSX.Element; getInitialProps(): Promise<{ title: string; }>; }' is not assignable to type 'NextComponentType<NextPageContext, WithRouterProps & PageProps, WithRouterProps & PageProps>'.
  Type '{ (prop: WithRouterProps): JSX.Element; getInitialProps(): Promise<{ title: string; }>; }' is not assignable to type 'FunctionComponent<WithRouterProps & PageProps> & { getInitialProps?(context: NextPageContext): (WithRouterProps & PageProps) | Promise<...>; }'.
    Type '{ (prop: WithRouterProps): JSX.Element; getInitialProps(): Promise<{ title: string; }>; }' is not assignable to type '{ getInitialProps?(context: NextPageContext): (WithRouterProps & PageProps) | Promise<WithRouterProps & PageProps>; }'.
      The types returned by 'getInitialProps(...)' are incompatible between these types.
        Type 'Promise<{ title: string; }>' is not assignable to type '(WithRouterProps & PageProps) | Promise<WithRouterProps & PageProps>'.
          Type 'Promise<{ title: string; }>' is not assignable to type 'Promise<WithRouterProps & PageProps>'.
            Type '{ title: string; }' is not assignable to type 'WithRouterProps & PageProps'.
              Property 'router' is missing in type '{ title: string; }' but required in type 'WithRouterProps'.
     6 |  * Content
     7 |  */
  >  8 | const Search: NextPage<WithRouterProps & PageProps> = (
       |       ^
     9 |   prop: WithRouterProps
    10 | ) => {
    11 |   return (

> Build error occurred
Error: > Build failed because of webpack errors
    at build (/Users/sano/Desktop/distribution-site-by-next/node_modules/next/dist/build/index.js:13:917)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.