Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make types for components accessible to import #4342

Open
fallenfreq opened this issue Jul 11, 2024 · 0 comments
Open

Make types for components accessible to import #4342

fallenfreq opened this issue Jul 11, 2024 · 0 comments

Comments

@fallenfreq
Copy link

Is your feature request related to a problem? Please describe.

Currently when you add rules to components such as VaDateInput or VaSelect, the internal types that Vuestic uses are not accessible to import. This means you need to use any which is not good practice. In the example bellow, any should really be DateInputModelValue.

  <VaDateInput
    v-model="form.birthDate"
    :rules="[(v: any) => validateBirthday(v)]"
    label="Birth Date"
    manual-input
    clearable
  />

SelectableOption is available as SelectOption but this is a little confusing when you follow what your IDE is telling you that you need.

  <VaSelect
    v-model="form.country"
    :options="countries"
    :rules="[
      (v: SelectOption) => v || 'Field is required',
      (v: SelectOption) =>
        v && typeof v === 'object' && v.value === 'ua'
          ? 'Delivery currently unavailable in your country'
          : undefined
    ]"
    label="Country"
  />

It would also be convenient if these types used generics so that you didn't need to check for the type as you can see in the example above. DateInputModelValue is similar in that it could be Date, Date[], { start: Date, end: Date }.

Describe the solution you'd like

These types at the very minimum need to be re-exported so they are accessible to import. It would also be convenient if they used generics to prevent having to do type narrowing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant