Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5eb87f

Browse files
committed
Make column renderer use the same type as its key
That way the renderer only takes `string` for example when rendering thename field instead of `string | number` when the interface has somefields that are strings and some fields are numbers.This will be necessary when switching to generated types since some ofthe fields are numbers (like the owner count on a template).
1 parent10bb649 commitd5eb87f

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

‎site/src/components/Table/Table.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@ import React from "react"
88
import{TableHeaders}from"../TableHeaders/TableHeaders"
99
import{TableTitle}from"../TableTitle/TableTitle"
1010

11-
exportinterfaceColumn<T>{
12-
/**
13-
* The field of type T that this column is associated with
14-
*/
15-
key:keyofT
16-
/**
17-
* Friendly name of the field, shown in headers
18-
*/
19-
name:string
20-
/**
21-
* Custom render for the field inside the table
22-
*/
23-
renderer?:(field:T[keyofT],data:T)=>React.ReactElement
24-
}
11+
exporttypeColumn<T>={
12+
[KinkeyofT]:{
13+
/**
14+
* The field of type T that this column is associated with
15+
*/
16+
key:K
17+
/**
18+
* Friendly name of the field, shown in headers
19+
*/
20+
name:string
21+
/**
22+
* Custom render for the field inside the table
23+
*/
24+
renderer?:(field:T[K],data:T)=>React.ReactElement
25+
}
26+
}[keyofT]
2527

2628
exportinterfaceTableProps<T>{
2729
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp