nextapps-de / flexsearch

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

Error: export 'Document' (imported as 'Document') was not found in 'flexsearch' (possible exports: default) #438

Open mirkoacadevmy opened 4 months ago

mirkoacadevmy commented 4 months ago

When I’m using flexsearch in my project and the project uses typescript too. I wrote the code below, with no complaints from IDE:

import { Document } from 'flexsearch';

this.index = new Document<Document, true>({
      document: {
        id: 'id',
        tag: 'type',
        index: Array.from(indexes),
        store: true
      }
    });

but when I compile the code I receive the following error:

Error: export 'Document' (imported as 'Document') was not found in 'flexsearch' (possible exports: default)

A similar error occurred also to this guy, where he explains the cause and how to resolve: Flexsearch Document Error

The solution works but with that all TypeScript types are broken, because replaced with any

luwes commented 2 months ago

I got the same error today.

zero1zero commented 1 month ago

The workaround from the link worked for me but I got the same error. Workaround:

import search from "flexsearch"
const i: search.Index = ...