question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(TypeScript) Type definitions are incomplete for sortable tables.

See original GitHub issue

Describe the bug (required) Some type definitions are incomplete – in the column for example. Property 'getSortByToggleProps' does not exist on type 'HeaderGroup<object>'.ts(2339) Property 'isSorted' does not exist on type 'HeaderGroup<object>'.ts(2339) Property 'isSortedDesc' does not exist on type 'HeaderGroup<object>'.ts(2339)

Provide an example via Codesandbox! (required) https://codesandbox.io/s/react-table-incomplete-types-x1es6

Steps To Reproduce (required) Try to use useSortBy on react-table and consume the getSortByToggleProps function or isSorted and isSortedDesc properties on a TypeScript project.

Expected behavior (Recommended) The types shouldn’t error

Screenshots Screen Shot 2021-01-05 at 20 55 25

This bug was reported without any information before and noticed they were also using TypeScript so I could only figure it was TypeScript specific. https://github.com/tannerlinsley/react-table/issues/1481

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:58
  • Comments:25

github_iconTop GitHub Comments

125reactions
samyancommented, Mar 2, 2021

I had a similar issue with another plugin. The solution i got, was creating folder called types in /src directory and then creating a file called react-table-config.d.ts. Then put the definitions that you can find in: types/react-table.

Now you can check: image

Example: https://codesandbox.io/s/react-table-incomplete-types-fixed-2r4us

Regards.

33reactions
nikauppcommented, Feb 10, 2021

After some digging it appears that this is expected behaviour of the @types/react-table package, and it has documentation on how to include types for the table plugins that you are using, not ideal but presumably this is because the plugins are optional…

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-table#configuration-using-declaration-merging

In all fairness, the plugins don’t feel all that optional as they are included in base package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

(TypeScript) Type definitions are incomplete for sortable tables.
Some type definitions are incomplete -- in the column for example. Property 'getSortByToggleProps' does not exist on type 'HeaderGroup<object>'.
Read more >
(TypeScript) Type definitions are incomplete for sortable tables.
(TypeScript) Type definitions are incomplete for sortable tables.
Read more >
react-table and TypeScript: how do custom properties on ...
TypeScript complains about these two properties that I've added to columns : Property 'className' does not exist on type 'ColumnInstance<object> ...
Read more >
Advanced type safety (Reference) - Prisma
Prisma Client provides full type safety for queries, even for partial queries or ... Generated types are TypeScript types that are derived from...
Read more >
Options - TypeDoc
TypeDoc accepts most of the command line arguments that the TypeScript ... These definitions will be used for both types linked to by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found