Skip to content

Commit ef305af

Browse files
tetsuharuohzekibenlesh
authored andcommitted
fix(typings): make an exported function's destructuring signature explicitly.
1 parent bba13d8 commit ef305af

11 files changed

+101
-21
lines changed

src/observable/BoundCallbackObservable.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,21 @@ function dispatch<T>(state: { source: BoundCallbackObservable<T>, subscriber: Su
138138
self.add(subject.subscribe(subscriber));
139139
}
140140

141-
function dispatchNext({ value, subject }) {
141+
interface DispatchNextArg<T> {
142+
subject: AsyncSubject<T>;
143+
value: T;
144+
}
145+
function dispatchNext<T>(arg: DispatchNextArg<T>) {
146+
const { value, subject } = arg;
142147
subject.next(value);
143148
subject.complete();
144149
}
145150

146-
function dispatchError({ err, subject }) {
151+
interface DispatchErrorArg<T> {
152+
subject: AsyncSubject<T>;
153+
err: any;
154+
}
155+
function dispatchError<T>(arg: DispatchErrorArg<T>) {
156+
const { err, subject } = arg;
147157
subject.error(err);
148158
}

src/observable/BoundNodeCallbackObservable.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,21 @@ function dispatch<T>(state: { source: BoundNodeCallbackObservable<T>, subscriber
135135
self.add(subject.subscribe(subscriber));
136136
}
137137

138-
function dispatchNext({ value, subject }) {
138+
interface DispatchNextArg<T> {
139+
subject: AsyncSubject<T>;
140+
value: T;
141+
}
142+
function dispatchNext<T>(arg: DispatchNextArg<T>) {
143+
const { value, subject } = arg;
139144
subject.next(value);
140145
subject.complete();
141146
}
142147

143-
function dispatchError({ err, subject }) {
148+
interface DispatchErrorArg<T> {
149+
subject: AsyncSubject<T>;
150+
err: any;
151+
}
152+
function dispatchError<T>(arg: DispatchErrorArg<T>) {
153+
const { err, subject } = arg;
144154
subject.error(err);
145155
}

src/observable/EmptyObservable.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import {Subscriber} from '../Subscriber';
33
import {Observable} from '../Observable';
44
import {TeardownLogic} from '../Subscription';
55

6+
export interface DispatchArg<T> {
7+
subscriber: Subscriber<T>;
8+
}
9+
610
/**
711
* We need this JSDoc comment for affecting ESDoc.
812
* @extends {Ignored}
@@ -51,7 +55,8 @@ export class EmptyObservable<T> extends Observable<T> {
5155
return new EmptyObservable<T>(scheduler);
5256
}
5357

54-
static dispatch({ subscriber }) {
58+
static dispatch<T>(arg: DispatchArg<T>) {
59+
const { subscriber } = arg;
5560
subscriber.complete();
5661
}
5762

src/observable/ErrorObservable.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import {Scheduler} from '../Scheduler';
22
import {Observable} from '../Observable';
33
import {TeardownLogic} from '../Subscription';
44

5+
export interface DispatchArg {
6+
error: any;
7+
subscriber: any;
8+
}
9+
510
/**
611
* We need this JSDoc comment for affecting ESDoc.
712
* @extends {Ignored}
@@ -53,7 +58,8 @@ export class ErrorObservable extends Observable<any> {
5358
return new ErrorObservable(error, scheduler);
5459
}
5560

56-
static dispatch({ error, subscriber }) {
61+
static dispatch(arg: DispatchArg) {
62+
const { error, subscriber } = arg;
5763
subscriber.error(error);
5864
}
5965

src/observable/PromiseObservable.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,24 @@ export class PromiseObservable<T> extends Observable<T> {
8888
}
8989
}
9090

91-
function dispatchNext({ value, subscriber }) {
91+
interface DispatchNextArg<T> {
92+
subscriber: Subscriber<T>;
93+
value: T;
94+
}
95+
function dispatchNext<T>(arg: DispatchNextArg<T>) {
96+
const { value, subscriber } = arg;
9297
if (!subscriber.isUnsubscribed) {
9398
subscriber.next(value);
9499
subscriber.complete();
95100
}
96101
}
97102

98-
function dispatchError({ err, subscriber }) {
103+
interface DispatchErrorArg<T> {
104+
subscriber: Subscriber<T>;
105+
err: any;
106+
}
107+
function dispatchError<T>(arg: DispatchErrorArg<T>) {
108+
const { err, subscriber } = arg;
99109
if (!subscriber.isUnsubscribed) {
100110
subscriber.error(err);
101111
}

src/observable/SubscribeOnObservable.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import {Observable} from '../Observable';
55
import {asap} from '../scheduler/asap';
66
import {isNumeric} from '../util/isNumeric';
77

8+
export interface DispatchArg<T> {
9+
source: Observable<T>;
10+
subscriber: Subscriber<T>;
11+
}
12+
813
/**
914
* We need this JSDoc comment for affecting ESDoc.
1015
* @extends {Ignored}
@@ -15,7 +20,8 @@ export class SubscribeOnObservable<T> extends Observable<T> {
1520
return new SubscribeOnObservable(source, delay, scheduler);
1621
}
1722

18-
static dispatch<T>({ source, subscriber }): Subscription {
23+
static dispatch<T>(arg: DispatchArg<T>): Subscription {
24+
const { source, subscriber } = arg;
1925
return source.subscribe(subscriber);
2026
}
2127

src/operator/bufferTime.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,22 @@ function dispatchBufferTimeSpanOnly(state: any) {
152152
}
153153
}
154154

155+
interface DispatchArg<T> {
156+
subscriber: BufferTimeSubscriber<T>;
157+
buffer: Array<T>;
158+
}
159+
155160
function dispatchBufferCreation<T>(state: CreationState<T>) {
156161
const { bufferCreationInterval, bufferTimeSpan, subscriber, scheduler } = state;
157162
const buffer = subscriber.openBuffer();
158163
const action = <Action<CreationState<T>>>this;
159164
if (!subscriber.isUnsubscribed) {
160-
action.add(scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber, buffer }));
165+
action.add(scheduler.schedule<DispatchArg<T>>(dispatchBufferClose, bufferTimeSpan, { subscriber, buffer }));
161166
action.schedule(state, bufferCreationInterval);
162167
}
163168
}
164169

165-
function dispatchBufferClose({ subscriber, buffer }) {
170+
function dispatchBufferClose<T>(arg: DispatchArg<T>) {
171+
const { subscriber, buffer } = arg;
166172
subscriber.closeBuffer(buffer);
167173
}

src/operator/expand.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ export class ExpandOperator<T, R> implements Operator<T, R> {
4343
}
4444
}
4545

46+
interface DispatchArg<T, R> {
47+
subscriber: ExpandSubscriber<T, R>;
48+
result: Observable<R>;
49+
value: any;
50+
index: number;
51+
}
52+
4653
/**
4754
* We need this JSDoc comment for affecting ESDoc.
4855
* @ignore
@@ -64,7 +71,8 @@ export class ExpandSubscriber<T, R> extends OuterSubscriber<T, R> {
6471
}
6572
}
6673

67-
private static dispatch({subscriber, result, value, index}): void {
74+
private static dispatch<T, R>(arg: DispatchArg<T, R>): void {
75+
const {subscriber, result, value, index} = arg;
6876
subscriber.subscribeToProjection(result, value, index);
6977
}
7078

@@ -85,7 +93,7 @@ export class ExpandSubscriber<T, R> extends OuterSubscriber<T, R> {
8593
} else if (!this.scheduler) {
8694
this.subscribeToProjection(result, value, index);
8795
} else {
88-
const state = { subscriber: this, result, value, index };
96+
const state: DispatchArg<T, R> = { subscriber: this, result, value, index };
8997
this.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
9098
}
9199
} else {

src/operator/observeOn.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export class ObserveOnOperator<T> implements Operator<T, T> {
3737
* @extends {Ignored}
3838
*/
3939
export class ObserveOnSubscriber<T> extends Subscriber<T> {
40-
static dispatch({ notification, destination }) {
40+
static dispatch(arg: ObserveOnMessage) {
41+
const { notification, destination } = arg;
4142
notification.observe(destination);
4243
}
4344

@@ -66,7 +67,7 @@ export class ObserveOnSubscriber<T> extends Subscriber<T> {
6667
}
6768
}
6869

69-
class ObserveOnMessage {
70+
export class ObserveOnMessage {
7071
constructor(public notification: Notification<any>,
7172
public destination: PartialObserver<any>) {
7273
}

src/operator/throttleTime.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class ThrottleTimeSubscriber<T> extends Subscriber<T> {
6060
}
6161
}
6262

63-
function dispatchNext<T>({ subscriber }) {
63+
interface DispatchArg<T> {
64+
subscriber: ThrottleTimeSubscriber<T>;
65+
}
66+
67+
function dispatchNext<T>(arg: DispatchArg<T>) {
68+
const { subscriber } = arg;
6469
subscriber.clearThrottle();
6570
}

0 commit comments

Comments
 (0)