Open masx200 opened 2 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Out of curiosity, are there things @types/lokijs isn't covering? The only item I've really come across so far is the $exists
operator which isn't exposed on the top level. It might be helpful to have a list of types that need fixing.
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lokijs/index.d.ts
Based on the type file history, it seems very receptive to PRs as well.
Unfortunately, the typing definition provided by @types missed some detail about many classes, marked a lot of things as any
which make the definition less useful, and most important, not included the typing for all adapters.
Based on the roadmap I don't think a TS migration is planned. We can either add our own .d.ts
or PR against @types/lokijs
. My suggestion is we improve the external types when we bump against rough edges since those already have tests in place and cover a lot of Loki's API surface area.
A quick list of changes for those who are really good at typings:
any
usage. Where possible, any
should become unknown
LokiOps
should probably become a generic LokiOps<E = unknown>
, with LokiQuery
passing this type information in. Just typing the LokiOps will remove a lot of any
. here is how Mongo types their filter operations$exists
operator refLokiFsStructuredAdapter
LokiIndexedAdapter
LokiPartitioningAdapter
official docs do not mention a lot of methods in the types Additional Context:
I spent 6 days fully reviewing most of Loki's code (~6000 lines), and finally came to the conclusion that perhaps we have to do some house-keeping work to modernize the project and improve the code quality.
In addition, the mongo-like query is not the most tough one, writing typing definition for the Transform API and the lens implantation ( getIn
and deepProperty
) is even more desperate, I've did a lot of experiment about these API.
Maybe I should write a complete code review report but it's too late today, I think it will happen after I finished reading the last part of the source code.
BTW, actually there is another fork called loki-collections, but it is much different from original Loki.js
Can you add typescript support?