Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect alternates Example in Metadata Interface Documentation #62909

Open
ciruz opened this issue Mar 5, 2024 · 1 comment · May be fixed by #62910
Open

Incorrect alternates Example in Metadata Interface Documentation #62909

ciruz opened this issue Mar 5, 2024 · 1 comment · May be fixed by #62910
Labels
bug Issue was opened via the bug report template. TypeScript Related to types with Next.js.

Comments

@ciruz
Copy link
Contributor

ciruz commented Mar 5, 2024

Link to the code that reproduces this issue

https://github.com/ciruz/next.js-hreflang

To Reproduce

The metadata-interface.d.ts file contains incorrect documentation regarding the structure of the alternates property within the Metadata type. The example provided uses hreflang to define alternate languages, which contradicts the actual interface definition that expects a languages property.

image

image

image

image

Current vs. Expected behavior

Show a correct example.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
Binaries:
  Node: 18.18.2
  npm: N/A
  Yarn: N/A
  pnpm: 8.15.4
Relevant Packages:
  next: 14.1.2
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.2
Next.js Config:
  output: N/A

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

TypeScript (plugin, built-in types)

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

next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

No response

@ciruz ciruz added the bug Issue was opened via the bug report template. label Mar 5, 2024
@github-actions github-actions bot added the TypeScript Related to types with Next.js. label Mar 5, 2024
ciruz added a commit to ciruz/next.js that referenced this issue Mar 5, 2024
@ciruz ciruz linked a pull request Mar 5, 2024 that will close this issue
@mrgwd
Copy link

mrgwd commented May 13, 2024

I am facing the same bug,

Code

export const metadata: Metadata = {
  title: 'My website',
  description: 'My awesome website',
  metadataBase: new URL('https://mywebsitecom/images/images/'),
  openGraph: {
    images: '/opengraph-image.jpg',
  },
  alternates: {
    canonical: 'https://example.com',
    hreflang: { 'en-US': 'https://example.com/en-US' },
  },
}

Error

Object literal may only specify known properties, and 'hreflang' does not exist in type 'AlternateURLs'.ts(2353)
metadata-interface.d.ts(196, 5): The expected type comes from property 'alternates' which is declared here on type 'Metadata'

Environment information


Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
Binaries:
  Node: v18.18.0
  npm: 9.8.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.3
  eslint-config-next: 14.2.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5
Next.js Config:
  output: 'export'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. TypeScript Related to types with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants