Skip to content

Commit 0e2ef5e

Browse files
authored
fix(subscriber): strict type signature for next method (#7172)
1 parent b6d00c1 commit 0e2ef5e

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/Subscriber-spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('SafeSubscriber', () => {
99
it('should ignore next messages after unsubscription', () => {
1010
let times = 0;
1111

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

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

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

47-
const sub = new SafeSubscriber({
47+
const sub = new SafeSubscriber<void>({
4848
next() { times += 1; },
4949
complete() { completeCalled = true; }
5050
});
@@ -268,4 +268,4 @@ describe('Subscriber', () => {
268268
} else {
269269
console.warn(`No support for FinalizationRegistry in Node ${process.version}`);
270270
}
271-
});
271+
});

src/internal/Subscriber.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class Subscriber<T> extends Subscription implements Observer<T> {
6464
* times.
6565
* @param value The `next` value.
6666
*/
67-
next(value?: T): void {
67+
next(value: T): void {
6868
if (this.isStopped) {
6969
handleStoppedNotification(nextNotification(value), this);
7070
} else {
@@ -197,7 +197,7 @@ export class SafeSubscriber<T> extends Subscriber<T> {
197197
// The first argument is a function, not an observer. The next
198198
// two arguments *could* be observers, or they could be empty.
199199
partialObserver = {
200-
next: (observerOrNext ?? undefined) as (((value: T) => void) | undefined),
200+
next: (observerOrNext ?? undefined) as ((value: T) => void) | undefined,
201201
error: error ?? undefined,
202202
complete: complete ?? undefined,
203203
};

0 commit comments

Comments
 (0)