[bug]: GET and POST route handler from createRouteHandler does not satisfy the constraint 'ParamCheck<NextRequest | Request>'.
Closed this issue ยท 4 comments
shisui0711 commented
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
markflorkowski commented
What server are you using?
shisui0711 commented
What server are you using?
Next.js 14
shisui0711 commented
@markflorkowski
i added the repo
markflorkowski commented
If you are using Next, you should be importing from the uploadthing/next
path
-import { createRouteHandler } from "uploadthing/server";
+import { createRouteHandler } from "uploadthing/next";