Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/compat/array/forEach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* forEach([1, 2], value => console.log(value));
* // => Logs `1` then `2`.
*/
export function forEach<T>(collection: T[], iteratee?: ArrayIterator<T, any>): T[];

Check warning on line 21 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* Iterates over characters of string and invokes iteratee for each character.
Expand All @@ -31,7 +31,7 @@
* forEach('abc', char => console.log(char));
* // => Logs 'a', 'b', then 'c'.
*/
export function forEach(collection: string, iteratee?: StringIterator<any>): string;

Check warning on line 34 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* Iterates over elements of collection and invokes iteratee for each element.
Expand All @@ -45,7 +45,7 @@
* forEach({ 0: 'a', 1: 'b', length: 2 }, value => console.log(value));
* // => Logs 'a' then 'b'.
*/
export function forEach<T>(collection: ArrayLike<T>, iteratee?: ListIterator<T, any>): ArrayLike<T>;

Check warning on line 48 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property.
Expand All @@ -59,7 +59,7 @@
* forEach({ a: 1, b: 2 }, (value, key) => console.log(key));
* // => Logs 'a' then 'b'.
*/
export function forEach<T extends object>(collection: T, iteratee?: ObjectIterator<T, any>): T;

Check warning on line 62 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* Iterates over elements of array and invokes iteratee for each element.
Expand All @@ -75,7 +75,7 @@
*/
export function forEach<T, U extends T[] | null | undefined>(
collection: U & (T[] | null | undefined),
iteratee?: ArrayIterator<T, any>

Check warning on line 78 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
): U;

/**
Expand All @@ -90,7 +90,7 @@
* forEach('abc', char => console.log(char));
* // => Logs 'a', 'b', then 'c'.
*/
export function forEach<T extends string | null | undefined>(collection: T, iteratee?: StringIterator<any>): T;

Check warning on line 93 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* Iterates over elements of collection and invokes iteratee for each element.
Expand All @@ -106,7 +106,7 @@
*/
export function forEach<T, L extends ArrayLike<T> | null | undefined>(
collection: L & (ArrayLike<T> | null | undefined),
iteratee?: ListIterator<T, any>

Check warning on line 109 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
): L;

/**
Expand All @@ -123,7 +123,7 @@
*/
export function forEach<T extends object>(
collection: T | null | undefined,
iteratee?: ObjectIterator<T, any>

Check warning on line 126 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
): T | null | undefined;

/**
Expand All @@ -145,15 +145,14 @@
* // 2 'b'
*/
export function forEach<T>(
collection: ArrayLike<T> | Record<any, any> | string | null | undefined,

Check warning on line 148 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 148 in src/compat/array/forEach.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
callback: (item: any, index: any, arr: any) => unknown = identity
): ArrayLike<T> | Record<any, any> | string | null | undefined {
if (!collection) {
return collection;
}

const keys: PropertyKey[] =
isArrayLike(collection) || Array.isArray(collection) ? range(0, collection.length) : Object.keys(collection);
const keys: PropertyKey[] = isArrayLike(collection) ? range(0, collection.length) : Object.keys(collection);

for (let i = 0; i < keys.length; i++) {
const key = keys[i];
Expand Down