Skip to content

missing Metric type in useReportWebVitals #59903

@stefanprobst

Description

@stefanprobst

Link to the code that reproduces this issue

https://github.com/stefanprobst/issue-next-webvitals

To Reproduce

  1. in the reproduction repo, open components/analytics.tsx
  2. see that metric.name is typed as any (you can also ctrl+click on useReportWebVitals to see that the type import import type { Metric } from 'next/dist/compiled/web-vitals'; does not resolve)

Current vs. Expected behavior

the useReportWebVitals hook accepts a callback (metric: Metric) => void, where the type Metric is imported from next/dist/compiled/web-vitals here. however, next/dist/compiled/web-vitals does not include a .d.ts file, only the .js, so the type import does not resolve.

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #38~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov  2 18:01:13 UTC 2
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: 1.22.19
  pnpm: 8.12.1
Relevant Packages:
  next: 14.0.5-canary.24
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

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

TypeScript (plugin, built-in types)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScriptRelated to types with Next.js.not staleA previously `stale` marked issue that is no longer stale.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions