Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(subscriber): strict type signature for next method #7172

Merged
merged 3 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions spec/Subscriber-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('SafeSubscriber', () => {
it('should ignore next messages after unsubscription', () => {
let times = 0;

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

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

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

const sub = new SafeSubscriber({
const sub = new SafeSubscriber<void>({
next() { times += 1; },
complete() { completeCalled = true; }
});
Expand Down Expand Up @@ -268,4 +268,4 @@ describe('Subscriber', () => {
} else {
console.warn(`No support for FinalizationRegistry in Node ${process.version}`);
}
});
});
4 changes: 2 additions & 2 deletions src/internal/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Subscriber<T> extends Subscription implements Observer<T> {
* @param {T} [value] The `next` value.
* @return {void}
*/
next(value?: T): void {
next(value: T): void {
if (this.isStopped) {
handleStoppedNotification(nextNotification(value), this);
} else {
Expand Down Expand Up @@ -203,7 +203,7 @@ export class SafeSubscriber<T> extends Subscriber<T> {
// The first argument is a function, not an observer. The next
// two arguments *could* be observers, or they could be empty.
partialObserver = {
next: (observerOrNext ?? undefined) as (((value: T) => void) | undefined),
next: (observerOrNext ?? undefined) as ((value: T) => void) | undefined,
error: error ?? undefined,
complete: complete ?? undefined,
};
Expand Down