use newer TS table def syntax

This commit is contained in:
Collin M. Barrett 2019-08-04 19:30:53 -05:00
parent 025e75739d
commit 0767831573
4 changed files with 10 additions and 37 deletions

View file

@ -1,6 +1,6 @@
import { Table } from 'antd';
import * as React from "react";
import { columnProps } from './columnProps';
import { nameof } from '../../utils';
import { List } from './List';
interface State {
@ -32,14 +32,10 @@ export class AllListsTable extends React.Component<{}, State> {
render() {
return (
<Table
size="small"
scroll={{ x: 1500 }}
columns={columnProps}
rowKey={record => record.id.toString()}
dataSource={this.state.data}
loading={this.state.loading}
/>
<Table<List> dataSource={this.state.data} rowKey={record => record.id.toString()} loading={this.state.loading}>
<Table.Column<List> title="Name" dataIndex={nameof<List>("name")} />
<Table.Column<List> title="Description" dataIndex={nameof<List>("description")} />
</Table>
);
}
}

View file

@ -1,28 +0,0 @@
import { ColumnProps } from "antd/lib/table";
import { List } from './List';
const nameof = <T>(name: Extract<keyof T, string>): string => name;
export const columnProps: ColumnProps<List>[] = [
{
title: 'Name',
dataIndex: nameof<List>("name"),
width: 200,
fixed: 'left'
},
{
title: 'Description',
dataIndex: nameof<List>("description"),
width: 400
},
{
title: 'Languages',
dataIndex: nameof<List>("languageIds"),
width: 400
},
{
title: 'Tags',
dataIndex: nameof<List>("tagIds"),
width: 400
}
];

View file

@ -0,0 +1,3 @@
import { nameof } from './nameof'
export { nameof }

View file

@ -0,0 +1,2 @@
//https://stackoverflow.com/a/50470026/2343739
export const nameof = <T>(name: Extract<keyof T, string>): string => name;