Most certainly! You can simply augment the Performance
interface in your own code:
// this does not overwrite `Performance`, it just augments it
interface Performance {
onresourcetimingbufferfull: (e: Event) => any;
// and/or perhaps something like
addEventListener(type: "resourcetimingbufferfull", handler: (e: Event) => any): void;
// in versions of TS before 2.0, you'll need to add this line also:
addEventListener(type: string, handler: (e: Event) => any): void;
}
function bufferFull(e: Event) {
console.log("WARNING: Resource Timing Buffer is FULL!");
performance.setResourceTimingBufferSize(200);
}
performance.onresourcetimingbufferfull = bufferFull;
performance.addEventListener("resourcetimingbufferfull", bufferFull);
I couldn't find that the resourcetimingbufferfull
event carried any special payload so it's easiest just to type it as a regular old Event
.