From 2ecf10b1ed5eb842b4cb2032da1ecb07c42a81d4 Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Thu, 23 Aug 2018 11:34:20 +0200 Subject: [PATCH 1/3] fix(subscribable): make subscribe() signature match Observable Fixes #3891 --- src/internal/types.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/internal/types.ts b/src/internal/types.ts index f29cae4194..9581f98ccb 100644 --- a/src/internal/types.ts +++ b/src/internal/types.ts @@ -39,9 +39,8 @@ export type SubscribableOrPromise = Subscribable | Subscribable | P /** OBSERVABLE INTERFACES */ export interface Subscribable { - subscribe(observerOrNext?: PartialObserver | ((value: T) => void), - error?: (error: any) => void, - complete?: () => void): Unsubscribable; + subscribe(observer?: PartialObserver): Unsubscribable; + subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Unsubscribable; } export type ObservableInput = SubscribableOrPromise | ArrayLike | Iterable; From 86e2707fafb3cb8384ed5fb3aa1e7141f7c35592 Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Thu, 23 Aug 2018 12:43:06 +0200 Subject: [PATCH 2/3] test: cast string | number to string before concatenating T of this Observable is string | number, so TypeScript does not allow using +. The desired behaviour for this function is to concatenate the string values, so cast to strings. On master, these were incorrectly inferred as never, which is why this error was not surfaced. --- spec/operators/zipAll-spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/operators/zipAll-spec.ts b/spec/operators/zipAll-spec.ts index 376c1fb469..f558268d14 100644 --- a/spec/operators/zipAll-spec.ts +++ b/spec/operators/zipAll-spec.ts @@ -39,7 +39,7 @@ describe('zipAll operator', () => { of('a', 'b', 'c'), of(1, 2, 3) ) - .pipe(zipAll((a, b) => a + b)) + .pipe(zipAll((a, b) => String(a) + String(b))) .subscribe((x) => { expect(x).to.equal(expected[i++]); }, null, done); @@ -378,7 +378,7 @@ describe('zipAll operator', () => { of('a', 'b', 'c'), of(1, 2) ) - .pipe(zipAll((a, b) => a + b)) + .pipe(zipAll((a, b) => String(a) + String(b))) .subscribe((x) => { expect(x).to.equal(expected[i++]); }, null, done); From 2706b1a83856c2364eaff16867b1b6d5cb631a16 Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Thu, 23 Aug 2018 12:43:40 +0200 Subject: [PATCH 3/3] test: correct type for selector function The hot() function will create an Observable that emits strings from marble diagrams (even if the strings contain numbers). So the type of x should be string, not number. --- spec/operators/zipAll-spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/operators/zipAll-spec.ts b/spec/operators/zipAll-spec.ts index f558268d14..6b8d0af1c1 100644 --- a/spec/operators/zipAll-spec.ts +++ b/spec/operators/zipAll-spec.ts @@ -231,7 +231,7 @@ describe('zipAll operator', () => { const b = [4, 5, 6]; const expected = '---x--#'; - const selector = function (x: number, y: number) { + const selector = function (x: string, y: number) { if (y === 5) { throw new Error('too bad'); } else {