diff --git a/src/types.ts b/src/types.ts index 26beaba2..22446712 100644 --- a/src/types.ts +++ b/src/types.ts @@ -58,9 +58,11 @@ interface PerformanceEntryMap { // Update built-in types to be more accurate. declare global { - // https://wicg.github.io/nav-speculation/prerendering.html#document-prerendering interface Document { - prerendering?: boolean + // https://wicg.github.io/nav-speculation/prerendering.html#document-prerendering + prerendering?: boolean; + // https://github.com/WICG/page-lifecycle/blob/main/README.md + wasDiscarded?: boolean; } interface Performance { diff --git a/src/types/base.ts b/src/types/base.ts index 811e628e..1d2d0a6a 100644 --- a/src/types/base.ts +++ b/src/types/base.ts @@ -105,12 +105,3 @@ export interface ReportOpts { * loading. This is equivalent to the corresponding `readyState` value. */ export type LoadState = 'loading' | 'dom-interactive' | 'dom-content-loaded' | 'complete'; - -/** - * Extend the document with the new wasDiscarded boolean which is not supported - * in typescript yet - * https://github.com/WICG/page-lifecycle/blob/main/README.md - */ -declare global { - interface Document { wasDiscarded?: boolean; } -} diff --git a/test/views/layout.njk b/test/views/layout.njk index c3a3a9b4..9136e6f2 100644 --- a/test/views/layout.njk +++ b/test/views/layout.njk @@ -105,7 +105,6 @@ */ self.__stubWasDiscarded = () => { return new Promise((resolve) => { - const navEntry = performance.getEntriesByType('navigation')[0]; // Only stub if the page isn't actually discarded. if (!document.wasDiscarded) { Object.defineProperty(document, 'wasDiscarded', {