static `text()` method is not actually exported
See original GitHub issueAs mentioned in the README:
You may also render the text content of a Cheerio object using the text static method:
const $ = cheerio.load('This is <em>content</em>.');
cheerio.text($('body'));
//=> This is content.
Yet neither index.d.ts
nor index.js
actually forwards text
from lib/static.{d.ts,js}
(it appears to re-export methods one-by-one for some reason, and misses text
).
As a workaround I tried importing static directly, but it doesnt like it.
Using import {text} from 'cheerio/lib/static'
gets past typescript complaints, but for some reason doesn’t transpile to mjs well.
So [at least in typescript targeting ES2020 using modules] it’s impossible to use the text static method.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Class with static methods vs exported functions typescript
I've inherited a code base where the team is using classes with static methods instead of functions for helper methods. I've never seen...
Read more >Export-CSV but append static text in one column? - TechNet
I have a script I've cobbled together which exports about 5 columns of server info to CSV. Actually, I have *several* scripts.
Read more >Static methods from classes exported as default are not made ...
I'm documenting this behavior in the examples below. I have used ns[Math.random() < 2 && 'name'] to test for dynamic property accesses since ......
Read more >export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the ......
Read more >16. Modules - Exploring JS
Can I use destructuring in an import statement? 16.9.5. Are named exports necessary? Why not default-export objects? 16.9.6. Can I eval() the code...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like this is a document bug; see #2286 for what it apparently actually should be. Also for
cheerio.html()
missing.I’m happy to accept a PR that adds the missing exports. Agreed they should be there.