-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
DataTable: The parameter of the function passed to sortIcon
has the wrong type
#4639
Comments
After my wrong PR (🤣), I found that these primereact/components/lib/utils/utils.d.ts Lines 137 to 142 in 39c5c98
|
I can fix it. Give me 5 minutes. |
This one was my first attempt but didn't worked. Because when I look at the See: primereact/components/lib/utils/utils.d.ts Line 144 in 39c5c98
|
Yep but... export interface IconOptions<ParentProps> {
iconProps: React.HTMLProps<HTMLElement>;
element: React.ReactNode;
props?: ParentProps;
[key: string]: any;
} The |
I also thought exactly the same as you but didn't worked 😄 I think it is because the |
Yep I think the generics for IconType need to be extended a little to make it more flexible but I am trying to figure out how. 😄 |
I have a suggestion, let me finalize and I can raise PR |
… in base object Closes primefaces#4639
… in base object (#4642) * feat: expose sorted and sortOrder properties for sortIcon Closes #4639 * feat: allow additional props from IconType to expose additional props in base object Closes #4639 * fix: make sortOrder and sorted propesties nullable * Update utils.d.ts --------- Co-authored-by: Melloware <mellowaredev@gmail.com>
Describe the bug
When using a function for the
sortIcon
prop of a<DataTable>
, the function's first parameter,options
, is of typeIconOptions<DataTable<TValue>>
. This type knows about icons, but not about sorting.Logging the
options
parameter to console shows it has more props than its type claims. The most important one issortOrder
, telling which direction a column is sorted. TS does not know about this, sooptions.sortOrder
defaults to typeany
. It should be0 | 1 | -1
In addition to
sortOrder
, there is also a propertysorted
which the type does not know about. Its actual type appears to for some reason benull | true
, instead ofboolean
.Reproducer
https://stackblitz.com/edit/vitejs-vite-s3jiwf?file=src%2FApp.tsx
PrimeReact version
9.6.0
React version
18.x
Language
TypeScript
Build / Runtime
Create React App (CRA)
Browser(s)
No response
Steps to reproduce the behavior
Hover
options.sortOrder
andoptions.sorted
in the reproducer. They both show typeany
.Check the console, where both props are logged. They clearly have values.
Expected behavior
The type should know about
options.sortOrder
, which should have type0 | 1 | -1
.In addition, the type should know about
options.sorted
, which for some reason should have typenull | true
The text was updated successfully, but these errors were encountered: