-
-
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
fix(types): export type for VDataTable headers #21052
base: master
Are you sure you want to change the base?
Conversation
Note that not only |
@BalagePMI , I get it would be convenient, but Lookup Types seem to enable deeper access. Actually I just noticed the type I am trying to explicitly export is also available through this technique - making this PR more like enhancement than a fix. const actionTitle = ref<VDataTable['$props']['headers'][0]['title'] | null>(null)
const titleLowercase = computed(() => actionTitle.value?.toLowerCase())
// can be assigned to an alias
type VDataTableHeader = VDataTable['$props']['headers']
const headers: VDataTableHeader = [
{ title: 'Name', value: 'name' },
{ title: 'Age', value: 'age' },
{ text: 'Email', value: 'email' }, // should underline `text`
] |
For me, it doesn't work: import { VDataTable } from 'vuetify/components'
export type DataTableHeader = VDataTable['$props']['headers'] And using it: const def : DataTableHeader = {
key: header.key,
title: header.title ?? i18n.t(props.itemCode + '.columns.' + header.key + '.title'),
align: header.align ?? 'start',
sortable: header.sortable ?? false
}
if (header.maxWidth) {
def.maxWidth = convertWidth(header.maxWidth, undefined)
}
def.width = convertWidth(header.width, def.maxWidth)
console.log('header', def.key, def)
return def
})]
}) marks key, maxWidth, width as not in type, because DataTableHeader is identified as Also, this access of type looks as bad as declaring my own as it digs deeply into a structure. |
You need I cannot extract single header locally, because of Weird that it works on VPlay demo just fine: |
Workaround: import type { VDataTable } from 'vuetify/components/VDataTable'
export type DataTableHeaders = VDataTable['$props']['headers'] & {}
export type DataTableHeader = DataTableHeaders[0] // take single header |
Description
followup to #16680
It seems to be one of the common requests on Discord.
Markup: