Skip to content

Wrong types ? #3

@ThalusA

Description

@ThalusA

Hi, it seems you are using & to merge two different types but that's not how it works in TypeScript, if you do A & B B properties won't overwrite A properties. If you want to do so you can do an helper type like type Merge<A, B> = Omit<A, keyof B> & B;.

This make typing non usable like so

Image

It should say : all: [string, string, { [key: string]: string }][]; // TODO: see above comment on iterator``
Are you also sure that every single types of the object should me a string ? Key are always string sure, but values always string ? I can't put numbers ?
Shouldn't all those method be async too ? And all method is also not a method in types ?

I overwrote this type to :

type DocumentsDatabase<T, E extends object> = {
    type: "documents";
    put: (doc: E) => Promise<void>;
    del: (key: string) => Promise<void>;
    get: (key: string) => Promise<E | null>;
    iterator: (args: { amount: number }) => Promise<Iterable<[string, string, E]>>;
    query: (findFn: (doc: E) => boolean) => Promise<E[]>;
    indexBy: T;
    all: () => Promise<[string, string, E][]>;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions