In my TypeScript project, I am working with RxJS and trying to implement the combineLatest
function. Below is the method I have defined:
myMethod(): Observable<{ one: string }> {
return combineLatest({
one: of('one'),
two: of('two'),
});
}
I was expecting a TypeScript compilation error because the return type of my method specifies
Observable<{ one: string }>
, but the combineLatest
function actually returns an observable that includes both one
and two
properties, which does not align with the return type of the method.
If anyone can provide an explanation or some guidance on this issue, I would greatly appreciate it.