Solvedrxjs startWith Deprecation warning

I can't find any documentation on what is actually deprecated, but I believe this is related to: #4723.

Bug Report

Current Behavior
startWith is deprecated: use {@link scheduled} and {@link concatAll} (e.g. scheduled([[a, b, c], source], schedul er).pipe(concatAll()))

Reproduction

startWith(null);

Expected behavior
No deprecation warning

Environment

  • RxJS version: 6.5.2
18 Answers

✔️Accepted Answer

The deprecation warning also disappears when typing the null in startWith.
By default it's typed any, so I guess the compiler doesn't know it's not meant to be a SchedulerLike.

startWith(<string>null); // In case your stream emits strings

Other Answers:

startWith(null as string)

Coming from Angular, I run into it when using a pattern like

this.myFormControl.valueChanges.pipe(
    startWith(this.myFormControl.value)
  )

since FormControls are typed as any. I suspect that the false positive with any is more common than actually using the deprecated single-argument scheduler, so I'll cast a vote for removing the signature.

No hacks (obfuscating) or cheats (tslint:disable comments) please. Also null is not a string. (no cast). What's the problem if I expect (and my type is set to) optionally null? e.g. An array which could contain null values. But the deprecated error on using startWith(null) will not disappear if I change my type to fit it. Also when the type is any.
Why exactly is it marked as deprecated and what's the problem? In simple words and examples.

My current alternative for a specific case (text input element) is to use an empty string ''. It's also a falsy value. startWith(''). But the observable event is from type any. So null should also accepted.
(Background: I use Angular Material "FormControl" valueChanges.)

startWith<any,any>(blah)

More Issues: