Skip to content

Add types for window.performance.getEntriesByType #33866

@third774

Description

@third774

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions