rsnext/packages/next/server/web/spec-compliant/fetch-event.ts
jj@jjsweb.site 9f0330f301
Fix TS error
2021-10-26 10:29:17 -05:00

26 lines
738 B
TypeScript

export const responseSymbol = Symbol('response')
export const passThroughSymbol = Symbol('passThrough')
export const waitUntilSymbol = Symbol('waitUntil')
export class FetchEvent {
readonly [waitUntilSymbol]: Promise<any>[] = [];
[responseSymbol]?: Promise<Response>;
[passThroughSymbol] = false
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(_request: Request) {}
respondWith(response: Response | Promise<Response>): void {
if (!this[responseSymbol]) {
this[responseSymbol] = Promise.resolve(response)
}
}
passThroughOnException(): void {
this[passThroughSymbol] = true
}
waitUntil(promise: Promise<any>): void {
this[waitUntilSymbol].push(promise)
}
}