We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
state
1 parent 404d0de commit d39791bCopy full SHA for d39791b
types/index.d.ts
@@ -79,7 +79,7 @@ export interface CommitOptions {
79
}
80
81
export interface StoreOptions<S> {
82
- state?: S;
+ state?: S | (() => S);
83
getters?: GetterTree<S, S>;
84
actions?: ActionTree<S, S>;
85
mutations?: MutationTree<S>;
types/test/index.ts
@@ -98,6 +98,15 @@ namespace RootDefaultModule {
98
});
99
100
101
+namespace InitialStateFunction {
102
+ const store = new Vuex.Store({
103
+ state: () => ({
104
+ value: 1
105
+ })
106
+ });
107
+ const n: number = store.state.value;
108
+}
109
+
110
namespace NestedModules {
111
interface RootState {
112
a: {
0 commit comments