Add types for window.performance.getEntriesByType
See original GitHub issueSearch 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:
- Created 4 years ago
- Reactions:12
- Comments:6 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Waiting the feature.
any updates on this?