11export interface VuexModuleOptions {
2- namespaced ?:boolean ;
3- target ?:"nuxt"
2+ /*
3+ * Takes a boolean or a namespacedPath.
4+ * Defines wether the module should be namespaced or not.
5+ * If true, then the module will be namespaced.
6+ * If false, then the module will not be namespaced.
7+ * If it is a string the module will be namespaced and the value will be the namespaced path
8+ */
9+ namespaced ?:boolean | string ;
10+ target ?:"nuxt" ;
11+ enableLocalWatchers ?:boolean | string ;
12+ enableLocalSubscriptions ?:boolean | string ;
13+ enableLocalActionSubscriptions ?:boolean | string ;
414}
515
6- export class VuexModule {
7- }
8-
9- type VuexStashTypes = "state" | "explicit-mutation" | "getter" | "action" | "submodule" ;
10-
11- export interface VuexStash < T extends VuexStashTypes > {
12- [ field :string ] : {
13- type :T ,
14- value :
15- T extends "state" ? boolean | number | string | object | any :
16- T extends "explicit-mutation" ? ( state :any , payload :any ) => void :
17- T extends "getter" ? { getter :( state :any , context :any ) => any , mutation ? :( state :any , payload :any ) => void } :
18- T extends "action" ? ( context :any , payload :any ) => Promise < any > :
19- T extends "submodule" ? Map :
20- never
21- }
22- }
16+ export class VuexModule { }
2317
2418export type VuexModuleConstructor = typeof VuexModule & VuexModuleInternals ;
2519
2620export interface VuexModuleInternals {
27- prototype :{
28- __options__ :VuexModuleOptions | undefined ;
29- __vuex_module_cache__ :undefined | VuexObject ;
30- __vuex_module_tree_stash__ : VuexStash < VuexStashTypes > ;
31- __vuex_proxy_cache__ :{ } | undefined ;
32- __vuex_local_proxy_cache__ :{ } | undefined ;
33- __submodules_cache__ : Map ;
34- __mutations_cache__ : {
35- __explicit_mutations__ : { } ,
36- __setter_mutations__ : { } ,
37- } ;
38- __context_store__ : Map | undefined ;
39- }
21+ prototype :VuexModuleInternalsPrototype
22+ }
23+
24+ export interface VuexModuleInternalsPrototype {
25+ __options__ :VuexModuleOptions | undefined ;
26+ __namespacedPath__ :string ;
27+ __vuex_module_cache__ :undefined | VuexObject ;
28+ __vuex_proxy_cache__ :{ } | undefined ;
29+ __vuex_local_proxy_cache__ :{ } | undefined ;
30+ __submodules_cache__ : Map ;
31+ __context_store__ : Map | undefined ;
32+ __mutations_cache__ : {
33+ __explicit_mutations__ : { } ,
34+ __setter_mutations__ : { } ,
35+ } ;
36+ __explicit_getter_names__ :string [ ] ;
37+ __explicit_mutations_names__ : string [ ] ,
38+ __actions__ : {
39+ __name__ :string ,
40+ __type__ :ActionType ,
41+ } [ ] ,
42+ __watch__ :Map ;
4043}
4144
4245export interface SubModuleType < T > {
@@ -60,4 +63,37 @@ export type Map = Record<DictionaryField, any>
6063export interface FieldPayload {
6164 field :string ;
6265 payload :any ;
66+ }
67+
68+ export type MutationDescriptor = TypedPropertyDescriptor < ( payload ?:any ) => void >
69+
70+ export type ActionType = "raw" | "mutate" ;
71+
72+ export type ActionOption = {
73+ mode ? :ActionType
74+ }
75+
76+ export type ActionDescriptor = TypedPropertyDescriptor < ( payload ?:any ) => Promise < any > >
77+
78+ export interface ProxyWatchers {
79+
80+ $watch (
81+ getterField :string ,
82+ callback :( ( newVal :string , oldVal :string ) => void ) | object ,
83+ options ? :{ deep :boolean , immediate :boolean }
84+ ) :( ) => void
85+
86+ $subscribe (
87+ mutationfield :string ,
88+ callback :( payload :any ) => void ,
89+ ) :void
90+
91+ $subscribeAction (
92+ actionField :string ,
93+ callbackOrObj :( payload :any ) => void | ( {
94+ before : ( payload :any ) => void ,
95+ after : ( payload :any ) => void ,
96+ } )
97+ ) :void
98+
6399}
0 commit comments