Skip to content

Commit

Permalink
fix(Effects): Make ofType operator strictFunctionTypes safe (#789)
Browse files Browse the repository at this point in the history
Closes #753
  • Loading branch information
timdeschryver authored and MikeRyanDev committed Feb 5, 2018
1 parent a140fa9 commit c8560e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
12 changes: 5 additions & 7 deletions modules/effects/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable, Inject } from '@angular/core';
import { Action, ScannedActionsSubject } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Operator } from 'rxjs/Operator';
import { filter } from 'rxjs/operator/filter';
import { filter } from 'rxjs/operators';
import { OperatorFunction } from 'rxjs/interfaces';

@Injectable()
Expand All @@ -23,14 +23,12 @@ export class Actions<V = Action> extends Observable<V> {
}

ofType<V2 extends V = V>(...allowedTypes: string[]): Actions<V2> {
return ofType<any>(...allowedTypes)(this as Actions<any>);
return ofType<any>(...allowedTypes)(this as Actions<any>) as Actions<V2>;
}
}

export function ofType<T extends Action>(...allowedTypes: string[]) {
return function ofTypeOperator(source$: Actions<T>): Actions<T> {
return filter.call(source$, (action: Action) =>
allowedTypes.some(type => type === action.type)
);
};
return filter((action: Action): action is T =>
allowedTypes.some(type => type === action.type)
);
}
1 change: 0 additions & 1 deletion modules/schematics/src/container/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ describe('Container Schematic', () => {
appTree.create('/src/app/reducers', '');
const tree = schematicRunner.runSchematic('container', options, appTree);
const content = getFileContent(tree, '/src/app/foo/foo.component.ts');
console.log(content);
expect(content).toMatch(/import\ {\ Store\ }\ from\ '@ngrx\/store';/);
});

Expand Down

0 comments on commit c8560e4

Please sign in to comment.