See https://github.com/cheeriojs/cheerio/blob/v1.0.0/types/index.d.ts
The interface Cheerio is declared but not exported. It leads to TS compilation errors in projects, that need it. E.G. https://github.com/vuejs/vue-test-utils/issues/1737
Feel free to open a PR to add this!
Looking at your link, it seems like the issue is that we export a value type. If all that's needed is a typeof, the additional export does not really seem worth it.
Looking at your link, it seems like the issue is that we export a value type. If all that's needed is a
typeof, the additional export does not really seem worth it.
Consider this code when using [email protected]:
function getTrimmedText(el: cheerio.Cheerio): string {
return el.text().trim()
}
const $ = cheerio.load(html)
const trimmedText = getTrimmedText($('#text'))
How can I type an argument for a function getTrimmedText in [email protected]? typeof cheerio will return cheerio.CheerioAPI which is not the same as cheerio.Cheerio.
I think this issue should be reopened.
After further investigation I think declaring type Cheerio = ReturnType<typeof cheerio> works. But it's not obvious in comparison with @types/cheerio
Most helpful comment
After further investigation I think declaring
type Cheerio = ReturnType<typeof cheerio>works. But it's not obvious in comparison with@types/cheerio