windingwind / zotero-types

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

Fix `executeTransaction`option types #52

Open thebluepotato opened 1 month ago

thebluepotato commented 1 month ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch zotero-types@2.2.1 for the project I'm working on.

Zotero.DB.executeTransaction() accepts options, but they were all required even if one wanted to set only a single one. After checking in the Zotero source, all these options are individually checked against a fallback, so we don't have to provide all of them every time. Also fixes a typo in one of the option names.

diff --git a/node_modules/zotero-types/types/xpcom/db.d.ts b/node_modules/zotero-types/types/xpcom/db.d.ts
index 78dd71d..0f1f9d2 100644
--- a/node_modules/zotero-types/types/xpcom/db.d.ts
+++ b/node_modules/zotero-types/types/xpcom/db.d.ts
@@ -56,7 +56,7 @@ declare namespace _ZoteroTypes {
      *    transaction and re-enable after. (`PRAGMA foreign_keys=0|1` is a no-op during a transaction.)
      * @return {Promise} - Promise for result of generator function
      */
-    executeTransaction<T>(func: () => T | Promise<T>, options?: {disbledForeignKeys: boolean, timeout: number, vacuumOnCommit: boolean, inBackup: boolean, onCommit: (id: string) => void, onRollback: (id: string) => void}): Promise<T>;
+    executeTransaction<T>(func: () => T | Promise<T>, options?: {disableForeignKeys?: boolean, waitTimeout?: number, vacuumOnCommit?: boolean, inBackup?: boolean, onCommit?: (id: string) => void, onRollback?: (id: string) => void}): Promise<T>;

     inTransaction(): boolean;

This issue body was partially generated by patch-package.

windingwind commented 1 month ago

Thanks. Do you want to propose a PR? Otherwise, I can do it.

volatile-static commented 1 month ago

I think we should use util type Partial instead of adding every ? in this case.