<p dir="auto">A lot of interfaces defined in <code class="notranslate">service_worker_api</code> are overrides of interfaces that fetch type definitions lie <code class="notranslate">watwg-fetch</code> or <code class="notranslate">isomorphic-fetch</code> are provided. <code class="notranslate">service_worker_api</code> is usually used in conjunction with one of fetch libs and when user do that, interface mismatches will throw TypeScript errors.</p>
<p dir="auto">There are two options to fix it:</p>
<ul dir="auto">
<li>Remove all of interface properties that are colliding  with fetch interfaces</li>
<li>Import of of the fetch type definitions and extend those interfaces</li>
</ul>
<p dir="auto">Here is the type definition with removed interface members that collide with <code class="notranslate">isomorphic-fetch</code> type definition:</p>
<details>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Type definitions for service_worker_api
// Project: https://developer.mozilla.org/fr/docs/Web/API/ServiceWorker_API
// Definitions by: Tristan Caron &lt;https://github.com/tristancaron&gt;
// Definitions: https://github.com/borisyankov/DefinitelyTyped

// &lt;reference path=&quot;../es6-promise/es6-promise.d.ts&quot; /&gt; // REMOVED third &quot;/&quot; so this doesn't fire. Problem with duplicate Promises
// between es6 and typescript - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/5015

/**
 * Provides methods relating to the body of the response/request, allowing you
 * to declare what its content type is and how it should be handled.
 */
interface Body {
    /**
     * Contains a Boolean that indicates whether the body has been read.
     * @readonly
     */
    bodyUsed: boolean;

    /**
     * Takes a Response stream and reads it to completion.
     * It returns a promise that resolves with an ArrayBuffer.
     */
    arrayBuffer(): Promise&lt;ArrayBuffer&gt;;

    /**
     * Takes a Response stream and reads it to completion.
     * It returns a promise that resolves with a Blob.
     */
    blob(): Promise&lt;Blob&gt;;

    /**
     * Takes a Response stream and reads it to completion.
     * It returns a promise that resolves with a FormData object.
     */
    formData(): Promise&lt;FormData&gt;;

    /**
     * Takes a Response stream and reads it to completion.
     * It returns a promise that resolves with a JSON object.
     */
    json(): Promise&lt;JSON&gt;;

    /**
     * Takes a Response stream and reads it to completion.
     * It returns a promise that resolves with a USVString (text).
     */
    text(): Promise&lt;Text&gt;;

}

/**
 * Represents response/request headers, allowing you to query them and take
 * different actions depending on the results.
 */
interface Header {
    new(): Header;

    /**
     * Appends a new value onto an existing header inside a Headers object, or
     * adds the header if it does not already exist.
     *
     * @param name The name of the HTTP header you want to add to the Headers
     * object.
     * @param value The value of the HTTP header you want to add.
     */
    append(name: string, value: string): void;

    /**
     * Deletes a header from a Headers object.
     *
     * @param name The name of the HTTP header you want to delete from the
     * Headers object.
     */
    delete(name: string): void;

    /**
     * Returns the first value of a given header from within a Headers object.
     *
     * @param name The name of the HTTP header whose value you want to retrieve
     * from the Headers object. If the given name is not the name of an
     * HTTP header, this method throws a TypeError.
     */
    get(name: string): string;

    /**
     * Returns an array of all the values of a header within a Headers object
     * with a given name.
     *
     * @param name The name of the HTTP header whose values you want to retrieve
     * from the Headers object. If the given name is not the name of an
     * HTTP header, this method throws a TypeError.
     */
    getAll(name:string): Array&lt;string&gt;;

    /**
     * Returns a boolean stating whether a Headers object contains a
     * certain header.
     *
     * @param name The name of the HTTP header you want to test for. If the
     * given name is not the name of an HTTP header, this method throws
     * a TypeError.
     */
    has(name: string): boolean;

    /**
     * Sets a new value for an existing header inside a Headers object, or
     * adds the header if it does not already exist.
     *
     * @param name The name of the HTTP header you want to set to a new value.
     * If the given name is not the name of an HTTP header, this method throws
     * a TypeError.
     * @param value The new value you want to set.
     */
    set(name: string, value: string): void;
}

/**
 * Represents the response to a request.
 */
interface Response extends Body {
    new(): Response;

    /**
     * Contains the URL of the response.
     * @readonly
     */
    url: string;

    /**
     * Contains a boolean stating whether this is the final URL of the response.
     */
    useFinalURL: boolean;

    /**
     * Contains the status code of the response (e.g., 200 for a success).
     * @readonly
     */
    status: number;

    /**
     * Contains a boolean stating whether the response was successful
     * (status in the range 200-299) or not.
     * @readonly
     */
    ok: boolean;

    /**
     * Contains the status message corresponding to the status code
     * (e.g., OK for 200).
     * @readonly
     */
    statusText: string;

    /**
     * Creates a clone of a Response object.
     */
    clone(): Response;

    /**
     * Returns a new Response object associated with a network error.
     */
    error(): Response;

    /**
     * Creates a new response with a different URL.
     */
    redirect(): Response;
}

/**
 * Represents a resource request.
 */
interface Request extends Body {
    new(): Request;

    /**
     * Contains the request's method (GET, POST, etc.).
     * @readonly
     */
    method: string;

    /**
     * Contains the URL of the request.
     * @readonly
     */
    url: string;

    /**
     * Contains the context of the request (e.g., audio, image, iframe, etc.).
     * @readonly
     */
    context: string;

    /**
     * Contains the referrer of the request (e.g., client).
     * @readonly
     */
    referrer: string;


    /**
     * Creates a copy of the current Request object.
     */
    clone(): Request;
}

/**
 * An CacheOptions object allowing you to set specific control options for the
 * matching done in the match operation.
 *
 * @property [ignoreSearch] A Boolean that specifies whether the matching
 * process should ignore the query string in the url.  If set to true,
 * the ?value=bar part of http://foo.com/?value=bar would be ignored when
 * performing a match. It defaults to false.
 *
 * @property [ignoreMethod] A Boolean that, when set to true, prevents matching
 * operations from validating the Request http method (normally only GET
 * and HEAD are allowed.) It defaults to false.
 *
 * @property [ignoreVary] A Boolean that when set to true tells the matching
 * operation not to perform VARY header matching — i.e. if the URL matches you
 * will get a match regardless of the Response object having a VARY header or
 * not. It defaults to false.
 *
 * @property [cacheName] A DOMString that represents a specific cache to search
 * within. Note that this option is ignored by Cache.match().
 */
interface CacheOptions {
    ignoreSearch?: boolean;
    ignoreMethod?: boolean;
    ignoreVary?: boolean;
    cacheName?: string;
}

/**
 * Represents the storage for Request / Response object pairs that are cached as
 * part of the ServiceWorker life cycle.
 */
interface Cache {
    /**
     * Returns a Promise that resolves to the response associated with the first
     * matching request in the Cache object.
     *
     * @param request The Request you are attempting to find in the Cache.
     * @param {CacheOptions} options
     */
    match(request: Request | string, options?: CacheOptions): Promise&lt;Response&gt;;

    /**
     * Returns a Promise that resolves to an array of all matching responses in
     * the Cache object.
     *
     * @param request The Request you are attempting to find in the Cache.
     * @param {CacheOptions} options
     */
    matchAll(request: Request | string, options?: CacheOptions): Promise&lt;Array&lt;Response&gt;&gt;;

    /**
     * Returns a Promise that resolves to a new Cache entry whose key
     * is the request.
     *
     * @param request The Request you want to add to the cache.
     */
    add(request: Request | string): Promise&lt;void&gt;;

    /**
     * Returns a Promise that resolves to a new array of Cache entries whose
     * keys are the requests.
     *
     * @param request An array of Request objects you want to add to the cache.
     */
    addAll(...request: Array&lt;Request | string&gt;): Promise&lt;void&gt;;

    /**
     * Adds additional key/value pairs to the current Cache object.
     *
     * @param request The Request you want to add to the cache.
     * @param response The response you want to match up to the request.
     */
    put(request: Request, response: Response): Promise&lt;void&gt;;

    /**
     * Finds the Cache entry whose key is the request, and if found, deletes the
     * Cache entry and returns a Promise that resolves to true. If no Cache
     * entry is found, it returns false.
     *
     * @param request The Request you are looking to delete.
     * @param {CacheOptions} options
     */
    delete(request: Request | string, options?: CacheOptions): Promise&lt;boolean&gt;;

    /**
     * Returns a Promise that resolves to an array of Cache keys.
     *
     * @param request The Request want to return, if a specific key is desired.
     * @param {CacheOptions} options
     */
    keys(request?: Request, options?: CacheOptions): Promise&lt;Array&lt;Request&gt;&gt;;
}

/**
 * Represents the storage for Cache objects. It provides a master directory of
 * all the named caches that a ServiceWorker can access and maintains a mapping
 * of string names to corresponding Cache objects.
 */
interface CacheStorage {
    /**
     * Checks if a given Request is a key in any of the Cache objects that the
     * CacheStorage object tracks and returns a Promise that resolves
     * to that match.
     *
     * @param request The Request you are looking for a match for in the CacheStorage.
     * @param {CacheOptions} options
     */
    match(request: Request | string, options?: CacheOptions): Promise&lt;Response&gt;;

    /**
     * Returns a Promise that resolves to true if a Cache object matching
     * the cacheName exists.
     *
     * @param cacheName The Request you are looking for a match for in the
     * CacheStorage.
     */
    has(cacheName: string): Promise&lt;boolean&gt;;

    /**
     * Returns a Promise that resolves to the Cache object matching
     * the cacheName.
     *
     * @param cacheName The name of the cache you want to open.
     */
    open(cacheName: string): Promise&lt;Cache&gt;;

    /**
     * Finds the Cache object matching the cacheName, and if found, deletes the
     * Cache object and returns a Promise that resolves to true. If no
     * Cache object is found, it returns false.
     *
     * @param cacheName The name of the cache you want to delete.
     */
    delete(cacheName: string): Promise&lt;boolean&gt;;

    /**
     * Returns a Promise that will resolve with an array containing strings
     * corresponding to all of the named Cache objects tracked by the
     * CacheStorage. Use this method to iterate over a list of all the
     * Cache objects.
     */
    keys(): Promise&lt;Array&lt;string&gt;&gt;;
}

/**
 * Represents the scope of a service worker client. A service worker client is
 * either a document in a browser context or a SharedWorker, which is controlled
 * by an active worker.
 */
interface ServiceWorkerClient {
    /**
     * Allows a service worker client to send a message to a ServiceWorker.
     *
     * @param message The message to send to the service worker.
     * @param [transfer] A transferable object such as, for example, a reference
     * to a port.
     */
    postMessage(message: string, transfer?: Object): void;

    /**
     * Indicates the type of browsing context of the current client.
     * This value can be one of auxiliary, top-level, nested, or none.
     * @readonly
     */
    frameType: string;

    /**
     * Returns the id of the Client object.
     * @readonly
     */
    id: string;

    /**
     * The URL of the current service worker client.
     * @readonly
     */
    url: string;
}

interface WindowClient extends ServiceWorkerClient {
    /**
     * Gives user input focus to the current client.
     */
    focus(): Promise&lt;WindowClient&gt;;

    /**
     * A boolean that indicates whether the current client has focus.
     * @readonly
     */
    focused: boolean;

    /**
     * Indicates the visibility of the current client. This value can be one of
     * hidden, visible, prerender, or unloaded.
     * @readonly
     */
    visibilityState: string;
}

interface ServiceWorkerClientsMatchOptions {
    includeUncontrolled?: boolean;
    type?: string;
}

/**
 * Represents a container for a list of Client objects; the main way to access
 * the active service worker clients at the current origin.
 */
interface ServiceWorkerClients {
    /**
     * Gets a list of service worker clients and returns them in a Promise.
     * Include the options parameter to return all service worker clients whose
     * origin is the same as the associated service worker's origin. If options
     * are not included, the method returns only the service worker clients
     * controlled by the service worker.
     *
     * @param options
     */
    matchAll(options: ServiceWorkerClientsMatchOptions): Promise&lt;Array&lt;ServiceWorkerClient&gt;&gt;;

    /**
     * Opens a service worker Client in a new browser window.
     *
     * @param url A string representing the URL of the client you want to open
     * in the window.
     */
    openWindow(url: string): Promise&lt;WindowClient&gt;;

    /**
     * Allows an active Service Worker to set itself as the active worker for a
     * client page when the worker and the page are in the same scope.
     */
    claim(): Promise&lt;void&gt;;
}

/**
 * Extends the lifetime of the install and activate events dispatched on the
 * ServiceWorkerGlobalScope as part of the service worker lifecycle. This
 * ensures that any functional events (like FetchEvent) are not dispatched to
 * the ServiceWorker until it upgrades database schemas, deletes outdated cache
 * entries, etc.
 */
interface ExtendableEvent extends Event {
    /**
     * Extends the lifetime of the event.
     * It is intended to be called in the install EventHandler for the
     * installing worker and on the active EventHandler for the active worker.
     *
     * @param all
     */
    waitUntil(all: any): any;
}

/**
 * The parameter passed into the ServiceWorkerGlobalScope.onfetch handler,
 * FetchEvent represents a fetch action that is dispatched on the
 * ServiceWorkerGlobalScope of a ServiceWorker. It contains information about
 * the request and resulting response, and provides the FetchEvent.respondWith()
 * method, which allows us to provide an arbitrary response back to the
 * controlled page.
 */
interface FetchEvent extends Event {
    /**
     * Returns a Boolean that is true if the event was dispatched with the
     * user's intention for the page to reload, and false otherwise. Typically,
     * pressing the refresh button in a browser is a reload, while clicking a
     * link and pressing the back button is not.
     * @readonly
     */
    isReload: boolean;

    /**
     * Returns the Request that triggered the event handler.
     * @readonly
     */
    request: Request;

    /**
     * Returns the Client that the current service worker is controlling.
     * @readonly
     */
    client: ServiceWorkerClient;

    /**
     * Resolves by returning a Response or a network error to Fetch.
     *
     * @param all
     */
    respondWith(all: any): Response;
}

/**
 * Represents a service worker. Multiple browsing contexts (e.g. pages, workers,
 * etc.) can be associated with the same ServiceWorker object.
 */
interface ServiceWorker extends Worker {
    /**
     * Returns the ServiceWorker serialized script URL defined as part of
     * ServiceWorkerRegistration. The URL must be on the same origin as the
     * document that registers the ServiceWorker.
     * @readonly
     */
    scriptURL: string;

    /**
     * Returns the state of the service worker. It returns one of the following
     * values: installing, installed, activating, activated, or redundant.
     * @readonly
     */
    state: string;

    /**
     * An EventListener property called whenever an event of type statechange
     * is fired; it is basically fired anytime the ServiceWorker.state changes.
     *
     * @param [statechangeevent]
     */
    onstatechange: (statechangeevent?: any) =&gt; void;
}

/**
 * The PushSubscription interface provides a subcription's URL endpoint and
 * subscription ID.
 */
interface PushSubscription {
    /**
     * The endpoint associated with the push subscription.
     * @readonly
     */
    endpoint: any;

    /**
     * The subscription ID associated with the push subscription.
     * @readonly
     */
    subscriptionId: any;
}

/**
 * The PushManager interface provides a way to receive notifications from
 * third-party servers as well as request URLs for push notifications.
 * This interface has replaced functionality offered by the obsolete
 * PushRegistrationManager.
 */
interface PushManager {
    /**
     * Returns a promise that resolves to a PushSubscription with details of a
     * new push subscription.
     */
    subscribe(): Promise&lt;PushSubscription&gt;;

    /**
     * Returns a promise that resolves to a PushSubscription details of
     * the retrieved push subscription.
     */
    getSubscription(): Promise&lt;PushSubscription&gt;;

    /**
     * Returns a promise that resolves to the PushPermissionStatus of the
     * requesting webapp, which will be one of granted, denied, or default.
     */
    hasPermission(): Promise&lt;any&gt;;
}

/**
 * Represents a service worker registration.
 */
interface ServiceWorkerRegistration extends EventTarget {
    /**
     * Returns a unique identifier for a service worker registration.
     * This must be on the same origin as the document that registers
     * the ServiceWorker.
     * @readonly
     */
    scope: any;

    /**
     * Returns a service worker whose state is installing. This is initially
     * set to null.
     * @readonly
     */
    installing: ServiceWorker;

    /**
     * Returns a service worker whose state is installed. This is initially
     * set to null.
     * @readonly
     */
    waiting: ServiceWorker;

    /**
     * Returns a service worker whose state is either activating or activated.
     * This is initially set to null. An active worker will control a
     * ServiceWorkerClient if the client's URL falls within the scope of the
     * registration (the scope option set when ServiceWorkerContainer.register
     * is first called).
     * @readonly
     */
    active: ServiceWorker;

    /**
     * Returns an interface to for managing push subscriptions, including
     * subcribing, getting an anctive subscription, and accessing push
     * permission status.
     * @readonly
     */
    pushManager: PushManager;

    /**
     * An EventListener property called whenever an event of type updatefound
     * is fired; it is fired any time the ServiceWorkerRegistration.installing
     * property acquires a new service worker.
     */
    onupdatefound: () =&gt; void;

    /**
     * Allows you to update a service worker.
     */
    update(): void;

    /**
     * Unregisters the service worker registration and returns a promise
     * (see Promise). The service worker will finish any ongoing operations
     * before it is unregistered.
     */
    unregister(): Promise&lt;boolean&gt;;
}

interface ServiceWorkerRegisterOptions {
    scope: string;
}

/**
 * Provides an object representing the service worker as an overall unit in the
 * network ecosystem, including facilities to register, unregister and update
 * service workers, and access the state of service workers
 * and their registrations.
 */
interface ServiceWorkerContainer {
    /**
     * Returns a ServiceWorker object if its state is activated (the same object
     * returned by ServiceWorkerRegistration.active). This property returns null
     * if the request is a force refresh (Shift + refresh) or if there is no
     * active worker.
     * @readonly
     */
    controller: ServiceWorker;

    /**
     * Defines whether a service worker is ready to control a page or not.
     * It returns a Promise that will never reject, which resolves to a
     * ServiceWorkerRegistration with an ServiceWorkerRegistration.active worker.
     * @readonly
     */
    ready: Promise&lt;ServiceWorkerRegistration&gt;;

    /**
     * An event handler fired whenever a controllerchange event occurs — when
     * the document's associated ServiceWorkerRegistration acquires a new
     * ServiceWorkerRegistration.active worker.
     *
     * @param [controllerchangeevent]
     */
    oncontrollerchange: (controllerchangeevent?: Event) =&gt; void;

    /**
     * An event handler fired whenever an error event occurs in the associated
     * service workers.
     *
     * @param [errorevent]
     */
    onerror: (errorevent?: ErrorEvent) =&gt; void;

    /**
     * An event handler fired whenever a message event occurs — when incoming
     * messages are received to the ServiceWorkerContainer object (e.g. via a
     * MessagePort.postMessage() call.)
     *
     * @param [messageevent]
     */
    onmessage: (messageevent?: MessageEvent) =&gt; void;

    /**
     * Creates or updates a ServiceWorkerRegistration for the given scriptURL.
     *
     * @param scriptURL The URL of the service worker script.
     * @param [options] An options object to provide options upon registration.
     * Currently available options are: scope: A USVString representing a URL
     * that defines a service worker's registration scope; what range of URLs a
     * service worker can control. This is usually a relative URL, and it
     * defaults to '/' when not specified.
     */
    register(scriptURL: string, options?: ServiceWorkerRegisterOptions): Promise&lt;ServiceWorkerRegistration&gt;;

    /**
     * Gets a ServiceWorkerRegistration object whose scope URL matches the
     * provided document URL.  If the method can't return a
     * ServiceWorkerRegistration, it returns a Promise.
     *
     * @param [scope] A unique identifier for a service worker registration — the
     * scope URL of the registration object you want to return. This is usually
     * a relative URL.
     */
    getRegistration(scope?: string): Promise&lt;ServiceWorkerRegistration&gt;;

    /**
     * Returns all ServiceWorkerRegistrations associated with a
     * ServiceWorkerContainer in an array.  If the method can't return
     * ServiceWorkerRegistrations, it returns a Promise.
     */
    getRegistrations(): Promise&lt;Array&lt;ServiceWorkerRegistration&gt;&gt;;
}

/**
 * The parameter passed into the oninstall handler, the InstallEvent interface
 * represents an install action that is dispatched on the
 * ServiceWorkerGlobalScope of a ServiceWorker. As a child of ExtendableEvent,
 * it ensures that functional events such as FetchEvent are not dispatched
 * during installation.
 */
interface InstallEvent extends ExtendableEvent {
    /**
     * Returns the ServiceWorker that is currently actively controlling the page.
     * @readonly
     */
    activeWorker: ServiceWorker;
}

interface ServiceWorkerGlobalScope {
    /**
     * Contains the Clients object associated with the service worker.
     * @readonly
     */
    clients: ServiceWorkerClients;

    /**
     * Contains the ServiceWorkerRegistration object that represents the
     * service worker's registration.
     * @readonly
     */
    registration: ServiceWorkerRegistration;

    /**
     * An event handler fired whenever an activate event occurs — when a
     * ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.active
     * worker.
     *
     * @param [activateevent]
     */
    onactivate: (activateevent?: ExtendableEvent) =&gt; void;

    /**
     * Not defined in the spec yet, but it looks like this will be fired when
     * the device is nearly out of storage space, prompting the UA to start
     * claiming back some space from web apps that are using client-side storage,
     * and the current app is targeted.
     *
     * @param [beforeevictedevent]
     */
    onbeforeevicted: (beforeevictedevent?: Event) =&gt; void;

    /**
     * Not defined in the spec yet, but it looks like this will be fired when
     * the device is out of storage space, and the UA claims back some space
     * from the current app.
     *
     * @param [evictedevent]
     */
    onevicted: (evictedevent?: Event) =&gt; void;

    /**
     * An event handler fired whenever a fetch event occurs — when a fetch()
     * is called.
     *
     * @param [fetchevent]
     */
    onfetch: (fetchevent?: FetchEvent) =&gt; void;

    /**
     * An event handler fired whenever an install event occurs — when a
     * ServiceWorkerRegistration acquires a new
     * ServiceWorkerRegistration.installing worker.
     *
     * @param [installevent]
     */
    oninstall: (installevent?: InstallEvent) =&gt; void;

    /**
     * An event handler fired whenever a message event occurs — when incoming
     * messages are received. Controlled pages can use the
     * MessagePort.postMessage() method to send messages to service workers.
     * The service worker can optionally send a response back via the
     * MessagePort exposed in event.data.port, corresponding to the controlled
     * page.
     *
     * @param [messageevent]
     */
    onmessage: (messageevent?: MessageEvent) =&gt; void;

    /**
     * An event handler fired whenever a notificationclick event occurs — when
     * a user clicks on a displayed notification.
     *
     * @param [notificationclickevent]
     */
    onnotificationclick: (notificationclickevent?: NotificationEvent) =&gt; void;

    /**
     * An event handler fired whenever a push event occurs — when a server
     * push notification is received.
     *
     * @param [onpushevent]
     */
    onpush: (onpushevent?: Event) =&gt; void;

    /**
     * An event handler fired whenever a pushsubscriptionchange event occurs —
     * when a push subscription has been invalidated, or is about to be
     * invalidated (e.g. when a push service sets an expiration time).
     *
     * @param [pushsubscriptionchangeevent]
     */
    onpushsubscriptionchange: (pushsubscriptionchangeevent?: Event) =&gt; void;

    /**
     * Allows the current service worker registration to progress from waiting
     * to active state while service worker clients are using it.
     */
    skipWaiting(): Promise&lt;void&gt;;

    /**
     * TODO GlobalFetch
     * @param url
     * @param init
     */
    fetch(url: string | Request, init?: Object): Promise&lt;Response&gt;;
}

interface Navigator {
    /**
     * Returns a ServiceWorkerContainer object, which provides access to
     * registration, removal, upgrade, and communication with the ServiceWorker
     * objects for the associated document.
     */
    serviceWorker: ServiceWorkerContainer;
}

interface Global extends ServiceWorkerGlobalScope {
    caches: CacheStorage;
}

interface NotificationEvent extends Event, ExtendableEvent {
    notification: any;
}"><pre class="notranslate"><span class="pl-c">// Type definitions for service_worker_api</span>
<span class="pl-c">// Project: https://developer.mozilla.org/fr/docs/Web/API/ServiceWorker_API</span>
<span class="pl-c">// Definitions by: Tristan Caron &lt;https://github.com/tristancaron&gt;</span>
<span class="pl-c">// Definitions: https://github.com/borisyankov/DefinitelyTyped</span>

<span class="pl-c">// &lt;reference path="../es6-promise/es6-promise.d.ts" /&gt; // REMOVED third "/" so this doesn't fire. Problem with duplicate Promises</span>
<span class="pl-c">// between es6 and typescript - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/5015</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Provides methods relating to the body of the response/request, allowing you</span>
<span class="pl-c"> * to declare what its content type is and how it should be handled.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">Body</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains a Boolean that indicates whether the body has been read.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">bodyUsed</span>: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Takes a Response stream and reads it to completion.</span>
<span class="pl-c">     * It returns a promise that resolves with an ArrayBuffer.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">arrayBuffer</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">ArrayBuffer</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Takes a Response stream and reads it to completion.</span>
<span class="pl-c">     * It returns a promise that resolves with a Blob.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">blob</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Blob</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Takes a Response stream and reads it to completion.</span>
<span class="pl-c">     * It returns a promise that resolves with a FormData object.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">formData</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">FormData</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Takes a Response stream and reads it to completion.</span>
<span class="pl-c">     * It returns a promise that resolves with a JSON object.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">json</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">JSON</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Takes a Response stream and reads it to completion.</span>
<span class="pl-c">     * It returns a promise that resolves with a USVString (text).</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">text</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Text</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Represents response/request headers, allowing you to query them and take</span>
<span class="pl-c"> * different actions depending on the results.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">Header</span> <span class="pl-kos">{</span>
    <span class="pl-k">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Header</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Appends a new value onto an existing header inside a Headers object, or</span>
<span class="pl-c">     * adds the header if it does not already exist.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> name The name of the HTTP header you want to add to the Headers</span>
<span class="pl-c">     * object.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> value The value of the HTTP header you want to add.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">append</span><span class="pl-kos">(</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">value</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Deletes a header from a Headers object.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> name The name of the HTTP header you want to delete from the</span>
<span class="pl-c">     * Headers object.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">delete</span><span class="pl-kos">(</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns the first value of a given header from within a Headers object.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> name The name of the HTTP header whose value you want to retrieve</span>
<span class="pl-c">     * from the Headers object. If the given name is not the name of an</span>
<span class="pl-c">     * HTTP header, this method throws a TypeError.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">get</span><span class="pl-kos">(</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns an array of all the values of a header within a Headers object</span>
<span class="pl-c">     * with a given name.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> name The name of the HTTP header whose values you want to retrieve</span>
<span class="pl-c">     * from the Headers object. If the given name is not the name of an</span>
<span class="pl-c">     * HTTP header, this method throws a TypeError.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">getAll</span><span class="pl-kos">(</span><span class="pl-s1">name</span>:<span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-smi">string</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a boolean stating whether a Headers object contains a</span>
<span class="pl-c">     * certain header.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> name The name of the HTTP header you want to test for. If the</span>
<span class="pl-c">     * given name is not the name of an HTTP header, this method throws</span>
<span class="pl-c">     * a TypeError.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">has</span><span class="pl-kos">(</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Sets a new value for an existing header inside a Headers object, or</span>
<span class="pl-c">     * adds the header if it does not already exist.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> name The name of the HTTP header you want to set to a new value.</span>
<span class="pl-c">     * If the given name is not the name of an HTTP header, this method throws</span>
<span class="pl-c">     * a TypeError.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> value The new value you want to set.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">set</span><span class="pl-kos">(</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">value</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Represents the response to a request.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">Response</span> <span class="pl-k">extends</span> <span class="pl-smi">Body</span> <span class="pl-kos">{</span>
    <span class="pl-k">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Response</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains the URL of the response.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">url</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains a boolean stating whether this is the final URL of the response.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">useFinalURL</span>: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains the status code of the response (e.g., 200 for a success).</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">status</span>: <span class="pl-smi">number</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains a boolean stating whether the response was successful</span>
<span class="pl-c">     * (status in the range 200-299) or not.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">ok</span>: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains the status message corresponding to the status code</span>
<span class="pl-c">     * (e.g., OK for 200).</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">statusText</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Creates a clone of a Response object.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">clone</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Response</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a new Response object associated with a network error.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">error</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Response</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Creates a new response with a different URL.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">redirect</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Response</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Represents a resource request.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">Request</span> <span class="pl-k">extends</span> <span class="pl-smi">Body</span> <span class="pl-kos">{</span>
    <span class="pl-k">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Request</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains the request's method (GET, POST, etc.).</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">method</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains the URL of the request.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">url</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains the context of the request (e.g., audio, image, iframe, etc.).</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">context</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains the referrer of the request (e.g., client).</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">referrer</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>


    <span class="pl-c">/**</span>
<span class="pl-c">     * Creates a copy of the current Request object.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">clone</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Request</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * An CacheOptions object allowing you to set specific control options for the</span>
<span class="pl-c"> * matching done in the match operation.</span>
<span class="pl-c"> *</span>
<span class="pl-c"> * <span class="pl-k">@property</span> [ignoreSearch] A Boolean that specifies whether the matching</span>
<span class="pl-c"> * process should ignore the query string in the url.  If set to true,</span>
<span class="pl-c"> * the ?value=bar part of http://foo.com/?value=bar would be ignored when</span>
<span class="pl-c"> * performing a match. It defaults to false.</span>
<span class="pl-c"> *</span>
<span class="pl-c"> * <span class="pl-k">@property</span> [ignoreMethod] A Boolean that, when set to true, prevents matching</span>
<span class="pl-c"> * operations from validating the Request http method (normally only GET</span>
<span class="pl-c"> * and HEAD are allowed.) It defaults to false.</span>
<span class="pl-c"> *</span>
<span class="pl-c"> * <span class="pl-k">@property</span> [ignoreVary] A Boolean that when set to true tells the matching</span>
<span class="pl-c"> * operation not to perform VARY header matching — i.e. if the URL matches you</span>
<span class="pl-c"> * will get a match regardless of the Response object having a VARY header or</span>
<span class="pl-c"> * not. It defaults to false.</span>
<span class="pl-c"> *</span>
<span class="pl-c"> * <span class="pl-k">@property</span> [cacheName] A DOMString that represents a specific cache to search</span>
<span class="pl-c"> * within. Note that this option is ignored by Cache.match().</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">CacheOptions</span> <span class="pl-kos">{</span>
    <span class="pl-c1">ignoreSearch</span>?: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>
    <span class="pl-c1">ignoreMethod</span>?: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>
    <span class="pl-c1">ignoreVary</span>?: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>
    <span class="pl-c1">cacheName</span>?: <span class="pl-smi">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Represents the storage for Request / Response object pairs that are cached as</span>
<span class="pl-c"> * part of the ServiceWorker life cycle.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">Cache</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a Promise that resolves to the response associated with the first</span>
<span class="pl-c">     * matching request in the Cache object.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> request The Request you are attempting to find in the Cache.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> {<span class="pl-smi">CacheOptions</span>} options</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">match</span><span class="pl-kos">(</span><span class="pl-s1">request</span>: <span class="pl-smi">Request</span> <span class="pl-c1">|</span> <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">options</span>?: <span class="pl-smi">CacheOptions</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Response</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a Promise that resolves to an array of all matching responses in</span>
<span class="pl-c">     * the Cache object.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> request The Request you are attempting to find in the Cache.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> {<span class="pl-smi">CacheOptions</span>} options</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">matchAll</span><span class="pl-kos">(</span><span class="pl-s1">request</span>: <span class="pl-smi">Request</span> <span class="pl-c1">|</span> <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">options</span>?: <span class="pl-smi">CacheOptions</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-smi">Response</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a Promise that resolves to a new Cache entry whose key</span>
<span class="pl-c">     * is the request.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> request The Request you want to add to the cache.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">add</span><span class="pl-kos">(</span><span class="pl-s1">request</span>: <span class="pl-smi">Request</span> <span class="pl-c1">|</span> <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a Promise that resolves to a new array of Cache entries whose</span>
<span class="pl-c">     * keys are the requests.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> request An array of Request objects you want to add to the cache.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">addAll</span><span class="pl-kos">(</span>...<span class="pl-s1">request</span>: <span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-smi">Request</span> <span class="pl-c1">|</span> <span class="pl-smi">string</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Adds additional key/value pairs to the current Cache object.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> request The Request you want to add to the cache.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> response The response you want to match up to the request.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">put</span><span class="pl-kos">(</span><span class="pl-s1">request</span>: <span class="pl-smi">Request</span><span class="pl-kos">,</span> <span class="pl-s1">response</span>: <span class="pl-smi">Response</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Finds the Cache entry whose key is the request, and if found, deletes the</span>
<span class="pl-c">     * Cache entry and returns a Promise that resolves to true. If no Cache</span>
<span class="pl-c">     * entry is found, it returns false.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> request The Request you are looking to delete.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> {<span class="pl-smi">CacheOptions</span>} options</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">delete</span><span class="pl-kos">(</span><span class="pl-s1">request</span>: <span class="pl-smi">Request</span> <span class="pl-c1">|</span> <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">options</span>?: <span class="pl-smi">CacheOptions</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">boolean</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a Promise that resolves to an array of Cache keys.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> request The Request want to return, if a specific key is desired.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> {<span class="pl-smi">CacheOptions</span>} options</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">keys</span><span class="pl-kos">(</span><span class="pl-s1">request</span>?: <span class="pl-smi">Request</span><span class="pl-kos">,</span> <span class="pl-s1">options</span>?: <span class="pl-smi">CacheOptions</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-smi">Request</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Represents the storage for Cache objects. It provides a master directory of</span>
<span class="pl-c"> * all the named caches that a ServiceWorker can access and maintains a mapping</span>
<span class="pl-c"> * of string names to corresponding Cache objects.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">CacheStorage</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Checks if a given Request is a key in any of the Cache objects that the</span>
<span class="pl-c">     * CacheStorage object tracks and returns a Promise that resolves</span>
<span class="pl-c">     * to that match.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> request The Request you are looking for a match for in the CacheStorage.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> {<span class="pl-smi">CacheOptions</span>} options</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">match</span><span class="pl-kos">(</span><span class="pl-s1">request</span>: <span class="pl-smi">Request</span> <span class="pl-c1">|</span> <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">options</span>?: <span class="pl-smi">CacheOptions</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Response</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a Promise that resolves to true if a Cache object matching</span>
<span class="pl-c">     * the cacheName exists.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> cacheName The Request you are looking for a match for in the</span>
<span class="pl-c">     * CacheStorage.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">has</span><span class="pl-kos">(</span><span class="pl-s1">cacheName</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">boolean</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a Promise that resolves to the Cache object matching</span>
<span class="pl-c">     * the cacheName.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> cacheName The name of the cache you want to open.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">open</span><span class="pl-kos">(</span><span class="pl-s1">cacheName</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Cache</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Finds the Cache object matching the cacheName, and if found, deletes the</span>
<span class="pl-c">     * Cache object and returns a Promise that resolves to true. If no</span>
<span class="pl-c">     * Cache object is found, it returns false.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> cacheName The name of the cache you want to delete.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">delete</span><span class="pl-kos">(</span><span class="pl-s1">cacheName</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">boolean</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a Promise that will resolve with an array containing strings</span>
<span class="pl-c">     * corresponding to all of the named Cache objects tracked by the</span>
<span class="pl-c">     * CacheStorage. Use this method to iterate over a list of all the</span>
<span class="pl-c">     * Cache objects.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">keys</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-smi">string</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Represents the scope of a service worker client. A service worker client is</span>
<span class="pl-c"> * either a document in a browser context or a SharedWorker, which is controlled</span>
<span class="pl-c"> * by an active worker.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">ServiceWorkerClient</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Allows a service worker client to send a message to a ServiceWorker.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> message The message to send to the service worker.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [transfer] A transferable object such as, for example, a reference</span>
<span class="pl-c">     * to a port.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">postMessage</span><span class="pl-kos">(</span><span class="pl-s1">message</span>: <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">transfer</span>?: <span class="pl-smi">Object</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Indicates the type of browsing context of the current client.</span>
<span class="pl-c">     * This value can be one of auxiliary, top-level, nested, or none.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">frameType</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns the id of the Client object.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">id</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * The URL of the current service worker client.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">url</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">WindowClient</span> <span class="pl-k">extends</span> <span class="pl-smi">ServiceWorkerClient</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Gives user input focus to the current client.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">focus</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">WindowClient</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * A boolean that indicates whether the current client has focus.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">focused</span>: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Indicates the visibility of the current client. This value can be one of</span>
<span class="pl-c">     * hidden, visible, prerender, or unloaded.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">visibilityState</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">ServiceWorkerClientsMatchOptions</span> <span class="pl-kos">{</span>
    <span class="pl-c1">includeUncontrolled</span>?: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>
    <span class="pl-c1">type</span>?: <span class="pl-smi">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Represents a container for a list of Client objects; the main way to access</span>
<span class="pl-c"> * the active service worker clients at the current origin.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">ServiceWorkerClients</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Gets a list of service worker clients and returns them in a Promise.</span>
<span class="pl-c">     * Include the options parameter to return all service worker clients whose</span>
<span class="pl-c">     * origin is the same as the associated service worker's origin. If options</span>
<span class="pl-c">     * are not included, the method returns only the service worker clients</span>
<span class="pl-c">     * controlled by the service worker.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> options</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">matchAll</span><span class="pl-kos">(</span><span class="pl-s1">options</span>: <span class="pl-smi">ServiceWorkerClientsMatchOptions</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-smi">ServiceWorkerClient</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Opens a service worker Client in a new browser window.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> url A string representing the URL of the client you want to open</span>
<span class="pl-c">     * in the window.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">openWindow</span><span class="pl-kos">(</span><span class="pl-s1">url</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">WindowClient</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Allows an active Service Worker to set itself as the active worker for a</span>
<span class="pl-c">     * client page when the worker and the page are in the same scope.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">claim</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Extends the lifetime of the install and activate events dispatched on the</span>
<span class="pl-c"> * ServiceWorkerGlobalScope as part of the service worker lifecycle. This</span>
<span class="pl-c"> * ensures that any functional events (like FetchEvent) are not dispatched to</span>
<span class="pl-c"> * the ServiceWorker until it upgrades database schemas, deletes outdated cache</span>
<span class="pl-c"> * entries, etc.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">ExtendableEvent</span> <span class="pl-k">extends</span> <span class="pl-smi">Event</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Extends the lifetime of the event.</span>
<span class="pl-c">     * It is intended to be called in the install EventHandler for the</span>
<span class="pl-c">     * installing worker and on the active EventHandler for the active worker.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> all</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">waitUntil</span><span class="pl-kos">(</span><span class="pl-s1">all</span>: <span class="pl-smi">any</span><span class="pl-kos">)</span>: <span class="pl-smi">any</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * The parameter passed into the ServiceWorkerGlobalScope.onfetch handler,</span>
<span class="pl-c"> * FetchEvent represents a fetch action that is dispatched on the</span>
<span class="pl-c"> * ServiceWorkerGlobalScope of a ServiceWorker. It contains information about</span>
<span class="pl-c"> * the request and resulting response, and provides the FetchEvent.respondWith()</span>
<span class="pl-c"> * method, which allows us to provide an arbitrary response back to the</span>
<span class="pl-c"> * controlled page.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">FetchEvent</span> <span class="pl-k">extends</span> <span class="pl-smi">Event</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a Boolean that is true if the event was dispatched with the</span>
<span class="pl-c">     * user's intention for the page to reload, and false otherwise. Typically,</span>
<span class="pl-c">     * pressing the refresh button in a browser is a reload, while clicking a</span>
<span class="pl-c">     * link and pressing the back button is not.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">isReload</span>: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns the Request that triggered the event handler.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">request</span>: <span class="pl-smi">Request</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns the Client that the current service worker is controlling.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">client</span>: <span class="pl-smi">ServiceWorkerClient</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Resolves by returning a Response or a network error to Fetch.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> all</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">respondWith</span><span class="pl-kos">(</span><span class="pl-s1">all</span>: <span class="pl-smi">any</span><span class="pl-kos">)</span>: <span class="pl-smi">Response</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Represents a service worker. Multiple browsing contexts (e.g. pages, workers,</span>
<span class="pl-c"> * etc.) can be associated with the same ServiceWorker object.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">ServiceWorker</span> <span class="pl-k">extends</span> <span class="pl-smi">Worker</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns the ServiceWorker serialized script URL defined as part of</span>
<span class="pl-c">     * ServiceWorkerRegistration. The URL must be on the same origin as the</span>
<span class="pl-c">     * document that registers the ServiceWorker.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">scriptURL</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns the state of the service worker. It returns one of the following</span>
<span class="pl-c">     * values: installing, installed, activating, activated, or redundant.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">state</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An EventListener property called whenever an event of type statechange</span>
<span class="pl-c">     * is fired; it is basically fired anytime the ServiceWorker.state changes.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [statechangeevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onstatechange</span>: <span class="pl-kos">(</span><span class="pl-s1">statechangeevent</span>?: <span class="pl-smi">any</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * The PushSubscription interface provides a subcription's URL endpoint and</span>
<span class="pl-c"> * subscription ID.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">PushSubscription</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * The endpoint associated with the push subscription.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">endpoint</span>: <span class="pl-smi">any</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * The subscription ID associated with the push subscription.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">subscriptionId</span>: <span class="pl-smi">any</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * The PushManager interface provides a way to receive notifications from</span>
<span class="pl-c"> * third-party servers as well as request URLs for push notifications.</span>
<span class="pl-c"> * This interface has replaced functionality offered by the obsolete</span>
<span class="pl-c"> * PushRegistrationManager.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">PushManager</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a promise that resolves to a PushSubscription with details of a</span>
<span class="pl-c">     * new push subscription.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">subscribe</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">PushSubscription</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a promise that resolves to a PushSubscription details of</span>
<span class="pl-c">     * the retrieved push subscription.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">getSubscription</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">PushSubscription</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a promise that resolves to the PushPermissionStatus of the</span>
<span class="pl-c">     * requesting webapp, which will be one of granted, denied, or default.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">hasPermission</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">any</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Represents a service worker registration.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">ServiceWorkerRegistration</span> <span class="pl-k">extends</span> <span class="pl-smi">EventTarget</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a unique identifier for a service worker registration.</span>
<span class="pl-c">     * This must be on the same origin as the document that registers</span>
<span class="pl-c">     * the ServiceWorker.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">scope</span>: <span class="pl-smi">any</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a service worker whose state is installing. This is initially</span>
<span class="pl-c">     * set to null.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">installing</span>: <span class="pl-smi">ServiceWorker</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a service worker whose state is installed. This is initially</span>
<span class="pl-c">     * set to null.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">waiting</span>: <span class="pl-smi">ServiceWorker</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a service worker whose state is either activating or activated.</span>
<span class="pl-c">     * This is initially set to null. An active worker will control a</span>
<span class="pl-c">     * ServiceWorkerClient if the client's URL falls within the scope of the</span>
<span class="pl-c">     * registration (the scope option set when ServiceWorkerContainer.register</span>
<span class="pl-c">     * is first called).</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">active</span>: <span class="pl-smi">ServiceWorker</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns an interface to for managing push subscriptions, including</span>
<span class="pl-c">     * subcribing, getting an anctive subscription, and accessing push</span>
<span class="pl-c">     * permission status.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">pushManager</span>: <span class="pl-smi">PushManager</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An EventListener property called whenever an event of type updatefound</span>
<span class="pl-c">     * is fired; it is fired any time the ServiceWorkerRegistration.installing</span>
<span class="pl-c">     * property acquires a new service worker.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onupdatefound</span>: <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Allows you to update a service worker.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">update</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Unregisters the service worker registration and returns a promise</span>
<span class="pl-c">     * (see Promise). The service worker will finish any ongoing operations</span>
<span class="pl-c">     * before it is unregistered.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">unregister</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">boolean</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">ServiceWorkerRegisterOptions</span> <span class="pl-kos">{</span>
    <span class="pl-c1">scope</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * Provides an object representing the service worker as an overall unit in the</span>
<span class="pl-c"> * network ecosystem, including facilities to register, unregister and update</span>
<span class="pl-c"> * service workers, and access the state of service workers</span>
<span class="pl-c"> * and their registrations.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">ServiceWorkerContainer</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a ServiceWorker object if its state is activated (the same object</span>
<span class="pl-c">     * returned by ServiceWorkerRegistration.active). This property returns null</span>
<span class="pl-c">     * if the request is a force refresh (Shift + refresh) or if there is no</span>
<span class="pl-c">     * active worker.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">controller</span>: <span class="pl-smi">ServiceWorker</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Defines whether a service worker is ready to control a page or not.</span>
<span class="pl-c">     * It returns a Promise that will never reject, which resolves to a</span>
<span class="pl-c">     * ServiceWorkerRegistration with an ServiceWorkerRegistration.active worker.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">ready</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">ServiceWorkerRegistration</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever a controllerchange event occurs — when</span>
<span class="pl-c">     * the document's associated ServiceWorkerRegistration acquires a new</span>
<span class="pl-c">     * ServiceWorkerRegistration.active worker.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [controllerchangeevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">oncontrollerchange</span>: <span class="pl-kos">(</span><span class="pl-s1">controllerchangeevent</span>?: <span class="pl-smi">Event</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever an error event occurs in the associated</span>
<span class="pl-c">     * service workers.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [errorevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onerror</span>: <span class="pl-kos">(</span><span class="pl-s1">errorevent</span>?: <span class="pl-smi">ErrorEvent</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever a message event occurs — when incoming</span>
<span class="pl-c">     * messages are received to the ServiceWorkerContainer object (e.g. via a</span>
<span class="pl-c">     * MessagePort.postMessage() call.)</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [messageevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onmessage</span>: <span class="pl-kos">(</span><span class="pl-s1">messageevent</span>?: <span class="pl-smi">MessageEvent</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Creates or updates a ServiceWorkerRegistration for the given scriptURL.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> scriptURL The URL of the service worker script.</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [options] An options object to provide options upon registration.</span>
<span class="pl-c">     * Currently available options are: scope: A USVString representing a URL</span>
<span class="pl-c">     * that defines a service worker's registration scope; what range of URLs a</span>
<span class="pl-c">     * service worker can control. This is usually a relative URL, and it</span>
<span class="pl-c">     * defaults to '/' when not specified.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">register</span><span class="pl-kos">(</span><span class="pl-s1">scriptURL</span>: <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">options</span>?: <span class="pl-smi">ServiceWorkerRegisterOptions</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">ServiceWorkerRegistration</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Gets a ServiceWorkerRegistration object whose scope URL matches the</span>
<span class="pl-c">     * provided document URL.  If the method can't return a</span>
<span class="pl-c">     * ServiceWorkerRegistration, it returns a Promise.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [scope] A unique identifier for a service worker registration — the</span>
<span class="pl-c">     * scope URL of the registration object you want to return. This is usually</span>
<span class="pl-c">     * a relative URL.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">getRegistration</span><span class="pl-kos">(</span><span class="pl-s1">scope</span>?: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">ServiceWorkerRegistration</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns all ServiceWorkerRegistrations associated with a</span>
<span class="pl-c">     * ServiceWorkerContainer in an array.  If the method can't return</span>
<span class="pl-c">     * ServiceWorkerRegistrations, it returns a Promise.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">getRegistrations</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-smi">ServiceWorkerRegistration</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c">/**</span>
<span class="pl-c"> * The parameter passed into the oninstall handler, the InstallEvent interface</span>
<span class="pl-c"> * represents an install action that is dispatched on the</span>
<span class="pl-c"> * ServiceWorkerGlobalScope of a ServiceWorker. As a child of ExtendableEvent,</span>
<span class="pl-c"> * it ensures that functional events such as FetchEvent are not dispatched</span>
<span class="pl-c"> * during installation.</span>
<span class="pl-c"> */</span>
<span class="pl-k">interface</span> <span class="pl-smi">InstallEvent</span> <span class="pl-k">extends</span> <span class="pl-smi">ExtendableEvent</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns the ServiceWorker that is currently actively controlling the page.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">activeWorker</span>: <span class="pl-smi">ServiceWorker</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">ServiceWorkerGlobalScope</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains the Clients object associated with the service worker.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">clients</span>: <span class="pl-smi">ServiceWorkerClients</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Contains the ServiceWorkerRegistration object that represents the</span>
<span class="pl-c">     * service worker's registration.</span>
<span class="pl-c">     * <span class="pl-k">@readonly</span></span>
<span class="pl-c">     */</span>
    <span class="pl-c1">registration</span>: <span class="pl-smi">ServiceWorkerRegistration</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever an activate event occurs — when a</span>
<span class="pl-c">     * ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.active</span>
<span class="pl-c">     * worker.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [activateevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onactivate</span>: <span class="pl-kos">(</span><span class="pl-s1">activateevent</span>?: <span class="pl-smi">ExtendableEvent</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Not defined in the spec yet, but it looks like this will be fired when</span>
<span class="pl-c">     * the device is nearly out of storage space, prompting the UA to start</span>
<span class="pl-c">     * claiming back some space from web apps that are using client-side storage,</span>
<span class="pl-c">     * and the current app is targeted.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [beforeevictedevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onbeforeevicted</span>: <span class="pl-kos">(</span><span class="pl-s1">beforeevictedevent</span>?: <span class="pl-smi">Event</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Not defined in the spec yet, but it looks like this will be fired when</span>
<span class="pl-c">     * the device is out of storage space, and the UA claims back some space</span>
<span class="pl-c">     * from the current app.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [evictedevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onevicted</span>: <span class="pl-kos">(</span><span class="pl-s1">evictedevent</span>?: <span class="pl-smi">Event</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever a fetch event occurs — when a fetch()</span>
<span class="pl-c">     * is called.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [fetchevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onfetch</span>: <span class="pl-kos">(</span><span class="pl-s1">fetchevent</span>?: <span class="pl-smi">FetchEvent</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever an install event occurs — when a</span>
<span class="pl-c">     * ServiceWorkerRegistration acquires a new</span>
<span class="pl-c">     * ServiceWorkerRegistration.installing worker.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [installevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">oninstall</span>: <span class="pl-kos">(</span><span class="pl-s1">installevent</span>?: <span class="pl-smi">InstallEvent</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever a message event occurs — when incoming</span>
<span class="pl-c">     * messages are received. Controlled pages can use the</span>
<span class="pl-c">     * MessagePort.postMessage() method to send messages to service workers.</span>
<span class="pl-c">     * The service worker can optionally send a response back via the</span>
<span class="pl-c">     * MessagePort exposed in event.data.port, corresponding to the controlled</span>
<span class="pl-c">     * page.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [messageevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onmessage</span>: <span class="pl-kos">(</span><span class="pl-s1">messageevent</span>?: <span class="pl-smi">MessageEvent</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever a notificationclick event occurs — when</span>
<span class="pl-c">     * a user clicks on a displayed notification.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [notificationclickevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onnotificationclick</span>: <span class="pl-kos">(</span><span class="pl-s1">notificationclickevent</span>?: <span class="pl-smi">NotificationEvent</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever a push event occurs — when a server</span>
<span class="pl-c">     * push notification is received.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [onpushevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onpush</span>: <span class="pl-kos">(</span><span class="pl-s1">onpushevent</span>?: <span class="pl-smi">Event</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * An event handler fired whenever a pushsubscriptionchange event occurs —</span>
<span class="pl-c">     * when a push subscription has been invalidated, or is about to be</span>
<span class="pl-c">     * invalidated (e.g. when a push service sets an expiration time).</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span> [pushsubscriptionchangeevent]</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">onpushsubscriptionchange</span>: <span class="pl-kos">(</span><span class="pl-s1">pushsubscriptionchangeevent</span>?: <span class="pl-smi">Event</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Allows the current service worker registration to progress from waiting</span>
<span class="pl-c">     * to active state while service worker clients are using it.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">skipWaiting</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * TODO GlobalFetch</span>
<span class="pl-c">     * <span class="pl-k">@param</span> url</span>
<span class="pl-c">     * <span class="pl-k">@param</span> init</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">fetch</span><span class="pl-kos">(</span><span class="pl-s1">url</span>: <span class="pl-smi">string</span> <span class="pl-c1">|</span> <span class="pl-smi">Request</span><span class="pl-kos">,</span> <span class="pl-s1">init</span>?: <span class="pl-smi">Object</span><span class="pl-kos">)</span>: <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi">Response</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">Navigator</span> <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Returns a ServiceWorkerContainer object, which provides access to</span>
<span class="pl-c">     * registration, removal, upgrade, and communication with the ServiceWorker</span>
<span class="pl-c">     * objects for the associated document.</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">serviceWorker</span>: <span class="pl-smi">ServiceWorkerContainer</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">Global</span> <span class="pl-k">extends</span> <span class="pl-smi">ServiceWorkerGlobalScope</span> <span class="pl-kos">{</span>
    <span class="pl-c1">caches</span>: <span class="pl-smi">CacheStorage</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">NotificationEvent</span> <span class="pl-k">extends</span> <span class="pl-smi">Event</span><span class="pl-kos">,</span> <span class="pl-smi">ExtendableEvent</span> <span class="pl-kos">{</span>
    <span class="pl-c1">notification</span>: <span class="pl-smi">any</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
</details>
<p dir="auto">//cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/tristancaron/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/tristancaron">@tristancaron</a></p>
<p dir="auto">Using @types/sequelize 4.28.6 (latest stable).</p>
<p dir="auto">QueryInterface.bulkInsert accepts string as first parameter, it should accept string | {schema: string, tableName: string}. I was going to create a pull request but I wasn't sure which of the many branches to use.</p>
<p dir="auto">The fix can be made in: query.interface.d.ts</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/jonmagic/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/jonmagic">@jonmagic</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/tdreyno/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/tdreyno">@tdreyno</a></p>