From 168220d0e38662eee81bd2c3bb76b3c1e02337ef Mon Sep 17 00:00:00 2001 From: Alex Jover Date: Mon, 17 Jul 2017 11:15:12 +0200 Subject: [PATCH 1/2] Add MutationPayload type On the subscribe function, the mutation object was only having the `type` property and missing the payload --- types/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 89d4b88ca..b2a21f0db 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -17,7 +17,7 @@ export declare class Store { dispatch: Dispatch; commit: Commit; - subscribe

(fn: (mutation: P, state: S) => any): () => void; + subscribe

(fn: (mutation: P, state: S) => any): () => void; watch(getter: (state: S) => T, cb: (value: T, oldValue: T) => void, options?: WatchOptions): void; registerModule(path: string, module: Module): void; @@ -59,6 +59,10 @@ export interface Payload { type: string; } +export interface MutationPayload extends Payload { + payload: any; +} + export interface DispatchOptions { root?: boolean; } From f17f2c52b421c3584726e95d08b3db4cf89776e8 Mon Sep 17 00:00:00 2001 From: Alex Jover Date: Mon, 17 Jul 2017 11:31:57 +0200 Subject: [PATCH 2/2] Add tests for MutationPayload --- types/test/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/test/index.ts b/types/test/index.ts index c034f932b..63c42ccff 100644 --- a/types/test/index.ts +++ b/types/test/index.ts @@ -35,6 +35,7 @@ namespace StoreInstance { store.subscribe((mutation, state) => { mutation.type; + mutation.payload; state.value; });