Skip to content

Incorrect return type for useControl in Vue #1967

@Cynthiafan

Description

@Cynthiafan

Describe the bug

Screen Shot 2022-06-28 at 4 10 16 PM

Typescript shows an error when using control.value: Property 'value' does not exist on type
But the control is returned as a ComputedRef object actually.

Expected behavior

control returns a ComputedRef object.

const control = computed(() => ({
...stateMap({ jsonforms }, props),
id: id.value
}));

Perhaps the line 150, 155, and 190 should replace with ComputedRef<R>

export function useControl<R, D, P extends {}>(
props: P,
stateMap: (state: JsonFormsState, props: P) => R
): { control: Required<R> };
export function useControl<R, D, P extends {}>(
props: P,
stateMap: (state: JsonFormsState, props: P) => R,
dispatchMap: (dispatch: Dispatch<CoreActions>) => D
): { control: Required<R> } & D;

Steps to reproduce the issue

  1. Call functions that call useControl inside, e.g. useJsonFormsControl
  2. Get value by control.value
  3. See type error

Screenshots

No response

In which browser are you experiencing the issue?

Brave 1.38.115

Framework

Vue 2

RendererSet

Other (please specify in the Additional context field)

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions