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.