-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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] Export TS types, interfaces #16680
Comments
@websitevirtuoso I agree this should be done, i did find a workaround for now though:
I do get a somewhat misleading typescript error for unresolved type on DataTableHeader but it does in fact still work. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This is very specifically about Labs, right? There is currently nothing to export anything other than the components. Edit: I see the |
I have no idea about all types. Because I used only types from datatable. I had to copy this types into my own code and use them with "todo commend". I hope that they will create index.d.ts for us with exported types and interfaces |
@joel-wenzel a simpler variant with no typescript error import { VDataTable } from 'vuetify/labs/VDataTable';
export type VDataTableHeaderProps = Extract<VDataTable['$props']['headers'][number], {key: string}> |
This comment was marked as off-topic.
This comment was marked as off-topic.
very sad situation
|
export type VDataTableHeaderProps = Extract<Extract<VDataTable["$props"]["headers"], Readonly<Array>>[number], {key: string}> |
See the following for references and examples:
This is what I would like to be able to do but currently cannot. <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> |
Yes I can confirm that rignt now is much better with exports types and interfaces. For example:
my file @/types/vuetify with all duplicated types from vuetify
So can I close this issue? |
@websitevirtuoso I don't think so. It seems like the team has expanded the scope of this issue such that it's be come a META issue. |
ValidationRule should also get exported. https://github.com/vuetifyjs/vuetify/blob/b87b28f72990ca0227906a266bbb58793332fcb8/packages/vuetify/src/composables/validation.ts#L15C1-L20C52 |
This doesn't seem to work with Vuetify Component Types either. https://github.com/vuejs/language-tools/tree/master/packages/component-type-helpers |
i asbolutely aggree that vuetify needs more type/interfaces export. probably not whole component props but complex types used in props like |
For reference there is this conversation happening on Discord about extending components and passing types up. https://discord.com/channels/340160225338195969/1192558069343854612 |
Any news about the Anchor part ? If we made a props used in location props of VMenu or VTooltip, we can't use it because it must be |
Here is dirty workaround if anyone interested. Just declare
|
@lenargum this is not a long term solution. For that vuetify team must export it. |
I find myself wanting to get the exported interface shape of emitted events frequently. I don't see it mentioned specifically here so I'm posting in my use case with needing the typings from emitted events for reference: // Vuetify
export interface SomeVuetifyEmitEvent {
id: unknown
value: boolean
path: unknown[]
event: MouseEvent | PointerEvent
}
emits: {
'update:selected': (value: unknown[]) => true,
'update:opened': (value: unknown[]) => true,
'click:open': (value: SomeVuetifyEmitEvent) => true,
'click:select': (value: SomeVuetifyEmitEvent) => true,
},
// Client
import type { SomeVuetifyEmitEvent } from 'vuetify/VSelect'
function onSortSelect(event: SomeVuetifyEmitEvent) {
const id = event.id as string
const paths event.paths as string[]
} |
How do I get at generic types like |
In case anyone is trying to do this with JSDoc -- this works. <v-data-table
v-model:items-per-page="table.itemsPerPage"
v-model:sort-by="table.sortBy"
:headers="table.headers"
:loading="loading"
:items="scores"
:items-per-page-options="table.itemsPerPageOptions"
>
... <script>
/**
* @typedef { import("vuetify/components").VDataTable["$props"]["headers"] } VDataTableHeaders
* @typedef { import("vuetify/components").VDataTable["$props"]["sortBy"] } VDataTableSortItems
*/
</script> <script setup>
const table = reactive({
/** @type {VDataTableHeaders} */
headers: [
{ sortable: true, title: 'Label', value: 'label' },
{ align: 'end', sortable: true, title: 'Score', value: 'score' }
],
itemsPerPage: 5,
itemsPerPageOptions: [
{ value: 5, title: '5' },
{ value: -1, title: '$vuetify.dataFooter.itemsPerPageAll' }
],
/** @type {VDataTableSortItems} */
sortBy: [{ key: 'score', order: 'desc' }]
})
... |
Any update on this issue? We want to access the type definition of location... |
To get my headers working without the typescript error I used Example: <script setup lang="ts">
const headers = [
{
title: "Dessert (100g serving)",
align: "start",
sortable: false,
key: "name",
},
{ title: "Calories", key: "calories", align: "end" },
{ title: "Fat (g)", key: "fat", align: "end" },
{ title: "Carbs (g)", key: "carbs", align: "end" },
{ title: "Protein (g)", key: "protein", align: "end" },
{ title: "Iron (%)", key: "iron", align: "end" },
] as const;
</script> |
seconding the importance of this I get TS errors when importing: import { |
I second this: vuetify lacks important features like resizable tables which can only be implemented via dynamic wrapper components which unfortunately will get you rid of any typings for the props/slots/etc because you cannot import them from vuetify. |
Bonus points when also adding generics support: vuejs/core#7963. That would be ideal for stuff like data tables etc |
It's been a year,Any updates? Or still have to export type define to my own file? |
Problem to solve
Let's consider next struct
We as developers don't have access to defined types, interfaces as a result in my project I have to duplicate the same TS types
Proposed solution
Just add export to types, interfaces that you already defined
The text was updated successfully, but these errors were encountered: