jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Incorrect return type for useControl in Vue

Open Cynthiafan opened this issue 2 years ago • 1 comments

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.

https://github.com/eclipsesource/jsonforms/blob/d2bf053315be914b1766a62eb6b7681a530a6633/packages/vue/vue/src/jsonFormsCompositions.ts#L169-L172

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

https://github.com/eclipsesource/jsonforms/blob/d2bf053315be914b1766a62eb6b7681a530a6633/packages/vue/vue/src/jsonFormsCompositions.ts#L147-L155

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

Cynthiafan avatar Jun 28 '22 08:06 Cynthiafan

I'm unfamiliar with the construct of your listing. You build and return the component within the setup method?

In general I agree, yes we should use ComputedRef within the typings to better express the actual return value.

sdirix avatar Jul 15 '22 14:07 sdirix

I agree that use of ComputedRef within the typings will improve Vue integration and DX a lot!

Regarding the construct in the listing, @Cynthiafan is using a render function instead of a <template>. setup() can also return a render function.

jdwit avatar Nov 09 '22 11:11 jdwit