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

index.d.ts not up to date for .load (missing isDocument) #2265

Closed
MeStrak opened this issue Dec 20, 2021 · 2 comments
Closed

index.d.ts not up to date for .load (missing isDocument) #2265

MeStrak opened this issue Dec 20, 2021 · 2 comments

Comments

@MeStrak
Copy link

MeStrak commented Dec 20, 2021

Hello there,

I'm using Typescript with v1.0rc-10, and I was trying to use .load with the isDocument parameter documented here: https://cheerio.js.org/interfaces/CheerioAPI.html. I found something weird with index.d.ts.

This is my code:

private cheerioBody = cheerio.load(myHtml, null, false);

I get the following type error Expected 1-2 arguments, but got 3. I noticed the same problem reported here but the issue was closed: #1697.

I checked index.d.ts from the installed npm package and it looks like the isDocument parameter is missing:

interface CheerioAPI extends Root {
        version: string;
        load(html: string | Buffer, options?: CheerioParserOptions): Root;
        load(element: Element | Element[], options?: CheerioParserOptions): Root;
    }

I assume that it should contain isDocument as an optional (even thought it is not currently defined as optional in the code) like below:

interface CheerioAPI extends Root {
        version: string;
        load(html: string | Buffer, options?: CheerioParserOptions, isDocument?: boolean): Root;
        load(element: Element | Element[], options?: CheerioParserOptions, isDocument?: boolean): Root;
    }

The source load,ts does contain this parameter (although not as optional), so I'm not sure why it does not appear in index.d.ts:

isDocument = true
.

@fb55
Copy link
Member

fb55 commented Dec 21, 2021

Is this the index.d.ts from @types/cheerio? If that's the case: That module isn't required anymore, as Cheerio ships with TypeScript types itself now.

@MeStrak
Copy link
Author

MeStrak commented Dec 21, 2021

You're right 😃

I hadn't noticed that @types was still left in devDependencies from an upgrade a while back.

Thanks for the tip!

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

No branches or pull requests

2 participants