Closed ahaoboy closed 7 months ago
For better type infer
const data = [{ id: '1' }] { const fuse = new Fuse(data, { keys: ['id'], includeScore: true }) const r = fuse.search('1') // ok r.sort((a, b) => a.score - b.score) } { const fuse = new Fuse(data, { keys: ['id'] }) const r = fuse.search('1') // error: Property 'score' does not exist on type '{ item: { id: string; }; refIndex: number; }' r.sort((a, b) => a.score - b.score) } { const fuse = new Fuse(data, { keys: ['id'], includeMatches: true }) const r = fuse.search('1') // ok r.sort((a, b) => a.matches.length - b.matches.length) } { const fuse = new Fuse(data, { keys: ['id'], includeMatches: false }) const r = fuse.search('1') // error: Property 'matches' does not exist on type '{ item: { id: string; }; refIndex: number; }'. r.sort((a, b) => a.matches.length - b.matches.length) }
For better type infer