Skip to content

Commit

Permalink
refactor: Remove no-shadowed-variable tslint override
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Oct 2, 2020
1 parent f51c239 commit 56f18a6
Show file tree
Hide file tree
Showing 26 changed files with 87 additions and 87 deletions.
6 changes: 3 additions & 3 deletions src/internal/Observable.ts
Expand Up @@ -435,11 +435,11 @@ export class Observable<T> implements Subscribable<T> {

/* tslint:disable:max-line-length */
/** @deprecated Deprecated use {@link firstValueFrom} or {@link lastValueFrom} instead */
toPromise<T>(this: Observable<T>): Promise<T | undefined>;
toPromise(): Promise<T | undefined>;
/** @deprecated Deprecated use {@link firstValueFrom} or {@link lastValueFrom} instead */
toPromise<T>(this: Observable<T>, PromiseCtor: typeof Promise): Promise<T | undefined>;
toPromise(PromiseCtor: typeof Promise): Promise<T | undefined>;
/** @deprecated Deprecated use {@link firstValueFrom} or {@link lastValueFrom} instead */
toPromise<T>(this: Observable<T>, PromiseCtor: PromiseConstructorLike): Promise<T | undefined>;
toPromise(PromiseCtor: PromiseConstructorLike): Promise<T | undefined>;
/* tslint:enable:max-line-length */

/**
Expand Down
4 changes: 2 additions & 2 deletions src/internal/Scheduler.ts
Expand Up @@ -26,7 +26,7 @@ export class Scheduler implements SchedulerLike {

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

constructor(private SchedulerAction: typeof Action,
constructor(private schedulerActionCtor: typeof Action,
now: () => number = Scheduler.now) {
this.now = now;
}
Expand Down Expand Up @@ -59,6 +59,6 @@ export class Scheduler implements SchedulerLike {
* the scheduled work.
*/
public schedule<T>(work: (this: SchedulerAction<T>, state?: T) => void, delay: number = 0, state?: T): Subscription {
return new this.SchedulerAction<T>(this, work).schedule(state, delay);
return new this.schedulerActionCtor<T>(this, work).schedule(state, delay);
}
}
22 changes: 10 additions & 12 deletions src/internal/ajax/errors.ts
Expand Up @@ -56,7 +56,7 @@ export interface AjaxErrorCtor {
*/
export const AjaxError: AjaxErrorCtor = createErrorClass(
(_super) =>
function AjaxError(this: any, message: string, xhr: XMLHttpRequest, request: AjaxRequest) {
function AjaxErrorImpl(this: any, message: string, xhr: XMLHttpRequest, request: AjaxRequest) {
this.message = message;
this.name = 'AjaxError';
this.xhr = xhr;
Expand Down Expand Up @@ -85,16 +85,6 @@ export interface AjaxTimeoutErrorCtor {
new (xhr: XMLHttpRequest, request: AjaxRequest): AjaxTimeoutError;
}

const AjaxTimeoutErrorImpl = (() => {
function AjaxTimeoutErrorImpl(this: any, xhr: XMLHttpRequest, request: AjaxRequest) {
AjaxError.call(this, 'ajax timeout', xhr, request);
this.name = 'AjaxTimeoutError';
return this;
}
AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype);
return AjaxTimeoutErrorImpl;
})();

/**
* Thrown when an AJAX request timesout. Not to be confused with {@link TimeoutError}.
*
Expand All @@ -105,4 +95,12 @@ const AjaxTimeoutErrorImpl = (() => {
* @class AjaxTimeoutError
* @see ajax
*/
export const AjaxTimeoutError: AjaxTimeoutErrorCtor = AjaxTimeoutErrorImpl as any;
export const AjaxTimeoutError: AjaxTimeoutErrorCtor = (() => {
function AjaxTimeoutErrorImpl(this: any, xhr: XMLHttpRequest, request: AjaxRequest) {
AjaxError.call(this, 'ajax timeout', xhr, request);
this.name = 'AjaxTimeoutError';
return this;
}
AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype);
return AjaxTimeoutErrorImpl;
})() as any;
8 changes: 4 additions & 4 deletions src/internal/observable/combineLatest.ts
Expand Up @@ -359,7 +359,7 @@ export function combineLatest<R>(

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

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

Expand Down Expand Up @@ -504,10 +504,10 @@ export function combineLatest<O extends ObservableInput<any>, R>(...args: any[])
scheduler,
keys
? // A handler for scrubbing the array of args into a dictionary.
(args: any[]) => {
(values: any[]) => {
const value: any = {};
for (let i = 0; i < args.length; i++) {
value[keys![i]] = args[i];
for (let i = 0; i < values.length; i++) {
value[keys![i]] = values[i];
}
return value;
}
Expand Down
10 changes: 5 additions & 5 deletions src/internal/observable/dom/WebSocketSubject.ts
Expand Up @@ -278,7 +278,7 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
}
});

socket.onopen = (e: Event) => {
socket.onopen = (evt: Event) => {
const { _socket } = this;
if (!_socket) {
socket!.close();
Expand All @@ -287,7 +287,7 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
}
const { openObserver } = this._config;
if (openObserver) {
openObserver.next(e);
openObserver.next(evt);
}

const queue = this.destination;
Expand All @@ -303,13 +303,13 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
}
}
},
(e) => {
(err) => {
const { closingObserver } = this._config;
if (closingObserver) {
closingObserver.next(undefined);
}
if (e && e.code) {
socket!.close(e.code, e.reason);
if (err && err.code) {
socket!.close(err.code, err.reason);
} else {
observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
}
Expand Down
8 changes: 4 additions & 4 deletions src/internal/observable/forkJoin.ts
Expand Up @@ -57,7 +57,7 @@ export function forkJoin<A extends ObservableInput<any>[]>(sources: A): Observab

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

/** @deprecated resultSelector is deprecated, pipe to map instead */
export function forkJoin(...args: Array<ObservableInput<any> | ((...args: any[]) => any)>): Observable<any>;
Expand Down Expand Up @@ -183,8 +183,8 @@ function forkJoinInternal(sources: ObservableInput<any>[], keys: string[] | null
const values = new Array(len);
let completed = 0;
let emitted = 0;
for (let i = 0; i < len; i++) {
const source = innerFrom(sources[i]);
for (let sourceIndex = 0; sourceIndex < len; sourceIndex++) {
const source = innerFrom(sources[sourceIndex]);
let hasValue = false;
subscriber.add(
source.subscribe({
Expand All @@ -193,7 +193,7 @@ function forkJoinInternal(sources: ObservableInput<any>[], keys: string[] | null
hasValue = true;
emitted++;
}
values[i] = value;
values[sourceIndex] = value;
},
error: (err) => subscriber.error(err),
complete: () => {
Expand Down
2 changes: 1 addition & 1 deletion src/internal/observable/fromEvent.ts
Expand Up @@ -214,7 +214,7 @@ export function fromEvent<T>(
}

if (isArrayLike(target)) {
return (mergeMap((target: any) => fromEvent(target, eventName, options as any))(internalFromArray(target)) as Observable<
return (mergeMap((subTarget: any) => fromEvent(subTarget, eventName, options as any))(internalFromArray(target)) as Observable<
T
>).subscribe(subscriber);
}
Expand Down
10 changes: 5 additions & 5 deletions src/internal/observable/zip.ts
Expand Up @@ -204,12 +204,12 @@ export function zip<O extends ObservableInput<any>, R>(
// Loop over our sources and subscribe to each one. The index `i` is
// especially important here, because we use it in closures below to
// access the related buffers and completion properties
for (let i = 0; !subscriber.closed && i < sources.length; i++) {
innerFrom(sources[i]).subscribe(
for (let sourceIndex = 0; !subscriber.closed && sourceIndex < sources.length; sourceIndex++) {
innerFrom(sources[sourceIndex]).subscribe(
new OperatorSubscriber(
subscriber,
(value) => {
buffers[i].push(value);
buffers[sourceIndex].push(value);
// if every buffer has at least one value in it, then we
// can shift out the oldest value from each buffer and emit
// them as an array.
Expand All @@ -230,11 +230,11 @@ export function zip<O extends ObservableInput<any>, R>(
() => {
// This source completed. Mark it as complete so we can check it later
// if we have to.
completed[i] = true;
completed[sourceIndex] = true;
// But, if this complete source has nothing in its buffer, then we
// can complete the result, because we can't possibly have any more
// values from this to zip together with the oterh values.
!buffers[i].length && subscriber.complete();
!buffers[sourceIndex].length && subscriber.complete();
}
)
);
Expand Down
10 changes: 5 additions & 5 deletions src/internal/operators/buffer.ts
Expand Up @@ -45,24 +45,24 @@ import { OperatorSubscriber } from './OperatorSubscriber';
*/
export function buffer<T>(closingNotifier: Observable<any>): OperatorFunction<T, T[]> {
return operate((source, subscriber) => {
let buffer: T[] = [];
let currentBuffer: T[] = [];

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

// Subscribe to the closing notifier.
closingNotifier.subscribe(
new OperatorSubscriber(subscriber, () => {
// Start a new buffer and emit the previous one.
const b = buffer;
buffer = [];
const b = currentBuffer;
currentBuffer = [];
subscriber.next(b);
})
);

return () => {
// Ensure buffered values are released on teardown.
buffer = null!;
currentBuffer = null!;
};
});
}
2 changes: 1 addition & 1 deletion src/internal/operators/count.ts
Expand Up @@ -56,5 +56,5 @@ import { reduce } from './reduce';
*/

export function count<T>(predicate?: (value: T, index: number) => boolean): OperatorFunction<T, number> {
return reduce((count, value, i) => (!predicate || predicate(value, i) ? count + 1 : count), 0);
return reduce((total, value, i) => (!predicate || predicate(value, i) ? total + 1 : total), 0);
}
6 changes: 3 additions & 3 deletions src/internal/operators/delay.ts
Expand Up @@ -45,14 +45,14 @@ import { timer } from '../observable/timer';
* @see {@link debounceTime}
* @see {@link delayWhen}
*
* @param {number|Date} delay The delay duration in milliseconds (a `number`) or
* @param {number|Date} due The delay duration in milliseconds (a `number`) or
* a `Date` until which the emission of the source items is delayed.
* @param {SchedulerLike} [scheduler=async] The {@link SchedulerLike} to use for
* managing the timers that handle the time-shift for each item.
* @return {Observable} An Observable that delays the emissions of the source
* Observable by the specified timeout or Date.
*/
export function delay<T>(delay: number | Date, scheduler: SchedulerLike = asyncScheduler): MonoTypeOperatorFunction<T> {
const duration = timer(delay, scheduler);
export function delay<T>(due: number | Date, scheduler: SchedulerLike = asyncScheduler): MonoTypeOperatorFunction<T> {
const duration = timer(due, scheduler);
return delayWhen(() => duration);
}
2 changes: 1 addition & 1 deletion src/internal/operators/groupBy.ts
Expand Up @@ -217,7 +217,7 @@ export function groupBy<T, K, R>(
* @param key The key of the group
* @param groupSubject The subject that fuels the group
*/
function createGroupedObservable<K, T>(key: K, groupSubject: Subject<any>) {
function createGroupedObservable(key: K, groupSubject: Subject<any>) {
const result: any = new Observable<T>((groupSubscriber) => {
groupBySourceSubscriber.activeGroups++;
const innerSub = groupSubject.subscribe(groupSubscriber);
Expand Down
6 changes: 3 additions & 3 deletions src/internal/operators/throttle.ts
Expand Up @@ -80,15 +80,15 @@ export function throttle<T>(
}
};

const throttle = (value: T) =>
const startThrottle = (value: T) =>
(throttled = innerFrom(durationSelector(value)).subscribe(
new OperatorSubscriber(subscriber, throttlingDone, undefined, throttlingDone)
));

const send = () => {
if (hasValue) {
subscriber.next(sendValue!);
!isComplete && throttle(sendValue!);
!isComplete && startThrottle(sendValue!);
}
hasValue = false;
sendValue = null;
Expand All @@ -105,7 +105,7 @@ export function throttle<T>(
(value) => {
hasValue = true;
sendValue = value;
!(throttled && !throttled.closed) && (leading ? send() : throttle(value));
!(throttled && !throttled.closed) && (leading ? send() : startThrottle(value));
},
undefined,
() => {
Expand Down
2 changes: 1 addition & 1 deletion src/internal/operators/timeout.ts
Expand Up @@ -88,7 +88,7 @@ export interface TimeoutErrorCtor {
*/
export const TimeoutError: TimeoutErrorCtor = createErrorClass(
(_super) =>
function TimeoutError(this: any, info: TimeoutInfo<any> | null = null) {
function TimeoutErrorImpl(this: any, info: TimeoutInfo<any> | null = null) {
_super(this);
this.message = 'Timeout has occurred';
this.name = 'TimeoutError';
Expand Down
6 changes: 3 additions & 3 deletions src/internal/operators/window.ts
Expand Up @@ -56,11 +56,11 @@ export function window<T>(windowBoundaries: Observable<any>): OperatorFunction<T
/**
* Subscribes to one of our two observables in this operator in the same way,
* only allowing for different behaviors with the next handler.
* @param source The observable to subscribe to.
* @param sourceOrNotifier The observable to subscribe to.
* @param next The next handler to use with the subscription
*/
const windowSubscribe = (source: Observable<any>, next: (value: any) => void) =>
source.subscribe(
const windowSubscribe = (sourceOrNotifier: Observable<any>, next: (value: any) => void) =>
sourceOrNotifier.subscribe(
new OperatorSubscriber(
subscriber,
next,
Expand Down
6 changes: 3 additions & 3 deletions src/internal/scheduler/VirtualTimeScheduler.ts
Expand Up @@ -26,12 +26,12 @@ export class VirtualTimeScheduler extends AsyncScheduler {
* This creates an instance of a `VirtualTimeScheduler`. Experts only. The signature of
* this constructor is likely to change in the long run.
*
* @param SchedulerAction The type of Action to initialize when initializing actions during scheduling.
* @param schedulerActionCtor The type of Action to initialize when initializing actions during scheduling.
* @param maxFrames The maximum number of frames to process before stopping. Used to prevent endless flush cycles.
*/
constructor(SchedulerAction: typeof AsyncAction = VirtualAction as any,
constructor(schedulerActionCtor: typeof AsyncAction = VirtualAction as any,
public maxFrames: number = Infinity) {
super(SchedulerAction, () => this.frame);
super(schedulerActionCtor, () => this.frame);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/internal/testing/ColdObservable.ts
Expand Up @@ -44,8 +44,8 @@ export class ColdObservable<T> extends Observable<T> implements SubscriptionLogg
subscriber.add(
this.scheduler.schedule(
(state) => {
const { message, subscriber } = state!;
observeNotification(message.notification, subscriber);
const { message: { notification }, subscriber: destination } = state!;
observeNotification(notification, destination);
},
message.frame,
{ message, subscriber }
Expand Down

0 comments on commit 56f18a6

Please sign in to comment.