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

Carousel - Improve items prop typing #2102

Closed
vitebo opened this issue Sep 2, 2024 · 1 comment
Closed

Carousel - Improve items prop typing #2102

vitebo opened this issue Sep 2, 2024 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists v3 #1289 wontfix-v2 This will not be fixed in `v2.x`.

Comments

@vitebo
Copy link

vitebo commented Sep 2, 2024

Environment


  • Operating System: Darwin
  • Node Version: v20.14.0
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Version

v2.18.4

Reproduction

https://stackblitz.com/edit/nuxt-ui-efufxa?file=app.vue

Description

Currently, the items prop in the carousel component is typed as any:

The issue with typing items as any is that when using v-slot="{ item }", the item will always be typed as any. This can make for a poor developer experience, especially when working with more complex item structures, such as creating a carousel of offer cards.

I believe we can improve this by utilizing Vue's generics:

We could define the generic in the script:

<script lang="ts" generic="Item">

And then use the generic in the prop definition:

items: {
  type: Array as PropType<Item[]>,
  default: () => []
},

If this change makes sense, I’d be happy to help by submitting a PR.

Additional context

No response

Logs

No response

@vitebo vitebo added bug Something isn't working triage labels Sep 2, 2024
@benjamincanac benjamincanac added v3 #1289 and removed triage labels Sep 10, 2024
Copy link
Member

Closing in favor of #2142. All components in v3 are implement with generics by default 😊

@benjamincanac benjamincanac closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2024
@benjamincanac benjamincanac added wontfix-v2 This will not be fixed in `v2.x`. duplicate This issue or pull request already exists labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists v3 #1289 wontfix-v2 This will not be fixed in `v2.x`.
Projects
None yet
Development

No branches or pull requests

2 participants