Skip to content

Commit

Permalink
fix(Subscriber): next method no longer has optional value argument (#…
Browse files Browse the repository at this point in the history
…7290)

resolves #2852
  • Loading branch information
benlesh authored Jun 19, 2023
1 parent 0fe6b2f commit 1c5673f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions spec-dtslint/Observable-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>(subscriber => {
const next = subscriber.next; // $ExpectType (value: number) => void
subscriber.next(); // $ExpectError
});
});
6 changes: 3 additions & 3 deletions spec/Subscriber-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Subscriber', () => {
it('should ignore next messages after unsubscription', () => {
let times = 0;

const sub = new Subscriber({
const sub = new Subscriber<void>({
next() { times += 1; }
});

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

const sub = new Subscriber({
const sub = new Subscriber<void>({
next() { times += 1; },
error() { errorCalled = true; }
});
Expand All @@ -44,7 +44,7 @@ describe('Subscriber', () => {
let times = 0;
let completeCalled = false;

const sub = new Subscriber({
const sub = new Subscriber<void>({
next() { times += 1; },
complete() { completeCalled = true; }
});
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Subscriber<T> extends Subscription implements Observer<T> {
* times.
* @param value The `next` value.
*/
next(value?: T): void {
next(value: T): void {
if (this.isStopped) {
handleStoppedNotification(nextNotification(value), this);
} else {
Expand Down

0 comments on commit 1c5673f

Please sign in to comment.