Quasar project with TypeScript show error when importing 3rd party libraries



  • I have created a Quasar CLI project using TypeScript. It’s all very impressing, but now I’m facing a problem importing 3rd party libraries (cheerio, jQuery or similar).

    I have a Index.vue file, where I’m fetching HTML/XML from an API. I need to find different nodes in the HTML/XML based on classes etc., hence I thought of using jQuery or cheerio to CSS select the node(s) I need.

    When importing cheerio:

    import {cheerio} from 'cheerio';
    

    I get the error:

    Could not find a declaration file for module 'cheerio'. 
    '/node_modules/cheerio/index.js' implicitly has an 'any' type.
      Try `npm install @types/cheerio` if it exists 
    or add a new declaration (.d.ts) file 
    containing `declare module 'cheerio';`Vetur(7016)
    

    Installing cheerio types does not work:

    npm install @types/cheerio
    

    If I look into node_modules/@types, there is a cheerio/index.d.ts file

    Any idea why this does not work out of the box with Quasar?


Log in to reply