pingdotgg/uploadthing

[bug]: GET and POST route handler from createRouteHandler does not satisfy the constraint 'ParamCheck<NextRequest | Request>'.

Closed this issue ยท 4 comments

Provide environment information

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 584.21 MB / 15.74 GB
  Binaries:
    Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.4.0 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @uploadthing/react: ^6.7.2 => 6.7.2
    typescript: ^5 => 5.5.4
    uploadthing: ^6.13.2 => 6.13.2

Describe the bug

import { createRouteHandler } from "uploadthing/server";
import { fileRouter } from "./core";

export const { GET, POST } = createRouteHandler({
  router: fileRouter,
})
Type error: Type '{ __tag__: "GET"; __param_position__: "first"; __param_type__: Request | { request: Request; }; }' does not satisfy the constraint 'ParamCheck<NextRequest | Request>'.
  Types of property '__param_type__' are incompatible.
    Type 'Request | { request: Request; }' is not assignable to type 'NextRequest | Request'.
      Type '{ request: Request; }' is not assignable to type 'NextRequest | Request'.

  31 |     Diff<
  32 |       ParamCheck<Request | NextRequest>,
> 33 |       {
     |       ^
  34 |         __tag__: 'GET'
  35 |         __param_position__: 'first'
  36 |         __param_type__: FirstArg<MaybeField<TEntry, 'GET'>>

Link to reproduction

https://stackblitz.com/edit/github-n44ttb?file=with-nextjs%2Fnextjs-error%2Fpackage.json

To reproduce

create route handler as same as example and build project

Additional information

No response

๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributing

  • ๐Ÿ™‹โ€โ™‚๏ธ Yes, I'd be down to file a PR fixing this bug!

Code of Conduct

  • I agree to follow this project's Code of Conduct

What server are you using?

What server are you using?

Next.js 14

@markflorkowski
i added the repo

If you are using Next, you should be importing from the uploadthing/next path

-import { createRouteHandler } from "uploadthing/server";
+import { createRouteHandler } from "uploadthing/next";