element-react icon indicating copy to clipboard operation
element-react copied to clipboard

add typescript table row generics

Open johanninos opened this issue 4 years ago • 0 comments

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!

  • [x] Make sure you are merging your commits to master branch.
  • [x] Add some descriptions and refer relative issues for you PR.
  • [x] Rebase your commits to make your pull request meaningful.
  • [x] Make sure that your changes pass npm test, npm run lint and npm run build.

Changes in this pull request

  • add typescript table row generics

johanninos avatar Jul 27 '20 08:07 johanninos