From c8560e4ccc93a839b86e8101547aeb78a6a5a8d2 Mon Sep 17 00:00:00 2001 From: tdeschryver Date: Mon, 5 Feb 2018 20:52:12 +0100 Subject: [PATCH] fix(Effects): Make ofType operator strictFunctionTypes safe (#789) Closes #753 --- modules/effects/src/actions.ts | 12 +++++------- modules/schematics/src/container/index.spec.ts | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/effects/src/actions.ts b/modules/effects/src/actions.ts index a7e6aaa448..fb06b27978 100644 --- a/modules/effects/src/actions.ts +++ b/modules/effects/src/actions.ts @@ -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() @@ -23,14 +23,12 @@ export class Actions extends Observable { } ofType(...allowedTypes: string[]): Actions { - return ofType(...allowedTypes)(this as Actions); + return ofType(...allowedTypes)(this as Actions) as Actions; } } export function ofType(...allowedTypes: string[]) { - return function ofTypeOperator(source$: Actions): Actions { - 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) + ); } diff --git a/modules/schematics/src/container/index.spec.ts b/modules/schematics/src/container/index.spec.ts index 2a38e3b114..aa2276df49 100644 --- a/modules/schematics/src/container/index.spec.ts +++ b/modules/schematics/src/container/index.spec.ts @@ -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';/); });