Link to the code that reproduces this issue
https://github.com/Thinkscape/form-data-does-not-exist-on-nextrequest
To Reproduce
Formdata type problem
- bun as runtime
- tsconfig
compilerOptions.types = ["bun-types", "web"](example)
- api route handler
req: NextRequest
await req.formData()
Actual
❯ next build
▲ Next.js 14.0.3-canary.4
✓ Creating an optimized production build
✓ Compiled successfully
Linting and checking validity of types ..Failed to compile.
./app/form-data-missing/route.ts:4:26
Type error: Property 'formData' does not exist on type 'NextRequest'.
2 |
3 | export async function POST(req: NextRequest): Promise<any> {
> 4 | const data = await req.formData();
| ^
5 | return NextResponse.json({ data: [...data.entries()] });
6 | }
7 |
Expected
Build succeeds.
Invalid export
- bun as runtime
- tsconfig
compilerOptions.types = ["bun-types", "web"] (example)
- api route handler
return NextResponse.json({});
Actual
❯ next build
▲ Next.js 14.0.3-canary.4
✓ Creating an optimized production build
✓ Compiled successfully
Linting and checking validity of types ..Failed to compile.
app/invalid-return-type/route.ts
Type error: Route "app/invalid-return-type/route.ts" has an invalid export:
"Promise<NextResponse<{ data: any[]; }>>" is not a valid POST return type:
Expected "void | Response | Promise<void | Response>", got "Promise<NextResponse<{ data: any[]; }>>".
Expected "Promise<void | Response>", got "Promise<NextResponse<{ data: any[]; }>>".
Expected "void | Response", got "NextResponse<{ data: any[]; }>".
Expected
Build succeeds.
Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.6.0: Wed Oct 4 21:26:23 PDT 2023; root:xnu-8796.141.3.701.17~4/RELEASE_ARM64_T6000
Binaries:
Node: 21.1.0
npm: 10.2.0
Yarn: 1.22.19
pnpm: 8.3.1
Relevant Packages:
next: 14.0.3-canary.4
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 5.2.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Package manager (npm, pnpm, Yarn), TypeScript (plugin, built-in types)
Additional context
Related to #55623 and oven-sh/bun#463
Link to the code that reproduces this issue
https://github.com/Thinkscape/form-data-does-not-exist-on-nextrequest
To Reproduce
Formdata type problem
compilerOptions.types = ["bun-types", "web"](example)req: NextRequestawait req.formData()Actual
Expected
Build succeeds.
Invalid export
compilerOptions.types = ["bun-types", "web"](example)return NextResponse.json({});Actual
Expected
Build succeeds.
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.6.0: Wed Oct 4 21:26:23 PDT 2023; root:xnu-8796.141.3.701.17~4/RELEASE_ARM64_T6000 Binaries: Node: 21.1.0 npm: 10.2.0 Yarn: 1.22.19 pnpm: 8.3.1 Relevant Packages: next: 14.0.3-canary.4 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/AWhich area(s) are affected? (Select all that apply)
Package manager (npm, pnpm, Yarn), TypeScript (plugin, built-in types)
Additional context
Related to #55623 and oven-sh/bun#463