windingwind / zotero-types

TypeScript definitions for Zotero.
https://www.npmjs.com/package/zotero-types
MIT License
56 stars 9 forks source link

Make fields in `options` in DB query methods optional #53

Closed sneakers-the-rat closed 3 days ago

sneakers-the-rat commented 3 days ago

Hello! thanks for this package :)

I was noticing while doing some DB calls that I can't do this:

let rows = await Zotero.DB.queryAsync(statement, [], {
  noCache: true,
});

because all the fields of the options object are required:

npm error src/connection.ts:19:73 - error TS2345: Argument of type '{ noCache: true; }' is not assignable to parameter of type '{ inBackup: boolean; noParseParams: boolean; onRow: (row: unknown, cancel: unknown) => void; noCache: boolean; }'.
npm error   Type '{ noCache: true; }' is missing the following properties from type '{ inBackup: boolean; noParseParams: boolean; onRow: (row: unknown, cancel: unknown) => void; noCache: boolean; }': inBackup, noParseParams, onRow
npm error
npm error 19       const lastInsertRowID = await Zotero.DB.queryAsync(statement, [], {
npm error                                                                            ~
npm error 20         noCache: true,
npm error    ~~~~~~~~~~~~~~~~~~~~~~
npm error 21       });
npm error    ~~~~~~~

It appears that they are all in fact optional, looking at the way it is called internally in Zotero, so a minor patch to reflect that :)