From e5f8ae32346b7574f264ecc366914c8459fe4751 Mon Sep 17 00:00:00 2001 From: Ori Livni Date: Wed, 27 Feb 2019 10:21:44 +0200 Subject: [PATCH] electron-store - Fix `onDidChange` return value --- types/electron-store/electron-store-tests.ts | 4 ++++ types/electron-store/index.d.ts | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/types/electron-store/electron-store-tests.ts b/types/electron-store/electron-store-tests.ts index f27cd6aca3..318af19f5c 100644 --- a/types/electron-store/electron-store-tests.ts +++ b/types/electron-store/electron-store-tests.ts @@ -52,3 +52,7 @@ typedElectronStore.set({ enabled: true, interval: 10000, }); + +const offDidChange = typedElectronStore.onDidChange("enabled", (n: boolean | undefined, p: boolean | undefined) => {}); + +offDidChange(); diff --git a/types/electron-store/index.d.ts b/types/electron-store/index.d.ts index 66e579b392..721386de2f 100644 --- a/types/electron-store/index.d.ts +++ b/types/electron-store/index.d.ts @@ -8,6 +8,8 @@ /// +import EventEmitter = require("events"); + type JSONValue = string | number | boolean | JSONObject | JSONArray; interface JSONObject { @@ -79,12 +81,12 @@ declare class ElectronStore implements Iterable<[string, JSONValue]> { */ onDidChange( key: K, - callback: (newValue: T[K], oldValue: T[K]) => void - ): void; + callback: (newValue: T[K] | undefined, oldValue: T[K] | undefined) => void + ): () => EventEmitter; onDidChange( key: string, - callback: (newValue: JSONValue, oldValue: JSONValue) => void - ): void; + callback: (newValue: JSONValue | undefined, oldValue: JSONValue | undefined) => void + ): () => EventEmitter; /** * Get the item count.