Type 'NextResponse<unknown>' is not assignable to type 'Request | NextRequest'.
Unanswered
Atlantic horse mackerel posted this in #help-forum
Atlantic horse mackerelOP
I'm getting the error below when I try to build my nextjs app, everything works just fine in dev mode and I've been trying to fix this for two days with no luck, I would appreciate it anyone could have a lead on what's going on:
.next/types/app/api/guild/[id]/members/route.ts:33:7
Type error: Type '{ __tag__: "GET"; __param_position__: "first"; __param_type__: NextResponse<unknown>; }' does not satisfy the constraint 'ParamCheck<Request | NextRequest>'.
Types of property '__param_type__' are incompatible.
Type 'NextResponse<unknown>' is not assignable to type 'Request | NextRequest'.
31 | Diff<
32 | ParamCheck<Request | NextRequest>,
> 33 | {
| ^
34 | __tag__: 'GET'
35 | __param_position__: 'first'
36 | __param_type__: FirstArg<MaybeField<TEntry, 'GET'>>
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
3 Replies
what is the code for the file that is giving this issue
Atlantic horse mackerelOP
The funny fact with this is it's happening in the .next folder
so not something i can interact with, but the file from my code base causing it is:
import { getServerSession } from "next-auth";
import { Routes } from "discord-api-types/v10";
import { options } from "@/app/api/auth/[...nextauth]/options";
import { REST } from "@discordjs/rest";
import { Guild } from "@/types";
import { NextResponse } from "next/server";
const handler = async (
req: NextResponse,
{ params }: { params: { id: string } }
) => {
try {
const id = params.id;
if (!id)
return NextResponse.json({
status: 400,
message: "Invalid or missing Guild ID",
});
const session = await getServerSession(options);
const accessToken = session?.user?.token || "";
const userRest = new REST({ version: "10", authPrefix: "Bearer" }).setToken(
accessToken
);
const response = (await userRest.get(Routes.userGuilds())) as Guild[];
const guild = response.find((g) => g.id === id);
return NextResponse.json(guild);
} catch (error) {
console.error("Error fetching guilds:", error);
return NextResponse.json({ status: 500, message: "Something went wrong" });
}
};
export { handler as GET };