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

fixing outdate type cheerio on the reference module using Cheerio ins… #194

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

fadingNA
Copy link
Contributor

@fadingNA fadingNA commented Oct 1, 2024

Fixed TypeScript Typings in index.d.ts:

  • Updated the ScrapeOptionElement interface to correctly type the element parameter in the how function as Cheerio, which provides proper typings and autocompletion for Cheerio methods.
export interface ScrapeOptionElement {
        selector?: string;
        convert?: (value: any) => any;
        how?: string | ((element: Cheerio) => any); // Updated type
}
  • By importing Cheerio from the Cheerio type definitions and using it in the how function, TypeScript now recognizes the element parameter correctly.

Added TypeScript Example index-type.ts

  • Created a new example file example/index-type.ts to demonstrate how to use scrape-it with TypeScript.
  • The example includes both Promise-based and async/await usage.
  • It shows how to scrape a website and use the how function with proper typings

Thanks for review.
@IonicaBizau

@fadingNA
Copy link
Contributor Author

fadingNA commented Oct 1, 2024

Screenshot 2024-10-01 at 6 52 51 PM

Passed all test cases.

@fadingNA
Copy link
Contributor Author

fadingNA commented Oct 4, 2024

@IonicaBizau Please review if you have a free time

Thanks

@IonicaBizau IonicaBizau mentioned this pull request Oct 4, 2024
@IonicaBizau IonicaBizau merged commit 5ea7fd5 into IonicaBizau:master Oct 4, 2024
@fadingNA fadingNA deleted the issue-193-type-error branch October 10, 2024 21:35
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

Successfully merging this pull request may close these issues.

Type error with the how field of type ScrapeOptionElement
2 participants