Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js v15 support #225

Open
Arsik0153 opened this issue Oct 22, 2024 · 6 comments
Open

Next.js v15 support #225

Arsik0153 opened this issue Oct 22, 2024 · 6 comments

Comments

@Arsik0153
Copy link

Please, add Next.js v15.0 support.

@crivera
Copy link

crivera commented Oct 22, 2024

Got this error when trying to run zsa-openapi

Type error: Route "src/app/api/v1/[[...openapi]]/route.ts" has an invalid "POST" export:
  Type "{ params?: Record<string, string> | undefined; } | undefined" is not a valid type for the function's second argument.
    Expected "RouteContext", got "{ params?: Record<string, string> | undefined; } | undefined".
      Expected "RouteContext", got "undefined".
      

@Kuzry
Copy link

Kuzry commented Nov 7, 2024

I have an error at build time:

unhandledRejection Error: Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:
  - react:      18.3.1
  - react-dom:  19.0.0-rc-66855b96-20241106

This occurs when i install zsa-openapi

@Pulstura
Copy link

Got this error when trying to run zsa-openapi

Type error: Route "src/app/api/v1/[[...openapi]]/route.ts" has an invalid "POST" export:
  Type "{ params?: Record<string, string> | undefined; } | undefined" is not a valid type for the function's second argument.
    Expected "RouteContext", got "{ params?: Record<string, string> | undefined; } | undefined".
      Expected "RouteContext", got "undefined".
      

I've got a similar error message to that, except it only occurs during build and I'm using createRouteHandlersForAction

@Kuzry
Copy link

Kuzry commented Nov 29, 2024

Got this error when trying to run zsa-openapi

Type error: Route "src/app/api/v1/[[...openapi]]/route.ts" has an invalid "POST" export:
  Type "{ params?: Record<string, string> | undefined; } | undefined" is not a valid type for the function's second argument.
    Expected "RouteContext", got "{ params?: Record<string, string> | undefined; } | undefined".
      Expected "RouteContext", got "undefined".
      

There is workaround for this:

const nextConfig = {
  typescript: {
    ignoreBuildErrors: true,
  },
};

I think ZSA is great! But two month without any commit? Or any fix for Next.js 15? It hurts right in my meow meow.

@r0skar
Copy link

r0skar commented Dec 3, 2024

There is workaround for this

It's not really a work-around. You are just suppressing build-time errors that will blow up in runtime.

@muharu
Copy link

muharu commented Dec 10, 2024

If you guys just coming here, i have better temporary fix for typed error instead suppress the nextjs typescript ignoreBuildErrors

import { createRouteHandlers } from "zsa-openapi";
import { router } from "./_router/index.router";

// Define the expected type for Next.js route handlers for temporary fix
// See: https://github.com/IdoPesok/zsa/issues/225
type NextApiHandler = (request: Request) => Response | Promise<Response>;

// Create the route handlers
const handler = createRouteHandlers(router, {
  shapeError: (error) => {
    const code = JSON.parse(error.data).code;
    return new Response(JSON.stringify({ code, message: error.message }), {
      status: code,
    });
  },
});

export const GET = handler.GET as NextApiHandler;
export const POST = handler.POST as NextApiHandler;
export const PUT = handler.PUT as NextApiHandler;
export const DELETE = handler.DELETE as NextApiHandler;
export const PATCH = handler.PATCH as NextApiHandler;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants