vercel / vercel/next.js

Support `satisfies` for metadata and viewport exports in TypeScript IDE plugin

Open
#84,159 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

TypeScript
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/stupefied-drake-djhgvk?workspaceId=ws_FFy8WZFGHmk9xkeVqwsT43

To Reproduce
  1. Create a metadata export in a Next.js page.tsx or layout.tsx file, using the satisfies keyword instead of directly setting the type:
    import { Metadata } from 'next'
    
    export const metadata = {
      title: 'My Website',
    } satisfies Metadata
    
  2. Enable the Next.js TypeScript IDE plugin
  3. Notice that TypeScript emits the warning The Next.js "metadata" export should be type of "Metadata" from "next". despite the object being typed with the satisfies keyword.
Current vs. Expected behavior

I would expect the Next.js IDE plugin to detect the use of the satisfies operator and not emit a warning in this situation.

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Mon Aug 25 21:17:51 PDT 2025; root:xnu-12377.1.9~3/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.15.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.15.0
Relevant Packages:
  next: 15.5.2
  eslint-config-next: N/A
  react: 19.1.1
  react-dom: 19.1.1
  typescript: 5.9.2
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

TypeScript

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

It's worth noting why it's important to support the satisfies operator here. We sometimes need to use the values for title, description, etc. in other places, and rather than define these in a 3rd object, we can directly import the metadata from routes. This ensures that the info can still be updated in the same place, which brings consistency, but also that we only have to update it in one place, reducing repetition. With the object directly typed, intellisense will not correctly know which keys have been defined to which exact types, and in the case of title and others, what shape is defined.

An example:

Without satisfies
import { Metadata } from 'next'

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

function ExampleComponent(props: { title: string }) { return null }

export default function() {
  return <ExampleComponent title={metadata.title} />
  //                                       ^^^^^
  // This will error as `title` is required, but Metadata defines it as optional (potentially undefined), even though it's defined in the object above
}
With satisfies
import { Metadata } from 'next'

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

function ExampleComponent(props: { title: string }) { return null }

export default function() {
  return <ExampleComponent title={metadata.title} />
  // This will now work correctly as `title` is typed at `string`
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and the TypeScript IDE plugin behavior for metadata and viewport exports in page.tsx or layout.tsx. Verify how the plugin handles the satisfies operator; done means a valid satisfies Metadata export no longer emits the warning while direct type behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.