DataTableSlots type narrowing not working properly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
I was using the NPM version of datatables.net-react, but was getting the whitespace warning on the props.children, which has been fixed recently.
I decided to checkout and build the newer version to eliminate this warning,
When I build my application, it is failing saying that:
./src/lib/components/datatables-react/src/components/DataTable/index.tsx:267:17
Type error: Expected 4 arguments, but got 3.
The issue seems to be the new signature added to DataTableSlots which allow the "meta" object to be passed with a slot.
The code is using Array.length with strict equality to narrow the type selection, but it doesnt seem to be working as intended.
Some internet sources say that using the array length property may not work for narrowing.
I have tried some other ways to narrow it down, but have been unsuccessful.
For now I am just going to remove the extra type union and just revert that section of code, but wanted to bring it up here to see if a proper fix can be released, or someone tell me what I am doing wrong, or some way to solve it.
My application uses nextJS 14.2.28, TypeScript 5.8.3 and ESLint 8.57.1 with typescript plugins at 6.21.0
When do you expect this latest version will be available on NPM?
I also did not see the package version updated in package.json, the npm version and the latest changes have 1.0.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read src/lib/components/datatables-react/src/components/DataTable/index.tsx around line 267 and inspect the DataTableSlots signature and its length-based narrowing. Reproduce the TypeScript 5.8.3 build failure, then verify that the component builds without the three-versus-four-argument error and that the updated package version is reflected as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100