olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.91k stars 546 forks source link

tokenizer.separator access modifier in type definition #323

Closed JeremyTCD closed 6 years ago

JeremyTCD commented 6 years ago

@seantanly First off, thanks for the lunr type definitions. Unfortunately, I ran into a minor issue with tokenizer.separator:

import * as lunr from 'lunr';
lunr.tokenizer.separator = /[\s\-\.]+/;

causes the following typescript error:

[ts] Cannot assign to 'separator' because it is a constant or a read-only property.
const tokenizer.separator: RegExp

Is the separator property meant to have a const access modifier? If so, is there a way to assign to it?

seantanly commented 6 years ago

Thanks for pointing out the error in the type definition. I have submitted a PR to correct this and it should be available soon.

seantanly commented 6 years ago

@JeremyTCD the PR is merged and the updated type definition is available now. Do close this issue if it's working for you now. :)

JeremyTCD commented 6 years ago

Thanks for the fix! I came across a second issue though. I think the generateStopWordFilter function in the lunr namespace is missing. I'm not too familiar with typescript but I think the declaration would be something like this:

function generateStopWordFilter(stopWords: string[]) : PipelineFunction;    
seantanly commented 6 years ago

@JeremyTCD You're correct with the missing definition. 👍 Added another PR for it. Thanks for making the definition more accurate and complete.

If you may wish to put up a PR for lunr directly on DefinitelyTyped next time too :) in case I'm not available to do so.

JeremyTCD commented 6 years ago

@seantanly Thanks again dude. Wasn't super confident in my TS skills :grinning:, but will create my own PRs for future issues. Closing this thread.