Open
Description
I was trying write something like
const [callback, flag] = useEventCallback<
React.MouseEvent<HTMLElement> | boolean,
boolean
>($events => $events.pipe(mapTo(false)), false)
callback(true)
And there was type error.
Argument of type 'true' is not assignable to parameter of type 'false & true & MouseEvent<HTMLElement, MouseEvent>'.
Type 'true' is not assignable to type 'false'.ts(2345)
Checking the source
rxjs-hooks/src/use-event-callback.ts
Line 6 in 2b781f1
It seems like for example
type Callback = VoidableEventCallback<string | boolean>
will be resolved as
type Callback = ((e: string) => void) | ((e: false) => void) | ((e: true) => void)
which means e
has to be string & boolean
. Is this a bug or am I missing something here?
Metadata
Metadata
Assignees
Labels
No labels