优化Array的类型提示

This commit is contained in:
kuangshen04 2024-04-15 01:06:58 +08:00
parent c66c85836d
commit 9f829a0194
1 changed files with 40 additions and 42 deletions

View File

@ -4,72 +4,64 @@ declare interface Array<T> {
* @deprecated 使includes * @deprecated 使includes
*/ */
contains(item: T): boolean; contains(item: T): boolean;
containsSome(...item: T): boolean; containsSome(...item: T[]): boolean;
containsAll(...item: T): boolean; containsAll(...item: T[]): boolean;
/** /**
* *
* @param args * @param args
* @returns * @returns
* 1.
* 2. ()false
*/ */
add(...args: T[]): this | false; add(...item: T[]): this;
/** /**
* (this.add)arr中若有一个数组元素可能会出现bug * (this.add)arr中若有一个数组元素可能会出现bug
* @param arr * @param arr
*/ */
addArray(arr: T[]): this; addArray(...arr: T[][]): this;
/** /**
* () * ()
* @param item * @param item
* @returns * @returns
* 1.
* 2. ()false
* 3. undefined
*/ */
remove(item: T): this | false; remove(...item: T[]): this;
remove(item: T[]): void;
/** /**
* (this.remove)arr中若有一个数组元素可能会出现bug * (this.remove)arr中若有一个数组元素可能会出现bug
* @param arr * @param arr
*/ */
removeArray(...arr: T[]): this; removeArray(...arr: T[][]): this;
/** /**
* *
* @param args * @param excludes
*/ */
randomGet(...args: T[]): T; randomGet(...excludes: T[]): T;
/** /**
* / *
* @param num num为数字的情况下num个元素 * @param num 0
*/
randomGets(num?: number): T[];
/**
* undefined
*/
randomRemove(): T | undefined;
/**
*
* @param num
* @returns * @returns
* 1.
* 2.
* 3. undefined
*/ */
randomRemove(num?: number): T | T[]; randomRemove(num: number): T[];
randomRemove(num?: T): T | undefined;
/** /**
* *
*/ */
randomSort(): this; randomSort(): this;
/** /**
* *
* *
* * *使lib.sort.seat方法
* @param num , 0
*/
randomGets(num?: number): this;
/**
*
* *
* 使lib.sort.seat方法 * @param target
* @param target
*/ */
sortBySeat(target?: Player): Player[]; sortBySeat(target?: Player): this;
/** /**
* Array中所有位于处理区的卡牌过滤出来 * Array中所有位于处理区的卡牌过滤出来
* *
* list为[c1,c2,c3,c4]c1和c3是位于处理区的卡牌 * list为[c1,c2,c3,c4]c1和c3是位于处理区的卡牌
* list.filterInD()[c1,c3] * list.filterInD()[c1,c3]
@ -77,11 +69,11 @@ declare interface Array<T> {
* 1.9.97.8.1: * 1.9.97.8.1:
* *
* list.filterInD('h') * list.filterInD('h')
* @param poiston 'o' * @param position 'o'
*/ */
filterInD(poiston?: "e" | "j" | "x" | "s" | "h" | "c" | "d" | "o"): Card[]; filterInD(position?: "e" | "j" | "x" | "s" | "h" | "c" | "d" | "o"): this;
someInD(poiston?: "e" | "j" | "x" | "s" | "h" | "c" | "d" | "o"): boolean; someInD(position?: "e" | "j" | "x" | "s" | "h" | "c" | "d" | "o"): boolean;
everyInD(poiston?: "e" | "j" | "x" | "s" | "h" | "c" | "d" | "o"): boolean; everyInD(position?: "e" | "j" | "x" | "s" | "h" | "c" | "d" | "o"): boolean;
//关于处理区: //关于处理区:
/* /*
@ -105,7 +97,13 @@ declare interface Array<T> {
* item * item
*/ */
numOf(item: T): number; numOf(item: T): number;
/**
*
*/
unique(): this; unique(): this;
/**
*
*/
toUniqued(): T[]; toUniqued(): T[];
maxBy(sortBy?: Function, filter?: typeof Array['prototype']['filter']): T; maxBy(sortBy?: Function, filter?: typeof Array['prototype']['filter']): T;
minBy(sortBy?: Function, filter?: typeof Array['prototype']['filter']): T; minBy(sortBy?: Function, filter?: typeof Array['prototype']['filter']): T;