Skip to content

Commit

Permalink
fix(types): allow a function type for root state option (#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn authored Sep 27, 2018
1 parent 404d0de commit d39791b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export interface CommitOptions {
}

export interface StoreOptions<S> {
state?: S;
state?: S | (() => S);
getters?: GetterTree<S, S>;
actions?: ActionTree<S, S>;
mutations?: MutationTree<S>;
Expand Down
9 changes: 9 additions & 0 deletions types/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ namespace RootDefaultModule {
});
}

namespace InitialStateFunction {
const store = new Vuex.Store({
state: () => ({
value: 1
})
});
const n: number = store.state.value;
}

namespace NestedModules {
interface RootState {
a: {
Expand Down

0 comments on commit d39791b

Please sign in to comment.