next.js
next.js copied to clipboard
Unsupported node type "TsConstAssertion" at "config.api.bodyParser".
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000
Binaries:
Node: 18.10.0
npm: 8.19.2
Yarn: 1.22.18
pnpm: 7.14.0
Relevant packages:
next: 13.0.0
eslint-config-next: 13.0.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
When config object is exported from an API route using TypeScript, an error is thrown.
Route:
export const config = {
api: {
bodyParser: false as const,
},
};
export default function handler(req, res) {
res.status(200).json({ name: 'John Doe' })
}
Error:
warn - Next.js can't recognize the exported `config` field in route "/pages/api/hello":
Unsupported node type "TsConstAssertion" at "config.api.bodyParser".
The default config will be used instead.
Read More - https://nextjs.org/docs/messages/invalid-page-config
Expected Behavior
No errors.
Link to reproduction
https://github.com/mmiszy/typescript-next-bug
To Reproduce
Run npm run dev and observe the error.