diff --git a/spec/util/isObservable-spec.ts b/spec/util/isObservable-spec.ts index 91d7d2ae0a..24fb6f69dc 100644 --- a/spec/util/isObservable-spec.ts +++ b/spec/util/isObservable-spec.ts @@ -23,4 +23,13 @@ describe('isObservable', () => { expect(isObservable(o)).to.be.false; }); + + it('should return false for null', () => { + expect(isObservable(null)).to.be.false; + }); + + it('should return false for a number', () => { + expect(isObservable(1)).to.be.false; + }); + }); diff --git a/src/internal/util/isObservable.ts b/src/internal/util/isObservable.ts index 2bda600928..f3df52485b 100644 --- a/src/internal/util/isObservable.ts +++ b/src/internal/util/isObservable.ts @@ -6,5 +6,5 @@ import { ObservableInput } from '../types'; * @param obj the object to test */ export function isObservable(obj: any): obj is Observable { - return obj && obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'); + return !!obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function')); }