Skip to content

Commit c8560e4

Browse files
timdeschryverMikeRyanDev
authored andcommitted
fix(Effects): Make ofType operator strictFunctionTypes safe (#789)
Closes #753
1 parent a140fa9 commit c8560e4

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

modules/effects/src/actions.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Injectable, Inject } from '@angular/core';
22
import { Action, ScannedActionsSubject } from '@ngrx/store';
33
import { Observable } from 'rxjs/Observable';
44
import { Operator } from 'rxjs/Operator';
5-
import { filter } from 'rxjs/operator/filter';
5+
import { filter } from 'rxjs/operators';
66
import { OperatorFunction } from 'rxjs/interfaces';
77

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

2525
ofType<V2 extends V = V>(...allowedTypes: string[]): Actions<V2> {
26-
return ofType<any>(...allowedTypes)(this as Actions<any>);
26+
return ofType<any>(...allowedTypes)(this as Actions<any>) as Actions<V2>;
2727
}
2828
}
2929

3030
export function ofType<T extends Action>(...allowedTypes: string[]) {
31-
return function ofTypeOperator(source$: Actions<T>): Actions<T> {
32-
return filter.call(source$, (action: Action) =>
33-
allowedTypes.some(type => type === action.type)
34-
);
35-
};
31+
return filter((action: Action): action is T =>
32+
allowedTypes.some(type => type === action.type)
33+
);
3634
}

modules/schematics/src/container/index.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ describe('Container Schematic', () => {
5151
appTree.create('/src/app/reducers', '');
5252
const tree = schematicRunner.runSchematic('container', options, appTree);
5353
const content = getFileContent(tree, '/src/app/foo/foo.component.ts');
54-
console.log(content);
5554
expect(content).toMatch(/import\ {\ Store\ }\ from\ '@ngrx\/store';/);
5655
});
5756

0 commit comments

Comments
 (0)