GoogleChrome / web-vitals

Essential metrics for a healthy site.
https://web.dev/vitals
Apache License 2.0
7.47k stars 410 forks source link

Fix compatibility issues with TypeScript v5.5 #497

Closed devjiwonchoi closed 2 months ago

devjiwonchoi commented 2 months ago

The type of LargestContentfulPaint conflicts with the new TypeScript@5.5.2, which throws an error:

error TS2687: All declarations of 'element' must have identical modifiers.
error TS2687: All declarations of 'id' must have identical modifiers.
...

The type has readonly which requires our type to be identical as well. The TypeScript:

// typescript@5.5.2/node_modules/typescript/lib/lib.dom.d.ts:14706:14

/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/LargestContentfulPaint) */
interface LargestContentfulPaint extends PerformanceEntry {
    /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/LargestContentfulPaint/element) */
    readonly element: Element | null;
    /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/LargestContentfulPaint/id) */
    readonly id: string;
    /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/LargestContentfulPaint/loadTime) */
    readonly loadTime: DOMHighResTimeStamp;
    /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/LargestContentfulPaint/renderTime) */
    readonly renderTime: DOMHighResTimeStamp;
    /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/LargestContentfulPaint/size) */
    readonly size: number;
    /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/LargestContentfulPaint/url) */
    readonly url: string;
    /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/LargestContentfulPaint/toJSON) */
    toJSON(): any;
}

Fixes #498

google-cla[bot] commented 2 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

devjiwonchoi commented 2 months ago

@philipwalton Sorry to ping you, this issue is a blocker of upgrading TypeScript version, would love your review for it. 🙏

philipwalton commented 2 months ago

This is added in v4.2.1, let me know if you're still seeing issues after upgrading.