Closed seantanly closed 7 years ago
+1 for the backwards compatible version, but does it need to be part of the TypeScript interface? The enum values do, but I don't think the string lunr.Query.wildcard
is really used as part of the public API, its not even used in other places within the JavaScript implementation (which could/should probably be fixed). I don't know what the best practise is when defining interfaces/typings for TypeScript though.
I have considered lunr.Query.wildcard
because it seems to be part of the public interface - placed after comments. It can be excluded from the TypeScript interface.
Searching around, lunr.Query.wildcard
is used only at
https://github.com/olivernn/lunr.js/blob/81b4fd6547ce3155820406b09ae417a4c10431ed/lib/query.js#L84 https://github.com/olivernn/lunr.js/blob/81b4fd6547ce3155820406b09ae417a4c10431ed/lib/query.js#L88
which could easily be replaced just with "*"
and then lunr.Query.wildcard
can be removed.
As suggested, I left out lunr.Query.wildcard
in the typescript definition.
https://github.com/olivernn/lunr.js/blob/81b4fd6547ce3155820406b09ae417a4c10431ed/lib/query.js#L40-L43
The clever use of defining enum constants within the instance of string "*" makes it hard to write type definition for typescript.
May I suggest adding
lunr.Query.wildcardSymbol = "*"
This allows the typescript definition to ignore
lunr.Query.wildcard
as a string, and prevent breakage to existing users who rely onlunr.Query.wildcard
as "*".