nextapps-de / flexsearch

Next-Generation full text search library for Browser and Node.js
Apache License 2.0
12.49k stars 491 forks source link

Please remove incorrect index.d.ts from the published package #392

Closed dhdaines closed 10 months ago

dhdaines commented 1 year ago

The types in index.d.ts are quite incorrect, whereas the third-party ones in DefinitelyTyped (@types/flexsearch) appear to be correct.

Unfortunately TypeScript will prefer to use the ones in the package... the advice on the internet seems to be just to downgrade FlexSearch, presumably to a version where index.d.ts is correct. This seems like bad advice.

Please fix the types or simply remove them so the library can be used from TypeScript.

dhdaines commented 1 year ago

Note that the best workaround for the moment is to use the paths option in tsconfig.json to override the built-in types, as per https://stackoverflow.com/questions/41558661/ignore-bundled-d-ts-and-use-external-declarations (actually I am surprised this is not a more common situation with NPM modules given their highly variable code quality):

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "flexsearch": ["node_modules/@types/flexsearch"]
    }
  }
}
Theaninova commented 1 year ago

I'm using patches with patch-package. Not the best solution but it works.