packages icon indicating copy to clipboard operation
packages copied to clipboard

Incomplete externs in pouchdb

Open Jarzka opened this issue 5 years ago • 0 comments

Here is the current externs file of pouchdb:

https://github.com/cljsjs/packages/blob/master/pouchdb/resources/cljsjs/pouchdb/common/pouchdb.ext.js

I believe this file is incomplete as it seems to lack _id and _rev fields.

For example, if I call get to fetch a document: (.get pouchdb id get-options) I get a result object with _id and _rev properties. If I try to read these values directly: (.-_id result) (.-_rev result) I get the correct result in dev build, but undefined in production build with advanced compilation.

However, I'm not sure if we should either update the externs file, or simply convert the result object into Clojure map in application code every time we use get, as it seems that reading any field value from the result object results undefined in advanced compilation. This problem can be avoided altogether by doing the conversion first. On the other hand, I can read id and rev directly in advanced compilation without problem, and _id and _rev are part of pouchdb's default fields, so they should probably be included in the externs file

Jarzka avatar Jun 25 '19 05:06 Jarzka