TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

PerformanceObserver types should be narrowed and corrected - unusable without suppressing atm

Open kkmuffme opened this issue 3 years ago • 1 comments

https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts#L10642

Should have the return type specific to the passed value or string if generic string only (see https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/supportedEntryTypes for possible values)

Atm, one has to specify a @type to get rid of false errors, but even then, it will give error TS2322 (but this is a false positive too)

/**
 * @type {PerformanceNavigationTiming[]}
 */
const navigation = performance.getEntriesByType( 'navigation' );

kkmuffme avatar Dec 29 '22 09:12 kkmuffme

The web-vitals package provides it https://github.com/GoogleChrome/web-vitals/blob/dfdf57d112a33ec3cd29e7bc293b253274e4e38d/src/types.ts#L60-L87.

vkrol avatar Oct 02 '23 13:10 vkrol