rxjs-hooks | React hooks for RxJS | Reactive Programming library
kandi X-RAY | rxjs-hooks Summary
kandi X-RAY | rxjs-hooks Summary
React hooks for RxJS
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rxjs-hooks
rxjs-hooks Key Features
rxjs-hooks Examples and Code Snippets
Community Discussions
Trending Discussions on rxjs-hooks
QUESTION
I am using a library which has the following type defined:
...ANSWER
Answered 2019-Apr-05 at 19:50This is caused by the distributive behavior of conditional types. Conditional types distribute over naked type parameters. This means if the type parameter contains a union, the conditional type will be applied to each member of the union and the result will be the union of all applications. So in your case we would get VoidableCallback<{ type: 'add'; n: number } | { type: 'multiply'; n: number }> = VoidableCallback<{ type: 'add'; n: number }> | VoidableCallback<{ type: 'multiply'; n: number }> = ((val: { type: 'add'; n: number }) => void) | ((val: { type: 'multiply'; n: number }) => void)
You can read about this behavior here
The reason you get an error about the intersection is the way typescript deals with unions of function signatures, it basically requires that the parameters be compatible will all signatures in the union, so the parameter must be an intersection of all possible parameter types. You can read about this here
The simple solution is to disable the distribution for the conditional type. This is easily done by placing the type parameter in a tuple:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rxjs-hooks
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page