Skip to content

Commit 541c51b

Browse files
authored
fix(lib): add PerformanceObserver and PerformanceObserverEntryList types (#35640)
`PerformanceObserver` and `PerformanceObserverEntryList` exist at runtime in Deno but were never declared in the default libs, only `lib.webworker.d.ts` declares them, and the `deno.window` lib doesn't load it.
1 parent 037e930 commit 541c51b

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

cli/tsc/dts/lib.deno.shared_globals.d.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,71 @@ declare var PerformanceMeasure: {
985985
new (): never;
986986
};
987987

988+
/** A list of {@linkcode PerformanceEntry} objects passed to a
989+
* {@linkcode PerformanceObserver} callback via its `observe()` method.
990+
*
991+
* @category Performance
992+
*/
993+
interface PerformanceObserverEntryList {
994+
/** Returns all explicitly observed performance entries. */
995+
getEntries(): PerformanceEntry[];
996+
/** Returns the observed performance entries with the given name. */
997+
getEntriesByName(name: string, type?: string): PerformanceEntry[];
998+
/** Returns the observed performance entries with the given entry type. */
999+
getEntriesByType(type: string): PerformanceEntry[];
1000+
}
1001+
1002+
/** A list of {@linkcode PerformanceEntry} objects passed to a
1003+
* {@linkcode PerformanceObserver} callback via its `observe()` method.
1004+
*
1005+
* @category Performance
1006+
*/
1007+
declare var PerformanceObserverEntryList: {
1008+
readonly prototype: PerformanceObserverEntryList;
1009+
new (): never;
1010+
};
1011+
1012+
/** The callback invoked when the observed set of performance entries grows.
1013+
*
1014+
* @category Performance
1015+
*/
1016+
interface PerformanceObserverCallback {
1017+
(list: PerformanceObserverEntryList, observer: PerformanceObserver): void;
1018+
}
1019+
1020+
/** Observes performance measurement events and is notified of new
1021+
* {@linkcode PerformanceEntry} objects as they are recorded in the performance
1022+
* timeline.
1023+
*
1024+
* @category Performance
1025+
*/
1026+
interface PerformanceObserver {
1027+
/** Stops the observer from receiving any further performance entries. */
1028+
disconnect(): void;
1029+
/** Specifies the set of performance entry types to observe. */
1030+
observe(
1031+
options?: {
1032+
entryTypes?: string[];
1033+
type?: string;
1034+
buffered?: boolean;
1035+
},
1036+
): void;
1037+
/** Returns the current list of buffered performance entries, emptying it. */
1038+
takeRecords(): PerformanceEntry[];
1039+
}
1040+
1041+
/** Observes performance measurement events and is notified of new
1042+
* {@linkcode PerformanceEntry} objects as they are recorded in the performance
1043+
* timeline.
1044+
*
1045+
* @category Performance
1046+
*/
1047+
declare var PerformanceObserver: {
1048+
readonly prototype: PerformanceObserver;
1049+
readonly supportedEntryTypes: readonly string[];
1050+
new (callback: PerformanceObserverCallback): PerformanceObserver;
1051+
};
1052+
9881053
/** @category Events */
9891054
interface CustomEventInit<T = any> extends EventInit {
9901055
detail?: T;

0 commit comments

Comments
 (0)