Skip to content

props columns at q-table showing error when using typescript #13687

Discussion options

You must be logged in to vote

You can use the QTableColumn type for this.

<template>
  <q-table :rows="users" :columns="columns" />
</template>

<script lang="ts" setup>
import { QTableColumn } from 'quasar';
import { ref } from 'vue';

interface User {
  id: number;
  name: string;
  address: {
    city: string;
    country: string;
  };
}

// You will get auto-complete on properties like `align`('left', 'right', etc.), `field`('id', 'name' and 'address' because of User), etc.
const columns: QTableColumn<User>[] = [
  { name: 'name', align: 'left', label: 'Name', field: 'name' },
  {
    name: 'city',
    align: 'left',
    label: 'City',
    // row is type of User, we get IntelliSense, etc.
    field: (row) => row.a…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@itsalb3rt
Comment options

Answer selected by yusufkandemir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment