ui icon indicating copy to clipboard operation
ui copied to clipboard

USelectMenu: authorize boolean value for model-value (typescript)

Open aspitrine opened this issue 1 year ago • 1 comments

Description

I have a case where my value of the select menu can be boolean but it's not authorized in the ts contract. It's possible to authorize it ?

It's work perfectly, juste the ts contract say me an error

Additional context

No response

aspitrine avatar Feb 08 '24 08:02 aspitrine

@benjamincanac when adding Boolean in the modelValue types, it does not seem to take effect

  props: {
    modelValue: {
      type: [Boolean, String, Number, Object, Array],
      default: ''
    },
    /* ... */
  }
Type 'boolean | undefined' is not assignable to type 'string | number | Record<string, any> | unknown[] | undefined'.ts(2322)
SelectMenu.vue(176, 5): The expected type comes from property 'modelValue' which is declared here on type 'Partial<{ id: string; options: string[] | { [key: string]: any; disabled?: boolean | undefined; }[]; class: any; ui: Partial<{ form: string; placeholder: string; default: { size: string; color: string; variant: string; loadingIcon: string; trailingIcon: string; }; ... 11 more ...; icon: { ...; }; }> & { ...; }; ... ...'
(property) modelValue?: string | number | Record<string, any> | unknown[] | undefined

Casting them with

modelValue: {
  type: [Boolean, String, Number, Object, Array] as PropType<boolean | string | number | { [key: string]: any } | any[]>,
  default: ''
}

does not seem to help either

noook avatar Feb 09 '24 10:02 noook