teos
teos
TTCTheo's Typesafe Cult
Created by teos on 9/10/2023 in #questions
Next.js AppRouter: not a valid export field
I've hit a wall when trying to add my own exports in a route.ts, side to side with GET, POST, etc
Type error: Route "app/(server)/api/test/route.ts" does not match the required types of a Next.js Route.
"test" is not a valid Route export field.
Type error: Route "app/(server)/api/test/route.ts" does not match the required types of a Next.js Route.
"test" is not a valid Route export field.
This forces me to have a separate file, that implement everything in exactly the same way, which I then export in route.ts like so:
export { OPTIONS, HEAD, GET, POST, PUT, PATCH, DELETE } from './server'
export { OPTIONS, HEAD, GET, POST, PUT, PATCH, DELETE } from './server'
Have you encountered this ? is there any better practice around it ? From what I can see, it is expected and documented, but I still think that should be allowed to avoid code duplication. So I created a discussion and (draft) PR on Github. I though some here might be interested, and any feedback or upvote would be appreciated
1 replies