bevacqua / fuzzysearch

:crystal_ball: Tiny and blazing-fast fuzzy search in JavaScript
https://ponyfoo.com
MIT License
2.71k stars 87 forks source link

chore: add typescript declaration file #27

Closed lextoc closed 1 year ago

lextoc commented 3 years ago

Saw request for declaration file, does this look good?

https://github.com/bevacqua/fuzzysearch/issues/23

jchook commented 2 years ago

Your type definition is slightly incorrect:

  1. export default corresponds to require('fuzzysearch').default
  2. both arguments have type string

Try this instead:

declare function fuzzysearch (needle: string, haystack: string): boolean;

export = fuzzysearch;
ajoslin103 commented 1 year ago

I added this when I wrapped search for my own uses

export type FuzzyResults = (string | object)[] | MatchData<string | object>[];
remcohaszing commented 1 year ago

@jchook is correct. A PR to add correct type definitions is available in #19. Such definitions are also available via @types/fuzzysearch. I suggest closing this PR.