@@ -69,43 +69,61 @@ namespace TestWithComponent {
6969}
7070
7171namespace TestModules {
72- interface IModuleAState {
72+
73+ interface INumberState {
7374 value : number ;
7475 }
7576
76- interface IModuleBState {
77- value : string ;
77+ interface INestedModuleState extends INumberState {
78+ a : INumberState ;
79+ b : INumberState ;
7880 }
7981
8082 interface IModuleState {
81- a : IModuleAState ;
82- b : IModuleBState ;
83+ nested : INestedModuleState ;
84+ c : INumberState ;
8385 }
8486
85- const aState : IModuleAState = { value : 1 } ;
86- const bState : IModuleBState = { value : 'test' } ;
87+ const aState = { value : 1 } ;
88+ const bState = { value : 2 } ;
89+ const cState = { value : 3 } ;
90+ const nestedState = { value : 4 } ;
8791
88- const aMutations : Vuex . MutationTree < IModuleAState > = {
89- INCREMENT ( state : IModuleAState ) {
92+ const mutations : Vuex . MutationTree < INumberState > = {
93+ INCREMENT ( state : INumberState ) {
9094 state . value = state . value + 1 ;
9195 }
9296 } ;
9397
94- const bMutations : Vuex . MutationTree < IModuleBState > = {
95- APPEND ( state : IModuleBState , value : string ) {
96- state . value = state . value + value ;
97- }
98+ const a = {
99+ state : aState ,
100+ mutations
98101 } ;
99102
100- const a = { state : aState , mutations : aMutations } ;
101- const b = { state : bState , mutations : bMutations } ;
103+ const b = {
104+ state : bState ,
105+ mutations
106+ } ;
102107
103- const store = new Vuex . Store < IModuleState > ( {
108+ const nested = {
109+ state : nestedState ,
110+ mutations,
104111 modules : { a, b }
112+ } ;
113+
114+ const c = {
115+ state : cState ,
116+ mutations
117+ } ;
118+
119+ const store = new Vuex . Store < IModuleState > ( {
120+ modules : { nested, c }
105121 } ) ;
106122
107- const valA : number = store . state . a . value ;
108- const valB : string = store . state . b . value ;
123+ const valA = store . state . nested . a . value ;
124+ const valB = store . state . nested . b . value ;
125+ const valC = store . state . c . value ;
126+ const valNested = store . state . nested . value ;
109127}
110128
111129namespace TestPlugin {
@@ -139,31 +157,35 @@ namespace TestWatch {
139157namespace TestHotUpdate {
140158 const store = createStore ( ) ;
141159
142- store . hotUpdate ( {
143- mutations : {
144- INCREMENT ( state ) {
145- state . count += 10 ;
146- }
160+ const mutations : Vuex . MutationTree < ISimpleState > = {
161+ INCREMENT ( state : ISimpleState ) {
162+ state . count ++ ;
147163 }
164+ } ;
165+
166+ store . hotUpdate ( {
167+ mutations
148168 } ) ;
149169
150170 store . hotUpdate ( {
151171 modules : {
152- a : {
153- state : 1 ,
154- mutations : {
155- INCREMENT ( state ) {
156- state . value ++ ;
172+ nested : {
173+ state : { count : 0 } ,
174+ mutations,
175+ modules : {
176+ a : {
177+ state : { count : 1 } ,
178+ mutations
179+ } ,
180+ b : {
181+ state : { count : 2 } ,
182+ mutations
157183 }
158184 }
159185 } ,
160- b : {
161- state : 'test' ,
162- mutations : {
163- APPEND ( state , value ) {
164- state . value += value ;
165- }
166- }
186+ c : {
187+ state : { count : 4 } ,
188+ mutations
167189 }
168190 }
169191 } ) ;
0 commit comments