Skip to content

Support Async Storage interface in ExternalsOptions #275

@unadlib

Description

@unadlib

I'm getting a type error when passing a localforage instance to the localStorage property in ExternalsOptions.

Type 'LocalForage' is not assignable to type 'Storage'.
  Types of property 'length' are incompatible.
    Type '(callback?: ((err: any, numberOfKeys: number) => void) | undefined) => Promise<number>' is not assignable to type 'number'.ts(2322)

This is likely because the ExternalsOptions type is not currently compatible with the asynchronous storage interface. The relevant code is as follows:

export interface ExternalsOptions {
    fetch?: typeof fetch;
    Request?: typeof Request;
    Response?: typeof Response;
    Headers?: typeof Headers;
    localStorage?: Storage;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions