Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript types package #88

Open
moodysalem opened this issue Dec 22, 2018 · 5 comments
Open

TypeScript types package #88

moodysalem opened this issue Dec 22, 2018 · 5 comments

Comments

@moodysalem
Copy link

moodysalem commented Dec 22, 2018

I wrote it for my project, please just include it in this project. Thanks for your work!

declare namespace PouchDB {
  interface SearchQuery<Content> {
    // Search string
    query?: string;

    // Or build the index
    build?: true;

    // Fields to search over
    fields: ((keyof Content)[]) | ({ [field in keyof Content]: number });

    limit?: number;
    skip?: number;

    mm?: string;

    filter?: (content: Content) => boolean;

    include_docs?: boolean;
    highlighting?: boolean;
    highlighting_pre?: string;
    highlighting_post?: string;

    stale?: 'update_after' | 'ok';

    language?: string | string[];

    destroy?: true;
  }

  interface SearchRow<T> {
    id: string;
    score: number;
    doc: T & { _id: string; _rev: string; };
  }

  interface SearchResponse<T> {
    rows: Array<SearchRow<T>>;
    total_rows: number;
  }

  interface Database<Content extends {} = {}> {
    search(query: SearchQuery<Content>): SearchResponse<Content>;
  }
}

declare module 'pouchdb-quick-search' {
  const plugin: PouchDB.Plugin;
  export = plugin;
}
@dsabanin
Copy link

Thanks @moodysalem! Did you try submitting them to @DefinitelyTyped instead?

@EcoFreak
Copy link

EcoFreak commented May 9, 2019

@moodysalem how did you implement this on your angular project?

@moodysalem
Copy link
Author

You can copy the content to a .d.ts file in your project. I haven’t submit to definitely typed but it’s nicer if the types are included in the package

@EcoFreak
Copy link

EcoFreak commented May 9, 2019

After including the content to the file, how do I import the file to be considered?
I'm used to importing @types/....

Thanks :)

@armin-th
Copy link

armin-th commented Dec 9, 2019

👍 Agree that it should be included in package thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants