Skip to content

Commit

Permalink
refactor: remove elementAt overload signatures (#6084)
Browse files Browse the repository at this point in the history
* refactor: remove elementAt overload sigs

* chore: update api_guardian
  • Loading branch information
cartant authored Mar 8, 2021
1 parent 40e5c10 commit 868e409
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 1 addition & 2 deletions api_guard/dist/types/operators/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export declare function distinctUntilChanged<T, K>(comparator: (previous: K, cur
export declare function distinctUntilKeyChanged<T>(key: keyof T): MonoTypeOperatorFunction<T>;
export declare function distinctUntilKeyChanged<T, K extends keyof T>(key: K, compare: (x: T[K], y: T[K]) => boolean): MonoTypeOperatorFunction<T>;

export declare function elementAt<T>(index: number): MonoTypeOperatorFunction<T>;
export declare function elementAt<T, D>(index: number, defaultValue: D): OperatorFunction<T, T | D>;
export declare function elementAt<T, D = T>(index: number, defaultValue?: D): OperatorFunction<T, T | D>;

export declare function endWith<T>(scheduler: SchedulerLike): MonoTypeOperatorFunction<T>;
export declare function endWith<T, A>(v1: A, scheduler: SchedulerLike): OperatorFunction<T, T | A>;
Expand Down
7 changes: 2 additions & 5 deletions src/internal/operators/elementAt.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError';
import { Observable } from '../Observable';
import { MonoTypeOperatorFunction, OperatorFunction } from '../types';
import { OperatorFunction } from '../types';
import { filter } from './filter';
import { throwIfEmpty } from './throwIfEmpty';
import { defaultIfEmpty } from './defaultIfEmpty';
import { take } from './take';

export function elementAt<T>(index: number): MonoTypeOperatorFunction<T>;
export function elementAt<T, D>(index: number, defaultValue: D): OperatorFunction<T, T | D>;

/**
* Emits the single value at the specified `index` in a sequence of emissions
* from the source Observable.
Expand Down Expand Up @@ -55,7 +52,7 @@ export function elementAt<T, D>(index: number, defaultValue: D): OperatorFunctio
* @return {Observable} An Observable that emits a single item, if it is found.
* Otherwise, will emit the default value if given. If not, then emits an error.
*/
export function elementAt<T, D>(index: number, defaultValue?: D): OperatorFunction<T, T | D> {
export function elementAt<T, D = T>(index: number, defaultValue?: D): OperatorFunction<T, T | D> {
if (index < 0) {
throw new ArgumentOutOfRangeError();
}
Expand Down

0 comments on commit 868e409

Please sign in to comment.