question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect type definitions

See original GitHub issue

The supplied type definitions are not correct importing the Index as such:

import { Index } from 'flexsearch';
const index = new Index();

results in the error: 'Index' only refers to a type, but is being used as a value here

There exits working type definitions in https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/flexsearch but to use them one has to either downgrade to a version containing no type definitions (e.g. 0.7.11) or delete the supplied one.

It would be awesome if you can sort this out.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:14
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
Lossescommented, Nov 5, 2022

Same issue after upgrading to 0.7.31. The DefinitelyTyped version (which is arguably the correct typing) is being shadowed by the built-in typing at node_modules/flexsearch/index.d.ts. I have to downgrade to 0.7.21.

In the meanwhile, @ts-thomas (author of Flexsearch) and @Losses (Author of de-facto the best typing in DefinitelyTyped project), would you consider bringing the DefinitelyTyped version into this repo? The typing files won’t hurt performance and it’s in theory a O(1) complexity change with huge improvement for developers who expect out-of-box typing. The competing library Lyra search, for example, already ships with full typescript support.

I’d like to if the developers of this library agree to merge the pull request… https://github.com/nextapps-de/flexsearch/pull/266

2reactions
lucas-labscommented, Oct 26, 2022

I’m experiencing this issue after updating from v0.7.21 to v0.7.31 (I was using this lib with @types/... definitions before). As of right now it seems completely unusable with typescript (I mean, it works once compiled but it throws type errors everywhere on dev time).

I had to rollback to 0.7.21 for the time being.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to overwrite incorrect TypeScript type definition ...
Say that I want to use dotenv module in my TypeScript project and install its . d. ts using npm install @types/dotenv --save...
Read more >
tsc 2.9.x generating incorrect type definitions for import types
tldr; when using the new import types feature of tsc 2.9, there are certain circumstances where the import( part is missing.
Read more >
TypeScript. How to rewrite type definition file (file.d.ts) of any ...
How to rewrite type definition file (file.d.ts) of any node_modules package. If you have some node_modules package with the very old /odd /...
Read more >
Incorrect type definition for Query.select() method
Hi, While upgrading to latest version 21.2.6, new types for the Query class became available to our ... Incorrect type definition for Query.select()...
Read more >
Override DefinitelyTyped definition : r/typescript
Can anyone explain how I'd use interface merging for this? I can't seem to get it to work! I've submitted a PR for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found