Stricter type checking causes pre export modifications to break
Unanswered
Orinoco Crocodile posted this in #help-forum
Orinoco CrocodileOP
In next.js v15, I was able to use decorators, i.e.
to modify the types of a nextjs request, i.e. inject fields into the next request. I've been using this for auth security, using a
Is there any solutions where I can continue modifying the NextRequest payload without build time type checking to fail?
@Xyz()
export const GET ...to modify the types of a nextjs request, i.e. inject fields into the next request. I've been using this for auth security, using a
Security decorator to pre-parse any auth headers/cookies and then populating a req.user field although this no longer works anymore in v16. Type error: Type 'typeof import("/Users/jeff/repo/apps/backend/src/app/api/me/route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/me">'.
Types of property 'GET' are incompatible.
Type '(req: RequestWithUser) => Promise<NextResponse<{ data: Items[]; }> | NextRe
sponse<{ error: string; }>>' is not assignable to type '(request: NextRequest, context: { params: Pro
mise<{}>; }) => void | Response | Promise<void | Response>'.
Types of parameters 'req' and 'request' are incompatible.
Type 'NextRequest' is not assignable to type 'RequestWithUser'.
Property 'user' is missing in type 'NextRequest' but required in type '{ user: User; }'.
Next.js build worker exited with code: 1 and signal: null
[ELIFECYCLE] Command failed with exit code 1.
ERROR: command (/Users/jeff/repo/apps/backend) /Users/jeff/.nvm/versions/node/v24.16.0/bin/pnpm runIs there any solutions where I can continue modifying the NextRequest payload without build time type checking to fail?