Skip to content

Commit b77a4be

Browse files
authored
Improve Vue control type
The `control` returned by the Vue composition helpers is a computed property. This is now properly reflected in its type.
1 parent 1b22f55 commit b77a4be

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/vue/vue/src/jsonFormsCompositions.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
import {
4040
PropType,
4141
computed,
42+
ComputedRef,
4243
inject,
4344
onBeforeMount,
4445
onUnmounted,
@@ -151,12 +152,12 @@ export type Required<T> = T extends object
151152
export function useControl<R, D, P extends {}>(
152153
props: P,
153154
stateMap: (state: JsonFormsState, props: P) => R
154-
): { control: Required<R> };
155+
): { control: ComputedRef<Required<R>> };
155156
export function useControl<R, D, P extends {}>(
156157
props: P,
157158
stateMap: (state: JsonFormsState, props: P) => R,
158159
dispatchMap: (dispatch: Dispatch<CoreActions>) => D
159-
): { control: Required<R> } & D;
160+
): { control: ComputedRef<Required<R>> } & D;
160161
export function useControl<R, D, P extends {}>(
161162
props: P,
162163
stateMap: (state: JsonFormsState, props: P) => R,
@@ -192,7 +193,7 @@ export function useControl<R, D, P extends {}>(
192193
});
193194

194195
return {
195-
control: (control as unknown) as R,
196+
control: (control as unknown) as ComputedRef<R>,
196197
...dispatchMethods
197198
};
198199
}

0 commit comments

Comments
 (0)