pouchdb.d.ts icon indicating copy to clipboard operation
pouchdb.d.ts copied to clipboard

Overload resolution

Open AGBrown opened this issue 9 years ago • 2 comments

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();
});

AGBrown avatar Apr 29 '15 20:04 AGBrown

Largely done - still need to add some correctness tests to pouchdb-tests.ts for one or two api methods.

AGBrown avatar Apr 30 '15 12:04 AGBrown

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:.

fredgalvao avatar Sep 22 '15 18:09 fredgalvao