diff --git a/spec-dtslint/Observable-spec.ts b/spec-dtslint/Observable-spec.ts index 2c3a308afb..88fda76aae 100644 --- a/spec-dtslint/Observable-spec.ts +++ b/spec-dtslint/Observable-spec.ts @@ -131,4 +131,11 @@ describe('pipe', () => { const o2 = of(123).pipe(map(n => n + '?'), source => source.subscribe()); // $ExpectType Subscription const o3 = of('test').pipe(map(n => n + ':' + n), filter(n => n < 30)); // $ExpectError }) +}); + +it('should provide the proper types to the subscriber', () => { + const o1$ = new Observable(subscriber => { + const next = subscriber.next; // $ExpectType (value: number) => void + subscriber.next(); // $ExpectError + }); }); \ No newline at end of file diff --git a/spec/Subscriber-spec.ts b/spec/Subscriber-spec.ts index 9dee9825e2..a0124694f8 100644 --- a/spec/Subscriber-spec.ts +++ b/spec/Subscriber-spec.ts @@ -9,7 +9,7 @@ describe('Subscriber', () => { it('should ignore next messages after unsubscription', () => { let times = 0; - const sub = new Subscriber({ + const sub = new Subscriber({ next() { times += 1; } }); @@ -25,7 +25,7 @@ describe('Subscriber', () => { let times = 0; let errorCalled = false; - const sub = new Subscriber({ + const sub = new Subscriber({ next() { times += 1; }, error() { errorCalled = true; } }); @@ -44,7 +44,7 @@ describe('Subscriber', () => { let times = 0; let completeCalled = false; - const sub = new Subscriber({ + const sub = new Subscriber({ next() { times += 1; }, complete() { completeCalled = true; } }); diff --git a/src/internal/Subscriber.ts b/src/internal/Subscriber.ts index 10f815049d..a429d81a34 100644 --- a/src/internal/Subscriber.ts +++ b/src/internal/Subscriber.ts @@ -123,7 +123,7 @@ export class Subscriber extends Subscription implements Observer { * times. * @param value The `next` value. */ - next(value?: T): void { + next(value: T): void { if (this.isStopped) { handleStoppedNotification(nextNotification(value), this); } else {