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

[Feature Request] Improve Access to Component Types (such as props) for TypeScript in Vuetify 3 #18047

Closed
MatthewAry opened this issue Aug 14, 2023 · 5 comments
Labels
duplicate The issue has already been reported

Comments

@MatthewAry
Copy link
Contributor

Problem to solve

I've often found myself struggling to extend Vuetify components in Vuetify 3. This is because I can't make my component wrappers know what props they can pass down to Vuetify Components themselves. Let's say that I want to make a component wrapper for VCard, how would I be able to ensure that my component wrapper has the same prop list signature as what VCard provides? What about slots? What about events? Where and how can I import that information and apply it to my own wrapper?

Proposed solution

See:

<script setup lang="ts">
import { VCard, type VCardProps } from "vuetify/components/VCard";

interface Props extends VCardProps {
  foo: string;
}

const props = defineProps<Props>();
</script>

<template>
  <VCard v-bind="props" />
</template>
@NextThread
Copy link

hey, can I work on this? please

@KaelWD
Copy link
Member

KaelWD commented Sep 6, 2023

Duplicate of #16680

@KaelWD KaelWD marked this as a duplicate of #16680 Sep 6, 2023
@KaelWD KaelWD closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2023
@KaelWD KaelWD added the duplicate The issue has already been reported label Sep 6, 2023
@github-actions github-actions bot removed the S: triage label Sep 6, 2023
@MatthewAry
Copy link
Contributor Author

@KaelWD The issue this was marked a duplicate of was closed by the OP. I don't think it's actually resolved. Anyways, I'm just letting you know so this request doesn't get forgotten.

@MatthewAry
Copy link
Contributor Author

@KaelWD Can you please reopen this issue?

@moeshin
Copy link

moeshin commented May 26, 2024

import { VSelect } from 'vuetify/components';

type VSelectProps = VSelect['$props'];
interface Props extends /* @vue-ignore */ VSelectProps {}
const props = defineProps<Props>();

Now I am using this method. If there is no /* @vue-ignore */ comment, an error will be reported.

[@vue/compiler-sfc] Failed to resolve extends base type.
If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:

interface Props extends /* @vue-ignore */ Base {}

Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.

10 |  
11 |  type VSelectProps = VSelect['$props'];
12 |  interface Props extends  VSelectProps {}
   |                           ^^^^^^^^^^^^
13 |  const props = defineProps<Props>();
14 |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate The issue has already been reported
Projects
None yet
Development

No branches or pull requests

4 participants