I tried to import fuse.js in a angular2 app, but I get an exception (Fuse is not defined). I also check definitions file (index.d.ts) in the package.
my class in typescript is :
import 'fuse.js';
export class Myclass{
/**some code*/
public mySearchFunction(text, list, Opts){
let fuseSearch = new Fuse(list, Opts);
let fuseResults: any[] = fuseSearch.search(text);
return fuseResults
}
}
I tried also with
import * as Fuse from 'fuse.js';
What is the right way to use this library?
The typings were only added to the project 8 days ago. If you look at the latest NPM release from here you'll see the typings aren't included.
If you either pull the package from master
or grab files package.json
and index.d.ts
, then you'll be able to use the package with import * as Fuse from 'fuse.js';
Looking at the console, I'm still getting error Cannot find module 'fuse.js'
, but it's working. Not sure what that's all about.
Version 2.6.1 got pushed to NPM yesterday, which supports typings - see here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With