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

Feature Request: export Root from the types #1649

Closed
Allain55 opened this issue Jan 4, 2021 · 3 comments · Fixed by #1682
Closed

Feature Request: export Root from the types #1649

Allain55 opened this issue Jan 4, 2021 · 3 comments · Fixed by #1682

Comments

@Allain55
Copy link

Allain55 commented Jan 4, 2021

Hi,
It would be great if the type Root would be accessible outside. Eg. when I pass around the result of the load method I'd need to use the Root type, the default export is not good in this case.

@5saviahv
Copy link
Contributor

5saviahv commented Jan 5, 2021

Can you provide some code.

I believe you wanted use cheerio.load

const $ = cheerio.load(rootElement)

but you didn't know how to get that rootElement ?

@Allain55
Copy link
Author

Allain55 commented Jan 5, 2021

Hi,
yes I want to use the type of the result of cheerio.load, for example in a ts file:

import {Root} from 'cheerio';

function getHtml($: Root) {
    return $.root();
}

Root would be exported in types/index.d.ts. Now only CheerioAPI is exported.
The Cheerio interface could be useful too

@fb55
Copy link
Member

fb55 commented Jan 5, 2021

For now, there is a solution in #1540. I agree that having this interface would be useful and we might add this in the future.

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

Successfully merging a pull request may close this issue.

3 participants