0
votes

I get the following typescript error:

Error:(34, 20) TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'number | Scheduler'. Type 'undefined[]' is not assignable to type 'Scheduler'. Property 'now' is missing in type 'undefined[]'.

when using startWith in this context:

items$:any = Observable
        .interval(250)
        .map((_:any) => Math.random())
        .startWith([])
        .scan((acc:any, curr:any)=> [...acc, curr]);

wondering of any way to cast to avoid the error?

regards

Sean

1

1 Answers

4
votes
show = false;
items$:any = Observable
    .interval(500)
    .delay(500)
    .map((_:any) => Math.random())
    .startWith(<any>[])
    .scan((acc:any, curr:any)=> [...acc, curr]);

adding any did the trick