Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled error TypeError: fuse_js_1.default is not a constructor #422

Closed
olriko opened this issue May 23, 2020 · 2 comments
Closed

Unhandled error TypeError: fuse_js_1.default is not a constructor #422

olriko opened this issue May 23, 2020 · 2 comments
Labels

Comments

@olriko
Copy link

olriko commented May 23, 2020

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
    });
@olriko olriko added the bug label May 23, 2020
@olriko
Copy link
Author

olriko commented May 27, 2020

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

@olriko olriko closed this as completed May 27, 2020
@rmatei
Copy link

rmatei commented Sep 3, 2020

Thanks for this, was facing the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants