DataTable typing errors

UI Components for React
Post Reply
ross.gardner
Posts: 2
Joined: 28 Dec 2017, 15:25

28 Dec 2017, 18:13

I am receiving type errors in Typescript version 2.6.2 with PrimeReact DataTable version 1.3.1. Using your sample code for rowexpand:

Code: Select all

                    <DataTable value={this.state.cars} expandedRows={this.state.expandedRows} onRowToggle={(e) => this.setState({expandedRows:e.data})}     
                            rowExpansionTemplate={this.rowExpansionTemplate}>
                        <Column expander={true} style={{width: '2em'}} />
                        <Column field="vin" header="Vin" />
                        <Column field="year" header="Year" />
                        <Column field="brand" header="Brand" />
                        <Column field="color" header="Color" />
                    </DataTable>
I get a type error with onRowToggle:

Code: Select all

TS2322: Type '{ value: any; expandedRows: any[]; onRowToggle: (e: any) => void; rowExpansionTemplate: () => Ele...' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<DataTable> & Readonly<{ children?: ReactNode; }> &...'.
  Type '{ value: any; expandedRows: any[]; onRowToggle: (e: any) => void; rowExpansionTemplate: () => Ele...' is not assignable to type 'Readonly<DataTableProps>'.
    Types of property 'onRowToggle' are incompatible.
      Type '(e: any) => void' is not assignable to type '(() => void) | undefined'.
        Type '(e: any) => void' is not assignable to type '() => void'.
I also get a type error when I use a function rowExpansionTemplate(data). It's requiring rowExpansionTemplate().

Code: Select all

TS2322: Type '{ value: any; expandedRows: any[]; onRowToggle: () => void; rowExpansionTemplate: (data: any) => ...' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<DataTable> & Readonly<{ children?: ReactNode; }> &...'.
  Type '{ value: any; expandedRows: any[]; onRowToggle: () => void; rowExpansionTemplate: (data: any) => ...' is not assignable to type 'Readonly<DataTableProps>'.
    Types of property 'rowExpansionTemplate' are incompatible.
      Type '(data: any) => Element' is not assignable to type '(() => void) | undefined'.
        Type '(data: any) => Element' is not assignable to type '() => void'.
Thanks for your help.

-Ross

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

04 Jan 2018, 19:50

We'll check, thank you.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

04 Jan 2018, 21:19

Fixed for 1.4.0 due 5th of January.

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests