From da04d8b684e79bcbcc31966fc2c4efdb0f2b64a1 Mon Sep 17 00:00:00 2001 From: Max Battcher Date: Thu, 8 Jun 2017 10:39:49 -0400 Subject: [PATCH] Add PouchDB heterogeneous generic test --- types/pouchdb-core/pouchdb-core-tests.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/types/pouchdb-core/pouchdb-core-tests.ts b/types/pouchdb-core/pouchdb-core-tests.ts index ba06de7608..1e5d7ee75a 100644 --- a/types/pouchdb-core/pouchdb-core-tests.ts +++ b/types/pouchdb-core/pouchdb-core-tests.ts @@ -210,3 +210,26 @@ function testRemoteOptions() { skip_setup: true }); } + +interface Cat { + meow: string; +} + +interface Boot { + thud: boolean; +} + +async function heterogeneousGenericsDatabase(db: PouchDB.Database) { + const cats = await db.allDocs({ startkey: 'cat/', endkey: 'cat/\uffff', include_docs: true }); + for (let row of cats.rows) { + if (row.doc) { + row.doc.meow; // $ExpectType string + } + } + const boots = await db.allDocs({ startkey: 'boot/', endkey: 'boot/\uffff', include_docs: true }); + for (let row of boots.rows) { + if (row.doc) { + row.doc.thud; // $ExpectType boolean + } + } +}