Hello,
Unhandled error TypeError: fuse_js_1.default is not a constructor
I have an issue when I import Fuse with import style. It's a typescript compilation bug.
import Fuse from 'fuse.js'
It work well if I use require but I loose typing.
6
Typescript
tsconfig:
{
"compilerOptions": {
"module": "CommonJS",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"allowJs": true,
"target": "ES2018",
"lib": ["es2018", "DOM"]
},
"compileOnSave": true,
"include": [
"src"
]
}
typescript file:
const fuse = new Fuse(data, {
keys: [
'name',
'configs.name'
],
includeScore: true
})
building result:
const fuse = new fuse_js_1.default(data, {
keys: [
'name',
'configs.name'
],
includeScore: true
});
My bad, I forget to use "esModuleInterop": true, in my tsconfig.
Thanks for this, was facing the same thing.
Most helpful comment
My bad, I forget to use
"esModuleInterop": true,in my tsconfig.