Skip to content

Commit 56f18a6

Browse files
committed
refactor: Remove no-shadowed-variable tslint override
1 parent f51c239 commit 56f18a6

26 files changed

+87
-87
lines changed

src/internal/Observable.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ export class Observable<T> implements Subscribable<T> {
435435

436436
/* tslint:disable:max-line-length */
437437
/** @deprecated Deprecated use {@link firstValueFrom} or {@link lastValueFrom} instead */
438-
toPromise<T>(this: Observable<T>): Promise<T | undefined>;
438+
toPromise(): Promise<T | undefined>;
439439
/** @deprecated Deprecated use {@link firstValueFrom} or {@link lastValueFrom} instead */
440-
toPromise<T>(this: Observable<T>, PromiseCtor: typeof Promise): Promise<T | undefined>;
440+
toPromise(PromiseCtor: typeof Promise): Promise<T | undefined>;
441441
/** @deprecated Deprecated use {@link firstValueFrom} or {@link lastValueFrom} instead */
442-
toPromise<T>(this: Observable<T>, PromiseCtor: PromiseConstructorLike): Promise<T | undefined>;
442+
toPromise(PromiseCtor: PromiseConstructorLike): Promise<T | undefined>;
443443
/* tslint:enable:max-line-length */
444444

445445
/**

src/internal/Scheduler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class Scheduler implements SchedulerLike {
2626

2727
public static now: () => number = dateTimestampProvider.now;
2828

29-
constructor(private SchedulerAction: typeof Action,
29+
constructor(private schedulerActionCtor: typeof Action,
3030
now: () => number = Scheduler.now) {
3131
this.now = now;
3232
}
@@ -59,6 +59,6 @@ export class Scheduler implements SchedulerLike {
5959
* the scheduled work.
6060
*/
6161
public schedule<T>(work: (this: SchedulerAction<T>, state?: T) => void, delay: number = 0, state?: T): Subscription {
62-
return new this.SchedulerAction<T>(this, work).schedule(state, delay);
62+
return new this.schedulerActionCtor<T>(this, work).schedule(state, delay);
6363
}
6464
}

src/internal/ajax/errors.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface AjaxErrorCtor {
5656
*/
5757
export const AjaxError: AjaxErrorCtor = createErrorClass(
5858
(_super) =>
59-
function AjaxError(this: any, message: string, xhr: XMLHttpRequest, request: AjaxRequest) {
59+
function AjaxErrorImpl(this: any, message: string, xhr: XMLHttpRequest, request: AjaxRequest) {
6060
this.message = message;
6161
this.name = 'AjaxError';
6262
this.xhr = xhr;
@@ -85,16 +85,6 @@ export interface AjaxTimeoutErrorCtor {
8585
new (xhr: XMLHttpRequest, request: AjaxRequest): AjaxTimeoutError;
8686
}
8787

88-
const AjaxTimeoutErrorImpl = (() => {
89-
function AjaxTimeoutErrorImpl(this: any, xhr: XMLHttpRequest, request: AjaxRequest) {
90-
AjaxError.call(this, 'ajax timeout', xhr, request);
91-
this.name = 'AjaxTimeoutError';
92-
return this;
93-
}
94-
AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype);
95-
return AjaxTimeoutErrorImpl;
96-
})();
97-
9888
/**
9989
* Thrown when an AJAX request timesout. Not to be confused with {@link TimeoutError}.
10090
*
@@ -105,4 +95,12 @@ const AjaxTimeoutErrorImpl = (() => {
10595
* @class AjaxTimeoutError
10696
* @see ajax
10797
*/
108-
export const AjaxTimeoutError: AjaxTimeoutErrorCtor = AjaxTimeoutErrorImpl as any;
98+
export const AjaxTimeoutError: AjaxTimeoutErrorCtor = (() => {
99+
function AjaxTimeoutErrorImpl(this: any, xhr: XMLHttpRequest, request: AjaxRequest) {
100+
AjaxError.call(this, 'ajax timeout', xhr, request);
101+
this.name = 'AjaxTimeoutError';
102+
return this;
103+
}
104+
AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype);
105+
return AjaxTimeoutErrorImpl;
106+
})() as any;

src/internal/observable/combineLatest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ export function combineLatest<R>(
359359

360360
// combineLatest({})
361361
export function combineLatest(sourcesObject: {}): Observable<never>;
362-
export function combineLatest<T, K extends keyof T>(sourcesObject: T): Observable<{ [K in keyof T]: ObservedValueOf<T[K]> }>;
362+
export function combineLatest<T>(sourcesObject: T): Observable<{ [K in keyof T]: ObservedValueOf<T[K]> }>;
363363

364364
/* tslint:enable:max-line-length */
365365

@@ -504,10 +504,10 @@ export function combineLatest<O extends ObservableInput<any>, R>(...args: any[])
504504
scheduler,
505505
keys
506506
? // A handler for scrubbing the array of args into a dictionary.
507-
(args: any[]) => {
507+
(values: any[]) => {
508508
const value: any = {};
509-
for (let i = 0; i < args.length; i++) {
510-
value[keys![i]] = args[i];
509+
for (let i = 0; i < values.length; i++) {
510+
value[keys![i]] = values[i];
511511
}
512512
return value;
513513
}

src/internal/observable/dom/WebSocketSubject.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
278278
}
279279
});
280280

281-
socket.onopen = (e: Event) => {
281+
socket.onopen = (evt: Event) => {
282282
const { _socket } = this;
283283
if (!_socket) {
284284
socket!.close();
@@ -287,7 +287,7 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
287287
}
288288
const { openObserver } = this._config;
289289
if (openObserver) {
290-
openObserver.next(e);
290+
openObserver.next(evt);
291291
}
292292

293293
const queue = this.destination;
@@ -303,13 +303,13 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
303303
}
304304
}
305305
},
306-
(e) => {
306+
(err) => {
307307
const { closingObserver } = this._config;
308308
if (closingObserver) {
309309
closingObserver.next(undefined);
310310
}
311-
if (e && e.code) {
312-
socket!.close(e.code, e.reason);
311+
if (err && err.code) {
312+
socket!.close(err.code, err.reason);
313313
} else {
314314
observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
315315
}

src/internal/observable/forkJoin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function forkJoin<A extends ObservableInput<any>[]>(sources: A): Observab
5757

5858
// forkJoin({})
5959
export function forkJoin(sourcesObject: {}): Observable<never>;
60-
export function forkJoin<T, K extends keyof T>(sourcesObject: T): Observable<{ [K in keyof T]: ObservedValueOf<T[K]> }>;
60+
export function forkJoin<T>(sourcesObject: T): Observable<{ [K in keyof T]: ObservedValueOf<T[K]> }>;
6161

6262
/** @deprecated resultSelector is deprecated, pipe to map instead */
6363
export function forkJoin(...args: Array<ObservableInput<any> | ((...args: any[]) => any)>): Observable<any>;
@@ -183,8 +183,8 @@ function forkJoinInternal(sources: ObservableInput<any>[], keys: string[] | null
183183
const values = new Array(len);
184184
let completed = 0;
185185
let emitted = 0;
186-
for (let i = 0; i < len; i++) {
187-
const source = innerFrom(sources[i]);
186+
for (let sourceIndex = 0; sourceIndex < len; sourceIndex++) {
187+
const source = innerFrom(sources[sourceIndex]);
188188
let hasValue = false;
189189
subscriber.add(
190190
source.subscribe({
@@ -193,7 +193,7 @@ function forkJoinInternal(sources: ObservableInput<any>[], keys: string[] | null
193193
hasValue = true;
194194
emitted++;
195195
}
196-
values[i] = value;
196+
values[sourceIndex] = value;
197197
},
198198
error: (err) => subscriber.error(err),
199199
complete: () => {

src/internal/observable/fromEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export function fromEvent<T>(
214214
}
215215

216216
if (isArrayLike(target)) {
217-
return (mergeMap((target: any) => fromEvent(target, eventName, options as any))(internalFromArray(target)) as Observable<
217+
return (mergeMap((subTarget: any) => fromEvent(subTarget, eventName, options as any))(internalFromArray(target)) as Observable<
218218
T
219219
>).subscribe(subscriber);
220220
}

src/internal/observable/zip.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ export function zip<O extends ObservableInput<any>, R>(
204204
// Loop over our sources and subscribe to each one. The index `i` is
205205
// especially important here, because we use it in closures below to
206206
// access the related buffers and completion properties
207-
for (let i = 0; !subscriber.closed && i < sources.length; i++) {
208-
innerFrom(sources[i]).subscribe(
207+
for (let sourceIndex = 0; !subscriber.closed && sourceIndex < sources.length; sourceIndex++) {
208+
innerFrom(sources[sourceIndex]).subscribe(
209209
new OperatorSubscriber(
210210
subscriber,
211211
(value) => {
212-
buffers[i].push(value);
212+
buffers[sourceIndex].push(value);
213213
// if every buffer has at least one value in it, then we
214214
// can shift out the oldest value from each buffer and emit
215215
// them as an array.
@@ -230,11 +230,11 @@ export function zip<O extends ObservableInput<any>, R>(
230230
() => {
231231
// This source completed. Mark it as complete so we can check it later
232232
// if we have to.
233-
completed[i] = true;
233+
completed[sourceIndex] = true;
234234
// But, if this complete source has nothing in its buffer, then we
235235
// can complete the result, because we can't possibly have any more
236236
// values from this to zip together with the oterh values.
237-
!buffers[i].length && subscriber.complete();
237+
!buffers[sourceIndex].length && subscriber.complete();
238238
}
239239
)
240240
);

src/internal/operators/buffer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ import { OperatorSubscriber } from './OperatorSubscriber';
4545
*/
4646
export function buffer<T>(closingNotifier: Observable<any>): OperatorFunction<T, T[]> {
4747
return operate((source, subscriber) => {
48-
let buffer: T[] = [];
48+
let currentBuffer: T[] = [];
4949

5050
// Subscribe to our source.
51-
source.subscribe(new OperatorSubscriber(subscriber, (value) => buffer.push(value)));
51+
source.subscribe(new OperatorSubscriber(subscriber, (value) => currentBuffer.push(value)));
5252

5353
// Subscribe to the closing notifier.
5454
closingNotifier.subscribe(
5555
new OperatorSubscriber(subscriber, () => {
5656
// Start a new buffer and emit the previous one.
57-
const b = buffer;
58-
buffer = [];
57+
const b = currentBuffer;
58+
currentBuffer = [];
5959
subscriber.next(b);
6060
})
6161
);
6262

6363
return () => {
6464
// Ensure buffered values are released on teardown.
65-
buffer = null!;
65+
currentBuffer = null!;
6666
};
6767
});
6868
}

src/internal/operators/count.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ import { reduce } from './reduce';
5656
*/
5757

5858
export function count<T>(predicate?: (value: T, index: number) => boolean): OperatorFunction<T, number> {
59-
return reduce((count, value, i) => (!predicate || predicate(value, i) ? count + 1 : count), 0);
59+
return reduce((total, value, i) => (!predicate || predicate(value, i) ? total + 1 : total), 0);
6060
}

0 commit comments

Comments
 (0)