Open maruffahmed opened 1 year ago
Hey @maruffahmed, Your code is working fine on my computer . Could you upgrade your node version I'm currently running on node -v18.16.0
Hey @maruffahmed, Your code is working fine on my computer . Could you upgrade your node version I'm currently running on node -v18.16.0
@ChandanJal I'm not sure if you already tried to build the above code. My issues were in the build process, my development server also working fine.
And this is my concern, if it's working on the development server it should build successfully. Otherwise bring the error to the development server so i could improve my development experience.
@maruffahmed I've created a build also.
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/aged-cache-l9xyus
To Reproduce
I'm trying to export a function from my
photos/[id]/page.tsx
page which allow me to fetch a photo from unsplash byid
.photos/[id]/page.tsx:
Describe the Bug
The development server is working fine but the build command throwing an error into the CLI.
It looks like the app router is only allowing me to export function with name
"metadata" | "default" | "config" | "generateStaticParams" | "revalidate" | "dynamic" | "dynamicParams" | "fetchCache" | "preferredRegion" | "runtime" | "generateMetadata"
.And throwing the error
Type '(id: string) => Promise<PhotoType>' is not assignable to type 'never'
.Expected Behavior
The build process should be successful without any problem.
I know I could move the
export async function getPhoto(id:string)
function to anutils/lib
file but exporting a reusable async function from thepage.tsx
should be also fine.If it is the way of NextJs at least we may add the error at the
dev server
too so we could know what's going wrong with ourpage.tsx
. Or aneslint
role ortypescript
error so we are concerned about the export function name at development time.Which browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
No response
NEXT-1266