question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add types for window.performance.getEntriesByType

See original GitHub issue

Search Terms

getEntriesByType PerformanceMark PerformanceMeasure PerformanceResourceTiming

Suggestion

Add types for the getEntriesByType API

I found this old issue (Jul 5, 2018) and saw that experimental API’s are not included in lib.dom.d.ts. The following API’s don’t appear to have experimental warnings on them on the MDN docs. Hopefully this means these are no longer experimental and types can be added now?

https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMark https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMeasure https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming

Use Cases

Getting specific strongly typed information for the entries when accessed via this API.

Examples

// resources would be of type PerformanceResourceTiming[]
const resources = window.navigation.getEntriesByType("resource");

// resources would be of type PerformanceMeasure[]
const measures = window.navigation.getEntriesByType("measure");

// marks would be of type PerformanceMark[]
const marks = window.navigation.getEntriesByType("mark");

// paints would still be of type PerformanceEntryList
const paints = window.navigation.getEntriesByType("paint");

Checklist

My suggestion meets these guidelines (not sure about the first one):

  • This wouldn’t be a breaking change in existing TypeScript/JavaScript code
  • This wouldn’t change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn’t a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript’s Design Goals.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:12
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
TaylorPzrealcommented, Jul 30, 2020

Waiting the feature.

1reaction
DerGernTodcommented, Feb 3, 2022

any updates on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

performance.getEntriesByType() - Web APIs | MDN
The getEntriesByType() method returns an array of PerformanceEntry objects currently present in the performance timeline for a given type.
Read more >
Mock window.performance.getEntriesByType - Stack Overflow
Even I tried to mock it like below but had no success. window.performance = { getEntriesByType: jest.fn().mockReturnValue([{ type: ...
Read more >
Performance.getEntriesByType()
The getEntriesByType() method returns a list of PerformanceEntry objects for a ... entries = window.performance.getEntriesByType(type); ...
Read more >
Assessing loading performance in the field with Navigation ...
getEntriesByType ('resource');. performance.getEntriesByType accepts a string describing the type of entries you want to retrieve from the ...
Read more >
Performance Timeline - W3C
3.1.1 getEntries() method. Returns a PerformanceEntryList object returned by the filter buffer map by name and type algorithm with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found