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): next method no longer has optional value argument #7290

Merged
merged 1 commit into from
Jun 19, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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