question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider owning @types/cheerio type definitions

See original GitHub issue

Problem

In the early days, jQuery familiarity was one of the main attractions to Cheerio. Nowadays it may be more of a hindrence.

For example, it’s confusing that Cheerio’s $(selector).each(fn) has a different argument order than ES5’s forEach.

const fruits = [];

$('li').each(function(i, elem) {
  fruits[i] = $(this).text();
});

fruits.join(', ');
//=> Apple, Orange, Pear

Potential Solution

One way to reduce the friction is to have autocomplete. We currently support some autocomplete via JSDoc but the type definitions would take it a step further.

Some wonderful folks have been maintaining @types/cheerio. Installing this extra package is quite obvious for Typescript users but less obvious for Javascript developers.

We could make this simpler by hosting those types within the Cheerio repository. This would be one less thing to install and the type definitions would get picked up for Javascript users.

Downsides

  • The maintenance burden is now on the Cheerio maintainers.
  • Any other downsides?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
fb55commented, Dec 8, 2020

Fixed in #1491

2reactions
paulmelnikowcommented, Oct 12, 2020

I suppose we should hold off on deprecating the DT types until the 1.0.0 release is made.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@types/cheerio - npm
TypeScript definitions for Cheerio. Latest version: 0.22.31, ... Start using @types/cheerio in your project by running `npm i @types/cheerio`.
Read more >
Cheerio `this` object in TypeScript make "TS2683
First install Cheerio types in the terminal: npm i @types/cheerio. Next import Cheerio: import cheerio from 'cheerio';.
Read more >
@types/cheerio 0.22.31 on npm - Libraries.io
TypeScript definitions for Cheerio - 0.22.31 - a TypeScript package ... When a package bundles its own types, types should be removed from ......
Read more >
@types/cheerio | Yarn - Package Manager
This package contains type definitions for Cheerio (https://github.com/cheeriojs/cheerio). Details.
Read more >
Cheerios Oat Crunch Almond | Whole Grain Cereal
Most cereals have vanilla flavor. I hate vanilla. Tje almond in this was a nice surprise. It is a tad strong. I think...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found