Skip to content

Commit

Permalink
fix(esl-utils): fix types for unwrap array utility
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Apr 28, 2023
1 parent 043fe45 commit a4b432a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/modules/esl-utils/misc/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ export const wrap = <T>(arr: undefined | null | T | T[]): T[] => {

/** Unwraps and returns the first element if passed object is array-like, returns original object otherwise */
export function unwrap(value: []): undefined;
export function unwrap<T>(value: (ArrayLike<T> & {0: T}) | T): T;
export function unwrap<T>(value: (ArrayLike<T> & {0: T})): T;
export function unwrap<T>(value: ArrayLike<T>): T | undefined;
export function unwrap<T extends Node>(value: NodeListOf<T>): T | undefined;
export function unwrap<T>(value: T): T;
export function unwrap(value: any): any;
export function unwrap(value: any): any {
return isArrayLike(value) ? value[0] : value;
Expand Down

0 comments on commit a4b432a

Please sign in to comment.