File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/shared-utils/src Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ const internalSharedData = {
31
31
debugInfo : false ,
32
32
}
33
33
34
+ type TSharedData = typeof internalSharedData
35
+
34
36
const persisted = [
35
37
'componentNameStyle' ,
36
38
'theme' ,
@@ -182,7 +184,7 @@ export function destroySharedData () {
182
184
watchers = { }
183
185
}
184
186
185
- let watchers = { }
187
+ let watchers : Partial < Record < keyof TSharedData , ( ( value : any , oldValue : any ) => unknown ) [ ] > > = { }
186
188
187
189
function setValue ( key : string , value : any ) {
188
190
// Storage
@@ -206,7 +208,9 @@ function sendValue (key: string, value: any) {
206
208
} )
207
209
}
208
210
209
- export function watchSharedData ( prop , handler ) {
211
+ export function watchSharedData <
212
+ TKey extends keyof TSharedData ,
213
+ > ( prop : TKey , handler : ( value : TSharedData [ TKey ] , oldValue : TSharedData [ TKey ] ) => unknown ) {
210
214
const list = watchers [ prop ] || ( watchers [ prop ] = [ ] )
211
215
list . push ( handler )
212
216
return ( ) => {
You can’t perform that action at this time.
0 commit comments