Fuse: Unhandled error TypeError: fuse_js_1.default is not a constructor

Created on 23 May 2020  路  2Comments  路  Source: krisk/Fuse

Describe the bug

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.

Version

6

Additional context

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
    });
bug

Most helpful comment

My bad, I forget to use "esModuleInterop": true, in my tsconfig.

All 2 comments

My bad, I forget to use "esModuleInterop": true, in my tsconfig.

Thanks for this, was facing the same thing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

washtenawIdtreble picture washtenawIdtreble  路  4Comments

ergcode picture ergcode  路  3Comments

Olian04 picture Olian04  路  4Comments

cathy810218 picture cathy810218  路  4Comments

lxynox picture lxynox  路  3Comments