#'this' implicitly has type 'any' because it does not have a type annotation.

3 messages · Page 1 of 1 (latest)

flint oyster
#

I think I can solve this by adding type annotations, but I am using a package so I don't know which type to use

#

The package is Cheerio, I have installed types/cheerio but I still can't use the types it seems

#
function traverseOutline(elements, level : number) {
  elements.each(function() {
    const element = $(this);
    const title = element.text().trim(); // get the title of the element
    const indent = '<OUTLINE_LEVEL_' + level + '>'; // create the indent level string

    console.log(indent + title); // print the title and indent level

    const subElements = element.children('ul').children(); // get the sub-elements of the current element
    if (subElements.length > 0) {
      traverseOutline(subElements, level + 1); // recursively traverse the sub-elements with an increased indent level
    }
  });
}