[NEXT-665] TypeScript error when using generateMetadata() in WebStorm IDE #46431
Labels
bug
Issue was opened via the bug report template.
linear: next
Confirmed issue that is tracked by the Next.js team.
TypeScript
Related to types with Next.js.
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Metadata (metadata, generateMetadata, next/head, head.js), TypeScript
Link to the code that reproduces this issue
https://github.com/patrykszwed/next-metadata-ts-error
To Reproduce
npx create-next-app --example reproduction-template-app-dir reproduction-app
generateMetadata
function topage.tsx
at a root level. That code should be enough:Describe the Bug
When implementing a
generateMetadata
function and opening a project in WebStorm, a TypeScript error is shown at a line where the function is defined. The error says:TS1055: Type 'Metadata | Promise ' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
However, building the project works fine. Moreover, when opening the same project in Visual Studio Code, there are no errors at all.
WebStorm:
Visual Studio Code:
Expected Behavior
No TypeScript errors are shown when defining a valid
generateMetadata
function.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-665
The text was updated successfully, but these errors were encountered: