Skip to content

Instantly share code, notes, and snippets.

@mtaran-google
mtaran-google / oftype.ts
Created July 12, 2018 19:11
an ofType() implementation that propagates types better
import {Action} from '@ngrx/store'; // from //third_party/javascript/ngrx:ngrx_store
import {OperatorFunction} from 'rxjs';
import {filter} from 'rxjs/operators';
// Removes types from T that are not assignable to U.
export type Filter<T, U> = T extends U ? T : never;
/**
* Equivalent to the `ofType` operator provided by @ngrx/effects, but with
* smarter type inference.