-
Notifications
You must be signed in to change notification settings - Fork 426
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
can't find ReportCallback or ReportHandler type #482
Comments
To fix this we can use But I'm also happy to make a new PR and provide it to be imported. The fix will make import { MetricType } from "web-vitals";
const reportWebVitals = (onPerfEntry?: (metric: MetricType) => void) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import("web-vitals").then(({ onCLS, onINP, onFCP, onLCP, onTTFB }) => {
onCLS(onPerfEntry);
onINP(onPerfEntry);
onFCP(onPerfEntry);
onLCP(onPerfEntry);
onTTFB(onPerfEntry);
});
}
};
export default reportWebVitals; |
Thanks for reporting @safeamiiir. I was going to suggest that fix, but looks like you already figured it out. Tagging in my colleague @brendankenny who reworked some of the types in this library for the v4 release to assess whether or not we need to add |
Thanks for your fast reply @philipwalton. Yes I was not able to find anything more than a line about a change here in an update to the upgrading guide could help, or also bringing it back as I believe so many people are still using Happy to file a PR if needed. |
Web Vitals v3 deprecated several methods and types, and v4 fully removed them. This commit adapts our code to the breaking changes. Note that the breaking removal of the `ReportHandler` type has been complained about[1] and may return in deprecated form[2], but we should go ahead and replace it anyway with the suggested inline typedef. [1] GoogleChrome/web-vitals#482 [2] GoogleChrome/web-vitals#483 PR #745 Bump web-vitals from 3.5.2 to 4.0.0
I've just updated my
web-vitals
packagev3.5.2
->v4.0.0
.Now I can't use argument type for functions (
onCLS
,onFCP
, ...)I'm using
create-react-app
when I've started my application. I'm calling a function to generate a report using this code:The input of
reportWebVitals
function needs a type here which I don't haveReportCallback
to use.this is my partly updated
reportWebVitals.ts
pageI couldn't find this type removal in breaking changes in the CHANGELOG file.
The text was updated successfully, but these errors were encountered: