nextjs - 💡(How to fix) Fix type mismatch between Metadata and ResolvedMetadata [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#88714Fetched 2026-04-08 02:04:05
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×2closed ×1commented ×1issue_type_added ×1

Code Example

import type { Metadata, ResolvedMetadata } from "next"

type OgUrl = NonNullable<Metadata["openGraph"]>["url"]
    // ^?
type ResolvedOgUrl = NonNullable<ResolvedMetadata["openGraph"]>["url"]
    // ^?

---

Operating System:
  Platform: linux
  Arch: x64
  Version: #202510231631 SMP PREEMPT_DYNAMIC Thu Oct 23 19:57:43 UTC 2025
  Available memory (MB): 32037
  Available CPU cores: 4
Binaries:
  Node: 24.13.0
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.28.0
Relevant Packages:
  next: 16.1.3 // Latest available version is detected (16.1.3).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBDAnmApnA3nAsimBDAEz3wBo4AlFAZwgBsA3FAnfI-OAXzgDMoIQ4AIgB2KAB4xBAKClJUcAPIBzAKpRacALxwAchGE6ArrVp4ARrRQAeFoWJ4A2oIiphAcSh4wAC0EBdAD4nQ3V-KTgIuAB6KLgAPQB+WWQ0ShoGJmU1DW09A2NTC2s0ukZmXDt8JxcUd08ffyDBENowyOjYxKkgA

To Reproduce

open repro link to typescript playground, and see one example on type mismatch: ResolvedMetadata og:url includes null but Metadata og:url does not:

import type { Metadata, ResolvedMetadata } from "next"

type OgUrl = NonNullable<Metadata["openGraph"]>["url"]
    // ^?
type ResolvedOgUrl = NonNullable<ResolvedMetadata["openGraph"]>["url"]
    // ^?

Current vs. Expected behavior

no type mismatch so it is easy to merge ResolvedMetadata into Metadata

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #202510231631 SMP PREEMPT_DYNAMIC Thu Oct 23 19:57:43 UTC 2025
  Available memory (MB): 32037
  Available CPU cores: 4
Binaries:
  Node: 24.13.0
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.28.0
Relevant Packages:
  next: 16.1.3 // Latest available version is detected (16.1.3).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Metadata

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

next dev (local)

Additional context

No response

extent analysis

TL;DR

Update the type definitions for Metadata and ResolvedMetadata to ensure consistency in the openGraph property.

Guidance

  • Review the type definitions for Metadata and ResolvedMetadata in the next package to identify any discrepancies in the openGraph property.
  • Check if the openGraph property in ResolvedMetadata is correctly defined to include null as a possible value.
  • Verify if the issue is specific to the next version 16.1.3 or if it persists across different versions.
  • Consider creating a custom type guard or interface to handle the potential null value in the openGraph property.

Example

type CustomOgUrl = NonNullable<Metadata["openGraph"]>["url"] | null;

Notes

The issue seems to be related to a type mismatch between Metadata and ResolvedMetadata in the next package. However, without more information about the package's internal implementation, it's difficult to provide a definitive solution.

Recommendation

Apply workaround by creating a custom type guard or interface to handle the potential null value in the openGraph property, as updating the next package may not be feasible or immediate.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING