Skip to content

Commit 1c5673f

Browse files
authored
fix(Subscriber): next method no longer has optional value argument (#7290)
resolves #2852
1 parent 0fe6b2f commit 1c5673f

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

spec-dtslint/Observable-spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,11 @@ describe('pipe', () => {
131131
const o2 = of(123).pipe(map(n => n + '?'), source => source.subscribe()); // $ExpectType Subscription
132132
const o3 = of('test').pipe(map(n => n + ':' + n), filter(n => n < 30)); // $ExpectError
133133
})
134+
});
135+
136+
it('should provide the proper types to the subscriber', () => {
137+
const o1$ = new Observable<number>(subscriber => {
138+
const next = subscriber.next; // $ExpectType (value: number) => void
139+
subscriber.next(); // $ExpectError
140+
});
134141
});

spec/Subscriber-spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('Subscriber', () => {
99
it('should ignore next messages after unsubscription', () => {
1010
let times = 0;
1111

12-
const sub = new Subscriber({
12+
const sub = new Subscriber<void>({
1313
next() { times += 1; }
1414
});
1515

@@ -25,7 +25,7 @@ describe('Subscriber', () => {
2525
let times = 0;
2626
let errorCalled = false;
2727

28-
const sub = new Subscriber({
28+
const sub = new Subscriber<void>({
2929
next() { times += 1; },
3030
error() { errorCalled = true; }
3131
});
@@ -44,7 +44,7 @@ describe('Subscriber', () => {
4444
let times = 0;
4545
let completeCalled = false;
4646

47-
const sub = new Subscriber({
47+
const sub = new Subscriber<void>({
4848
next() { times += 1; },
4949
complete() { completeCalled = true; }
5050
});

src/internal/Subscriber.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class Subscriber<T> extends Subscription implements Observer<T> {
123123
* times.
124124
* @param value The `next` value.
125125
*/
126-
next(value?: T): void {
126+
next(value: T): void {
127127
if (this.isStopped) {
128128
handleStoppedNotification(nextNotification(value), this);
129129
} else {

0 commit comments

Comments
 (0)