Typescript strict types and rxjs filter and map combination
You will need a type guard for that:
import { Subject } from "rxjs";
import { filter, first, map } from "rxjs/operators";
type Something = {
prop: number;
};
const source = new Subject<Something | undefined>();
function isDefined<T>(arg: T | null | undefined): arg is T {
return arg !== null && arg !== undefined;
}
source.asObservable().pipe(
first(isDefined),
map((value) => {
console.log(value.prop);
})
);