T
TanStack2y ago
grumpy-cyan

GetValue type lost

Hi I'm trying to define columns using ColumnDef, but for some reason the type on "getValue" in cell is unknown.
type Char = {
id: number;
name: string;
rankId: number;
rank: {
id: number;
name: string;
shortname: string;
value: number;
};
user: string;
joinedAt: Date;
rankChangedAt: Date;
};
type Char = {
id: number;
name: string;
rankId: number;
rank: {
id: number;
name: string;
shortname: string;
value: number;
};
user: string;
joinedAt: Date;
rankChangedAt: Date;
};
export const columns: ColumnDef<Char>[] = [
{
id: "rank",
accessorKey: "rank",
header: "Rank",
cell: ({ getValue}) => {
const rank = getValue();
console.log(rank.shortname);
return "test";
},
},
{
accessorKey: "id",
header: "ID",
},
{
accessorKey: "name",
header: "Name",
},
];
export const columns: ColumnDef<Char>[] = [
{
id: "rank",
accessorKey: "rank",
header: "Rank",
cell: ({ getValue}) => {
const rank = getValue();
console.log(rank.shortname);
return "test";
},
},
{
accessorKey: "id",
header: "ID",
},
{
accessorKey: "name",
header: "Name",
},
];
No description
3 Replies
rare-sapphire
rare-sapphire2y ago
rare-sapphire
rare-sapphire2y ago
Looking at its type defs, it looks like the accessor helper will either infer the TValue type for you, or you can specify it yourself.
grumpy-cyan
grumpy-cyanOP2y ago
it works, but this way also should infer the type

Did you find this page helpful?