Skip to content

3.3.2: type errors using attribution callbacks #351

Closed
@OliverJAsh

Description

@OliverJAsh

Following the fixes for #331 in #348, I upgraded to 3.3.2 to see if it fixed the issues I was facing, however I am still having problems. For example:

import { onCLS } from "web-vitals/attribution";
onCLS((metric) => {
  // Expected type: `string | undefined`
  // Actual type: `unknown`
  metric.attribution.largestShiftTarget;
  //                 ^?
});

Suggested fix:

-export interface CLSReportCallbackWithAttribution extends ReportCallbackWithAttribution {
+export interface CLSReportCallbackWithAttribution {
     (metric: CLSMetricWithAttribution): void;
 }

We would need to make a similar change for the other metrics as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions