Skip to content

Use DataIndex<RecordType> for better constraints? #435

@benallfree

Description

@benallfree

I'd like to propose this change:

Before:

export declare type DataIndex = string | number | (string | number)[];

After:

export declare type DataIndex<RecordType> = keyof RecordType | number | (keyof RecordType | number)[];

That way, you get full type checking on dataIndex like here:

const columns : ColumnsType<Client>= [
 {
      title: 'Name',
      dataIndex: 'name',   // If 'name' does not exist for type Client, a Typescript error will occur
      key: 'name',
      render: text => <a>{text}</a>
},
]

If you like it, I can send a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions