diff --git a/types/pouchdb-core/index.d.ts b/types/pouchdb-core/index.d.ts index 59e5650e62..01c7a0045c 100644 --- a/types/pouchdb-core/index.d.ts +++ b/types/pouchdb-core/index.d.ts @@ -594,7 +594,7 @@ declare namespace PouchDB { */ bulkDocs(docs: Array>, options: Core.BulkDocsOptions | null, - callback: Core.Callback): void; + callback: Core.Callback>): void; /** * Create, update or delete multiple documents. The docs argument is an array of documents. @@ -604,7 +604,7 @@ declare namespace PouchDB { * Finally, to delete a document, include a _deleted parameter with the value true. */ bulkDocs(docs: Array>, - options?: Core.BulkDocsOptions): Promise; + options?: Core.BulkDocsOptions): Promise>; /** Compact the database */ compact(options?: Core.CompactOptions): Promise; diff --git a/types/pouchdb-core/pouchdb-core-tests.ts b/types/pouchdb-core/pouchdb-core-tests.ts index 79a151aa3a..fe79997461 100644 --- a/types/pouchdb-core/pouchdb-core-tests.ts +++ b/types/pouchdb-core/pouchdb-core-tests.ts @@ -47,10 +47,19 @@ function testBulkDocs() { const model = { property: 'test' }; const model2 = { property: 'test' }; + const isError = ( + result: PouchDB.Core.Response | PouchDB.Core.Error + ): result is PouchDB.Core.Error => { + return !!( result).error; + }; + db.bulkDocs([model, model2]).then((result) => { - result.forEach(({ ok, id, rev }) => { + result.forEach(result => { + if (!isError(result)) { + const { ok, id, rev } = result; isString(id); isString(rev); + } }); });