Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ts for datatable #6486

Merged
merged 1 commit into from Nov 10, 2022
Merged

Conversation

britt6612
Copy link
Collaborator

What does this PR do?

Update the TS def for rowDetails in DataTable

Where should the reviewer start?

index.d.ts

What testing has been done on this PR?

locally

How should this be manually tested?

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

rowDetails takes a function as its argument. For example:

rowDetails={(row) => {return I am a box;}}

Typescript throws this error:

TS2769: No overload matches this call.
Overload 1 of 2, '(props: DataTableExtendedProps | Readonly<DataTableExtendedProps>): DataTable<...>', gave the following error.
Type '() => JSX.Element' is not assignable to type 'ReactNode'.
Overload 2 of 2, '(props: DataTableExtendedProps, context: any): DataTable', gave the following error.
Type '() => JSX.Element' is not assignable to type 'ReactNode'.

To fix it, I have updated src/js/components/DataTable/index.d.ts

I replace line 86 with this:

rowDetails?: (row: TRowType) => React.ReactNode;

What are the relevant issues?

closes #6477

Screenshots (if appropriate)

Do the grommet docs need to be updated?

no

Should this PR be mentioned in the release notes?

no

Is this change backwards compatible or is it a breaking change?

backwards compatible

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ericsoderberghp ericsoderberghp merged commit 119505f into grommet:master Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rowDetails in datatable seems to be incorrectly typed in typescript
3 participants