mljs/distance

Typescript dependencies are missing

Opened this issue · 1 comments

cheminfo-types and ml-tree-similarity are not dev dependencies when using this (or a package that uses this like LangChain) within a Typescript project.

node_modules/ml-distance/lib/similarities/tanimoto.d.ts:1:29 - error TS2307: Cannot find module 'cheminfo-types' or its corresponding type declarations.
                                                                                                   
1 import { NumberArray } from 'cheminfo-types';            

node_modules/ml-distance/lib/similarities.d.ts:1:23 - error TS7016: Could not find a declaration file for module 'ml-tree-similarity'. '[path]/node_modules/ml-distance/node_modules/ml-tree-similarity/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/ml-tree-similarity` if it exists or add a new declaration (.d.ts) file containing `declare module 'ml-tree-similarity';`

1 import * as tree from 'ml-tree-similarity';                                        

Reproduce

  • create a new test directory
  • run npm init -y
  • run npm install ml-distance typescript
  • create an index.ts file with the import import { distance, similarity } from 'ml-distance';
  • run npx tsc index.ts
  • observe errors
  • run npm install cheminfo-types
  • run npx tsc index.ts again
  • observe errors are gone

The same happens for ml-tree-similarty when in a project that references lib/similarity.d.ts because it's generated without the expect error comment. I think the types should be fully passed through but if you don't intend them to you need to make sure the errors don't propagate.

Same problem here.

I Just set "skipLibCheck": true in tsconfig.json

can bypass the d.ts checking