ElemeFE / element-react

Element UI
https://elemefe.github.io/element-react/index
MIT License
2.83k stars 444 forks source link

add typescript table row generics #1077

Open johanninos opened 3 years ago

johanninos commented 3 years ago

In current version the following code with typescript would get error

 const columns = {
    props: 'amount',
    title: 'amount',
    render: (row?: SymbolWithQuotation) => (
      //blablabla
    )
  }

const data: SymbolWithQuotation[] = [...some data];

<Table columns={columns} data={data} />

ts error:

    属性“render”的类型不兼容。
            不能将类型“(row?: SymbolWithQuotation | undefined) => JSX.Element”分配给类型“(data?: Object | undefined, column?: Object | undefined, index?: number | undefined) => void”。
              参数“row”和“data” 的类型不兼容。
                不能将类型“Object | undefined”分配给类型“SymbolWithQuotation | undefined”。

.........others details

Add a generics to replace the data?: Object | undefined to fix it

Please makes sure these boxes are checked before submitting your PR, thank you!

Changes in this pull request