seald / nedb

The JavaScript Database, for Node.js, nw.js, electron and the browser
MIT License
351 stars 32 forks source link

loadDatabase with callback option cannot be used from Typescript #21

Closed oskCom closed 2 years ago

oskCom commented 2 years ago

I'm trying to use nedb from typescript. But I get an error.

nedb version v2.2.1

sample code

import Nedb from 'nedb';
const DB = new Nedb({ filename: 'path/to/datafile' })
DB.loadDatabase(function (err) { 
    // callback
})

Symptoms typescript error occurs

Error details Expected 0 arguments, but got 1.ts(2554)

tex0l commented 2 years ago

Indeed, I don't know why we didn't see this before, I guess I'll need to double down the typings tests.

In any case, your PR cannot be merged into master if you want a 2.x.x, and is not correct because the first parameter can also be nullish.

Here is my suggested change: https://github.com/seald/nedb/tree/2.x.x I released it as a prepatch 2.2.2-0, could you confirm it works?

tex0l commented 2 years ago

I released the stable 2.2.2 that addresses the issue, the 3.0.0 will have the fix as well when published.

oskCom commented 2 years ago

Here is my suggested change: https://github.com/seald/nedb/tree/2.x.x I released it as a prepatch 2.2.2-0, could you confirm it works?

Good suggestion. Sure, this code is better. I was able to confirm that it works

oskCom commented 2 years ago

I released the stable 2.2.2 that addresses the issue, the 3.0.0 will have the fix as well when published.

Thank you for the new version release.