Skip to content

fix(next): support satisfies metadata warning#95686

Open
BlackishGreen33 wants to merge 3 commits into
vercel:canaryfrom
BlackishGreen33:bg/fix-metadata-satisfies-warning-84159
Open

fix(next): support satisfies metadata warning#95686
BlackishGreen33 wants to merge 3 commits into
vercel:canaryfrom
BlackishGreen33:bg/fix-metadata-satisfies-warning-84159

Conversation

@BlackishGreen33

@BlackishGreen33 BlackishGreen33 commented Jul 10, 2026

Copy link
Copy Markdown

Fixes #84159.

Description

The Next.js TypeScript plugin currently warns that a static metadata export has no Metadata type when the export uses TypeScript's satisfies operator:

export const metadata = {
  title: 'My Page',
} satisfies Metadata

This is a false warning. satisfies Metadata already checks the object against the Next.js Metadata type while preserving the more specific inferred type of its fields. For example, code that later reads metadata.title can keep its inferred string type instead of being widened to the optional Metadata['title'] type.

This PR updates the existing hasType() check to recognize a TypeScript SatisfiesExpression initializer. The plugin now treats both supported export forms as typed:

  • an inline export const metadata = ... satisfies Metadata
  • a separately declared value that is re-exported as metadata

The check uses the TypeScript AST and does not rely on source-text matching. Existing behavior is unchanged for metadata exports with no type information: they still receive the current warning. This change only affects the TypeScript plugin diagnostic and does not change runtime metadata handling.

Regression fixtures cover page.tsx and layout.tsx for both inline and separate exports. The existing no-type cases remain in the same test suite to verify that the warning is still reported when appropriate.

How did you test your changes?

Passed locally:

  • pnpm test-dev-turbo test/development/typescript-plugin/metadata/warn-no-type.test.ts
  • pnpm --filter=next types
  • pnpm --filter=next build
  • git diff --check

The focused test first reproduced the incorrect diagnostic for the new satisfies Metadata fixtures, then passed after the AST check was added.

PR Checklist

  • Linked the source issue with Fixes #84159
  • Added regression coverage for inline and separate metadata exports
  • Covered both page.tsx and layout.tsx
  • Kept the existing warning coverage for untyped metadata exports
  • Ran the focused test, type check, and Next.js package build

@BlackishGreen33 BlackishGreen33 marked this pull request as ready for review July 10, 2026 17:11
Copilot AI review requested due to automatic review settings July 10, 2026 17:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support satisfies for metadata and viewport exports in TypeScript IDE plugin

2 participants