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

fix(VDataTable): improve headers value function typing #18703

Merged
merged 1 commit into from Feb 21, 2024

Conversation

xdavidwu
Copy link
Contributor

Description

Improve typing on value functions with generics.

With markup below, before:

    Types of property 'value' are incompatible.
      Type '(v: Data) => string' is not assignable to type 'SelectItemKey'.
        Type '(v: Data) => string' is not assignable to type '(item: Record<string, any>, fallback?: any) => any'.
          Types of parameters 'v' and 'item' are incompatible.
            Property 'string' is missing in type 'Record<string, any>' but required in type 'Data'.

4       <v-data-table :items="items" :headers="headers" />

after: passes typecheck.

Markup:

<template>
  <v-app>
    <v-container>
      <v-data-table :items="items" :headers="headers" />
    </v-container>
  </v-app>
</template>

<script lang="ts">
  interface Data {
    string: string
  }

  export default {
    name: 'Playground',
    setup () {
      return {
        items: [
          { string: 'foo' },
          { string: 'bar' },
        ] as Data[],
        headers: [
          { key: 'foobar', title: 'String', value: (v: Data) => v.string },
        ],
      }
    },
  }
</script>

@johnleider
Copy link
Member

Can you reach out to me on Discord?

@KaelWD KaelWD force-pushed the master branch 3 times, most recently from cd170f8 to 98e57dc Compare February 14, 2024 06:14
@johnleider johnleider added this to the v3.5.x milestone Feb 21, 2024
@johnleider johnleider enabled auto-merge (squash) February 21, 2024 21:19
@johnleider johnleider merged commit 54f05f2 into vuetifyjs:master Feb 21, 2024
10 checks passed
VIXI0 pushed a commit to VIXI0/vuetify that referenced this pull request Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants