Comments (3)
It looks like you have a typing issue that isn't related to Remeda directly. I can't help you without seeing how everything is typed, you might be returning undefined
in your mapper.
from remeda.
As far as I remember (without running the code) you probably need to
- use
as const
at the end of the tuple (in the initial "sorts" mapper) so that typescript treats your array as an array of tuples and not an array of arrays. If the typing of sorts isn't correct when you use it in sortBy, Remeda won't be able to infer it. e.g.arr.map((item) => [(e) => { ... }, "asc"] as const)
- You don't need that last
sorts[0]
, simply spread the array.
from remeda.
@eranhirsch thanks for that. I tried this:
const sorts = sorters.map(sorter =>
[(x: Entity) => x[sorter.key], sorter.state === ColumnSortingState.Descending ? 'desc' : 'asc'] as const
);
return R.sortBy(entities, ...sorts);
So that compiles, but when I run it, I get:
ERROR TypeError: fn is not a function
at sortBy.js:40:14
at Array.sort (<anonymous>)
at sortBy (sortBy.js:39:46)
at Module.f2 (_curry2.js:28:14)
Thanks
from remeda.
Related Issues (20)
- keys.strict regression on partial records HOT 1
- Feature request: Symmetric Difference HOT 1
- Idea: Map and filter at once HOT 4
- groupBy: Generic key types HOT 2
- Submit to devdocs? HOT 6
- how to stop R.pipe( HOT 2
- keys: Wrong return value in example
- Implement intersectWith HOT 2
- Missing function: isEmpty HOT 4
- Option to filter docs by types HOT 2
- TS errors in curried `pick` HOT 2
- Question: Example removing undefined from array? HOT 2
- The sample function doesn't seem to infer types correctly HOT 1
- Helper to check if all object values are Truthy? HOT 2
- Pipe item not receiving guarded value? HOT 4
- Feature Request: swap element in Array HOT 1
- Nested object to object of key tuples HOT 1
- it would be cool if it works HOT 4
- Generate testing suites using a ChatGPT-4 CLI wrapper HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remeda.