Janpot / microdata-node

Cheerio based microdata parser
MIT License
57 stars 7 forks source link

Types for TypeScript #19

Open raine opened 4 years ago

raine commented 4 years ago

You added some kind of types in https://github.com/Janpot/microdata-node/commit/74442079eb33c5f0f1124e9f20caf4193e46f44b but they don't seem to be available when using this module from TypeScript.

error TS7016: Could not find a declaration file for module 'microdata-node'. 'node_modules/microdata-node/src/index.js' implicitly has an 'any' type.
  Try `npm install @types/microdata-node` if it exists or add a new declaration (.d.ts) file containing `declare module 'microdata-node';`
Janpot commented 4 years ago

Can you try to enable checkJs in your tsconfig.json? For now the types are strictly internal, I'm not sure I want to introduce a build step at this point.

raine commented 4 years ago

No effect. I wonder if that setting applies only to project files and not dependencies.

raine commented 4 years ago

This worked:

"include": ["node_modules/microdata-node/src/**/*.js"]

Looks like config is incorrectly defined as required parameter to toJson. It's optional in README.

scripts/run.ts:21:39 - error TS2554: Expected 2 arguments, but got 1.

21     require('util').inspect(microdata.toJson(html), {
                                         ~~~~~~~~~~~~~~~~~~

  node_modules/microdata-node/src/index.js:59:33
    59 function toJson (microdataHtml, config) {
                                       ~~~~~~
    An argument for 'config' was not provided.