Skip to content

Commit

Permalink
Merge pull request #1356 from justinwaite/jdw/types-function-autocomp…
Browse files Browse the repository at this point in the history
…lete-fix
  • Loading branch information
travi authored Jun 10, 2022
2 parents dd63e18 + d64c220 commit d5a0944
Showing 1 changed file with 22 additions and 40 deletions.
62 changes: 22 additions & 40 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,43 @@ import StringOptions = Chance.StringOptions;
import UrlOptions = Chance.UrlOptions;
import EmailOptions = Chance.EmailOptions;

declare function simpleObject(): Record<string, string>;

declare function objectWithKeys<T extends string, F, R = string>(
keys: T[],
options?: { factory?: F }
): Record<T, F extends (...args: any) => any ? ReturnType<F> : R>;

declare function fromList<T extends unknown>(list: T[]): T;
declare interface Any {
simpleObject(): Record<string, string>;

declare function subList<T extends unknown>(list: T[], options?: { size: number }): T[];
objectWithKeys<T extends string, F, R = string>(
keys: T[],
options?: { factory?: F }
): Record<T, F extends (...args: any) => any ? ReturnType<F> : R>;

declare function listOf<F extends (...args: any) => any, T = ReturnType<F>>(
factory: F,
options?: { size?: number; uniqueOn?: string } & Parameters<typeof integer>[0]
): T[];
fromList<T extends unknown>(list: T[]): T;

declare function string(options?: Partial<StringOptions>): string;
subList<T extends unknown>(list: T[], options?: { size: number }): T[];

declare function word(options?: Partial<WordOptions>): string;
listOf<F extends (...args: any) => any, T = ReturnType<F>>(
factory: F,
options?: { size?: number; uniqueOn?: string } & Parameters<typeof Any['integer']>[0]
): T[];

declare function sentence(options?: Partial<SentenceOptions>): string;
string(options?: Partial<StringOptions>): string;

declare function paragraph(options?: { sentences?: number }): string;
word(options?: Partial<WordOptions>): string;

sentence(options?: Partial<SentenceOptions>): string;

declare function integer(options?: Partial<IntegerOptions>): number;
paragraph(options?: { sentences?: number }): string;

declare function float(options?: Partial<IntegerOptions> & { fixed?: number }): number;
integer(options?: Partial<IntegerOptions>): number;

declare function boolean(options?: { likelihood?: number }): boolean;
float(options?: Partial<IntegerOptions> & { fixed?: number }): number;

declare function url(options?: Partial<UrlOptions>): string;
boolean(options?: { likelihood?: number }): boolean;

declare function email(options?: Partial<EmailOptions>): string;
url(options?: Partial<UrlOptions>): string;

declare function date(): string;
email(options?: Partial<EmailOptions>): string;

declare interface Any {
simpleObject: typeof simpleObject,
objectWithKeys: typeof objectWithKeys,
fromList: typeof fromList,
subList: typeof subList,
listOf: typeof listOf,
string: typeof string,
word: typeof word,
sentence: typeof sentence,
paragraph: typeof paragraph,
integer: typeof integer,
float: typeof float,
boolean: typeof boolean,
url: typeof url,
email: typeof email,
date: typeof date,
date(): string;
}

declare const Any: Any;

export default Any;

0 comments on commit d5a0944

Please sign in to comment.