inngest / inngest-js

The developer platform for easily building reliable workflows with zero infrastructure for TypeScript & JavaScript
https://www.inngest.com/
GNU General Public License v3.0
440 stars 43 forks source link

[BUG] Property does not exist on serve() #340

Closed ellisio closed 1 year ago

ellisio commented 1 year ago

Describe the bug

When upgrading to v3.0.0, we're getting a typing error:

Property 'PUT' does not exist on type '(req: Either<NextApiRequest, NextRequest>, res: NextApiResponse) => Promise<Response | undefined>'.ts(2339)

This is how we have our client defined:

import { serve } from "inngest/next";
import { functions, inngest } from "@/inngest";

export const { GET, POST, PUT } = serve({
  client: inngest,
  functions,
});

To Reproduce Steps to reproduce the behavior:

  1. Install inngest@3.0.0 in a TypeScript NextJS 13 project.
  2. Initialize the client (see above).
    • Note: You can just use an empty functions: [] definition, same thing.

Expected behavior Should not have a typing error.

Code snippets / Logs / Screenshots image

System info (please complete the following information):

jpwilliams commented 1 year ago

Thanks for the report, @ellisio! Sorry you've run into this.

A workaround for the moment is to revert the v2 functionality of treating serve() as any:

export const { GET, POST, PUT } = serve(...) as any;

There's a couple of fixes needed here - one is #339 and the other just needs to be an app router integration test! Let me work on that now. 🙂

ellisio commented 1 year ago

@jpwilliams Was just in the middle of typing out the as any fix myself, thank you!

tonyhb commented 1 year ago

Should be fixed in 3.0.1 - thank you!