[ramda] Why does dissoc uses a generic ?
See original GitHub issueActual definition is :
declare function dissoc<T>(
key: string,
...args: Array<void>
): (src: { [k: string]: T }) => { [k: string]: T };
declare function dissoc<T>(
key: string,
src: { [k: string]: T }
): { [k: string]: T };
I don’t get why we want to enforce a unique type T
a object content ?
I have a union use case where this causes trouble :
// @flow
import * as R from 'ramda'
type OtherType = { toto: string }
export type ActionA = {|
type: string,
payload: {| somePayload: string |}
|}
export type ActionB = {|
type: string,
payload: {| someOtherPayload: OtherType |}
|}
export type Action = ActionA | ActionB
const filterAction = (a: Action): {} => R.dissoc('type')(a)
I don’t see why Flow errors, and I don’t see any problem with this code …
When I change libdef to the following, I don’t have any problem :
declare function dissoc(
key: string
): (src: { [k: string]: any }) => { [k: string]: any };
declare function dissoc(
key: string,
src: { [k: string]: any }
): { [k: string]: any };
Issue Analytics
- State:
- Created 5 years ago
- Comments:25 (25 by maintainers)
Top Results From Across the Web
Ramda Documentation
(This latter might be unimportant if the list parameter is not used.) Open in REPL ... Run it here. R.dissoc('b', {a: 1, b:...
Read more >Typescript typing issue #2487 - ramda/ramda - GitHub
Should we ensure that all Ramda functions can be used with Elm, ... export function dissoc (...rest: any[]): any; export function dissocPath ...
Read more >ramda/ramda - Gitter
Hi everyone, I'm new to Ramda (and FP) and was hoping for some help with ... two functions, with difference in using assoc...
Read more >Thinking in Ramda: Immutability and Arrays - Randy Coulman
Ramda has even more methods for reading array elements. ... For objects, we learned about assoc , dissoc , and omit for adding,...
Read more >Use Ramda.js to pull off items from object - Stack Overflow
Lenses are probably your best bet for this. Ramda has a generic lens function, and specific ones for an object property ( lensProp...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Don’t we want
(obj1.a: number | string | boolean)
to fail becausea
is not onobj1
, and(obj1.b: number | string | boolean)
to fail because it is astring
?Oops, you’re quite right, I had missed that.