Before Rxjs 6 we could do:
interface TypeA {
payload: any;
}
source$.pipe(
withLatestFrom(source2$, (source1: TypeA, source2: TypeB) =>
({ payload: source1.payload, source2 }) ),
)
We could, in the resultSelector method arguments, add proper types for source1
and source2
, passed along within the constructed object here.
But now we must do the following:
source$.pipe(
withLatestFrom(source2$),
map(([source1, source2]) => ({ source1, source2 }) ),
)
Doing so we are unable to add type on source1 and source2 within array argument. The typing is then lost and IDE doesn't suggest .payload
on source1
for example.
How to be able, using the new syntax, to add proper typing with array arguments?