pouchdb.d.ts
pouchdb.d.ts copied to clipboard
Overload resolution
Related to #1
Need to work on overload resolution. Example:
A:
get<R extends ExistingDoc>(docId: string, options?: Options, callback?: async.Callback<R>): void;
vs. B:
get<R extends ExistingDoc>(docId: string, options: Options, callback?: async.Callback<R>): void;
get<R extends ExistingDoc>(docId: string, callback?: async.Callback<R>): void;
Using A then the following code shows err
in intellisense/type-checking as any
. Using B err
is correctly (and more helpfully) identified as Error | {}
db.get(info.id, (err) => {
expect(err.error).to.exist;
done();
});
Largely done - still need to add some correctness tests to pouchdb-tests.ts
for one or two api methods.
This should not be a rule, I'd guess this is a bug in intellisense on whichever IDE that is. Seeing this issue I now understand the reason for so many overloads :smile:.