bajankristof / nedb-promises

A dead-simple promise wrapper for nedb.
MIT License
298 stars 45 forks source link

Datastore not generic #39

Closed JulianLang closed 3 years ago

JulianLang commented 3 years ago

Hi, I noticed that Datastore is not generic while in Nedb it is. Having it generic can help devs to only pass in correct data to e.g. insert calls.

Example with Nedb:

interface MyType {
  prop: string;
}

const db: Datastore<MyType> = new Datastore();

// somewhere else:
db.insert({ }, (err, doc) => { /* ... */ });
//        ^^^ typescript complains that "{}" is not assignable to interface "MyType",
//            since it is missing the property "prop".

Am I missing something or is this is currently not possible to get this kind of help from compiler?

bajankristof commented 3 years ago

Hi,

Thanks for opening this issue! Sorry I did not respond to you so far, to be honest I'm don't have enough knowledge in TypeScript to verify that but there has been an update to the definition file a couple of weeks ago, maybe that solved your issue as well. Could you check please and report what you find back to this issue?

JulianLang commented 3 years ago

Hi,

thanks, sure. I will hopefully have time to take a look next days and give feedback. Thanks for responding!

stale[bot] commented 3 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.