`derivedFrom`: cannot provide `undefined` as `initialValue`
Opened this issue · 2 comments
mattmoos commented
I noticed that an initial value of undefined
cannot be used in derivedFrom
. I think this would be okay in itself because Angular is using undefined
implicitly as initial value. But derivedFrom
is setting requireSync: true
when it detects no initial value, cf.
and that does not work with async observables as sources
The problem seems to be here:
derivedFrom
is checking options?.initialValue !== undefined;
, thus an initial value of undefined
gets lost.
I guess this could be fixed by using Object.hasOwn(options, 'initialValue')
instead?
eneajaho commented
@mattmoos Can you provide a PR that adds a test case with your usecase (simplified) that breaks, and we can work on a fix or just use what you recommended (object.hasOwn).
mattmoos commented
Yes, just had a look at the existing test cases. I think I can provide a test.