krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
18.05k stars 766 forks source link

Fuse.js constructor options typing are widened #470

Closed wclr closed 4 years ago

wclr commented 4 years ago

Describe the bug

Typings of options allow to privide illegal options: https://github.com/krisk/Fuse/blob/master/src/index.d.ts#L4

So currently this is possible:

new Fuse(items, {
  whatever: true
})

Is there a reason why not change it to:

declare class Fuse<T> {
  constructor(list: ReadonlyArray<T>, options?: Fuse.IFuseOptions<T>, index?: FuseIndex<T>)

?

krisk commented 4 years ago

Good catch. Will update.