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 Fixes were not merged #121

Closed
actraiser opened this issue Dec 9, 2018 · 3 comments
Closed

Typescript Fixes were not merged #121

actraiser opened this issue Dec 9, 2018 · 3 comments
Labels

Comments

@actraiser
Copy link

actraiser commented Dec 9, 2018

I believe that the fixes provided in #116 were not correctly merged and hence not included in the 5.1.1 release of scrape-it.

The index.d.ts in current scrape-it 5.1.1

declare namespace scrapeIt {
    export interface ScrapeOptions {
        [key: string]: string | ScrapeOptionListWithData | ScrapeOptionListWithConvert | ScrapeOptionElement;
    }

    export interface ScrapeOptionElement {
        selector?: string;
        convert?: (value: any) => any;
        how?: string | ((element: CheerioSelector) => any);
        attr?: string;
        trim?: boolean;
        closest?: string;
        eq?: number;
        texteq?: number;
    }

    export interface ScrapeOptionList {
        listItem: string;
        data?: ScrapeOptions;
        convert?: (value: any) => any;
    }

    export interface ScrapeResult<T> {
        data: T,
        $: Cheerio,
        response: any,
        body: string
    }

    export function scrapeHTML<T>(body: CheerioStatic | string, options: ScrapeOptions): T;
}

declare function scrapeIt<T>(url: string | object, opts: scrapeIt.ScrapeOptions): Promise<scrapeIt.ScrapeResult<T>>;

declare function scrapeIt<T>(url: string | object, opts: scrapeIt.ScrapeOptions, cb: (err: any, res: scrapeIt.ScrapeResult<T>) => void): void;
export = scrapeIt;

The fixed version of index.d.ts (as provided in the pull request) should be

declare namespace scrapeIt {
  export interface ScrapeOptions {
      [key: string]: string | ScrapeOptionList | ScrapeOptionElement;
  }

  export interface ScrapeOptionElement {
      selector?: string;
      convert?: (value: any) => any;
      how?: string | ((element: CheerioSelector) => any);
      attr?: string;
      trim?: boolean;
      closest?: string;
      eq?: number;
      texteq?: number;
  }

  export interface ScrapeOptionList {
      listItem: string;
      data?: ScrapeOptions;
      convert?: (value: any) => any;
  }

  export interface ScrapeResult<T> {
      data: T,
      $: Cheerio,
      response: any,
      body: string
  }

  export function scrapeHTML<T>(body: CheerioStatic | string, options: ScrapeOptions): T;
}

declare function scrapeIt<T>(url: string | object, opts: scrapeIt.ScrapeOptions): Promise<scrapeIt.ScrapeResult<T>>;

declare function scrapeIt<T>(url: string | object, opts: scrapeIt.ScrapeOptions, cb: (err: any, res: scrapeIt.ScrapeResult<T>) => void): void;
export = scrapeIt;

So with the current 5.1.1 release Typescript is (still) complaining:

node_modules/scrape-it/lib/index.d.ts:3:33 - error TS2304: Cannot find name 'ScrapeOptionListWithData'.

3         [key: string]: string | ScrapeOptionListWithData | ScrapeOptionListWithConvert | ScrapeOptionElement;
                                  ~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/scrape-it/lib/index.d.ts:3:60 - error TS2304: Cannot find name 'ScrapeOptionListWithConvert'.

3         [key: string]: string | ScrapeOptionListWithData | ScrapeOptionListWithConvert | ScrapeOptionElement;

@IonicaBizau, could you kindly recheck the pull request and release an updated library version?

Greets
-act

@aa900031
Copy link

same problem

@IonicaBizau
Copy link
Owner

Can you check now?

@actraiser
Copy link
Author

Perfect, works! Thank you @IonicaBizau!

-act

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

No branches or pull requests

3 participants