diff --git a/types/chance/chance-tests.ts b/types/chance/chance-tests.ts index 1ad506ab80..86b220382d 100644 --- a/types/chance/chance-tests.ts +++ b/types/chance/chance-tests.ts @@ -110,6 +110,7 @@ const languages: string[] = chance.locales(); const regions: string[] = chance.locales({region: true}); let word: string = chance.word(); +word = chance.word({}); word = chance.word({syllables: 10, capitalize: true}); word = chance.word({length: 10, capitalize: true}); word = chance.word({syllables: 10}); @@ -117,6 +118,7 @@ word = chance.word({length: 10}); word = chance.word({capitalize: true}); let randomString: string = chance.string(); +randomString = chance.string({}); randomString = chance.string({ pool: 'abcdef' }); randomString = chance.string({ length: 10 }); randomString = chance.string({ casing: 'upper' }); @@ -133,6 +135,7 @@ randomString = chance.string({ }); let char: string = chance.character(); +char = chance.character({}); char = chance.character({ pool: 'abcdef' }); char = chance.character({ casing: 'upper' }); char = chance.character({ alpha: true }); @@ -141,6 +144,7 @@ char = chance.character({ symbols: true }); char = chance.character({ pool: 'abcdef', casing: 'lower', alpha: true, numeric: true, symbols: true }); let url: string = chance.url(); +url = chance.url({}); url = chance.url({protocol: 'http'}); url = chance.url({domain: 'www.socialradar.com'}); url = chance.url({domain_prefix: 'dev'}); @@ -149,11 +153,13 @@ url = chance.url({extensions: ['gif', 'jpg', 'png']}); url = chance.url({protocol: 'http', domain: 'www.socialradar.com', domain_prefix: 'dev', path: 'images', extensions: ['gif', 'jpg', 'png']}); let integer: number = chance.integer(); +integer = chance.integer({}); integer = chance.integer({min: 1}); integer = chance.integer({max: 10}); integer = chance.integer({min: 1, max: 10}); let first: string = chance.first(); +first = chance.first({}); first = chance.first({gender: 'male'}); first = chance.first({nationality: 'en'}); first = chance.first({gender: 'male', nationality: 'en'}); @@ -164,6 +170,7 @@ last = chance.last({nationality: 'jp'}); last = chance.last({nationality: '*'}); let prefix: string = chance.prefix(); +prefix = chance.prefix({}); prefix = chance.prefix({gender: 'male'}); prefix = chance.prefix({gender: 'female'}); prefix = chance.prefix({gender: 'all'}); @@ -174,6 +181,7 @@ let suffix: string = chance.suffix(); suffix = chance.suffix({full: true}); let name: string = chance.name(); +name = chance.name({}); name = chance.name({middle: true}); name = chance.name({middle_initial: true}); name = chance.name({prefix: true}); @@ -184,11 +192,13 @@ name = chance.name({full: true}); name = chance.name({middle: true, middle_initial: true, prefix: true, suffix: true, nationality: 'en', gender: 'male', full: true}); let email: string = chance.email(); +email = chance.email({}); email = chance.email({domain: 'chance.com'}); email = chance.email({length: 10}); email = chance.email({domain: 'chance.com', length: 10}); let sentence: string = chance.sentence(); +sentence = chance.sentence({}); sentence = chance.sentence({words: 10}); sentence = chance.sentence({punctuation: false}); sentence = chance.sentence({punctuation: '.'}); diff --git a/types/chance/index.d.ts b/types/chance/index.d.ts index 479633e922..93e450fc86 100644 --- a/types/chance/index.d.ts +++ b/types/chance/index.d.ts @@ -5,13 +5,10 @@ // Carlos Sanchez // Colby M. White // Zachary Dow +// Jacob Easley // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -// a bit of cleverness from jcalz at https://stackoverflow.com/a/48244432 -// this will ensure that empty objects are not allowed for objects with optional parameters -type AtLeastOneKey }> = Partial & U[keyof U]; - declare namespace Chance { type Seed = number | string; @@ -32,18 +29,18 @@ declare namespace Chance { interface Chance extends Seeded { // Basics bool(opts?: {likelihood: number}): boolean; - character(opts?: AtLeastOneKey): string; + character(opts?: Partial): string; floating(opts?: Options): number; - integer(opts?: AtLeastOneKey): number; + integer(opts?: Partial): number; letter(opts?: Options): string; natural(opts?: Options): number; - string(opts?: AtLeastOneKey): string; + string(opts?: Partial): string; // Text paragraph(opts?: Options): string; - sentence(opts?: AtLeastOneKey): string; + sentence(opts?: Partial): string; syllable(opts?: Options): string; - word(opts?: AtLeastOneKey): string; + word(opts?: Partial): string; // Person age(opts?: Options): number; @@ -52,12 +49,12 @@ declare namespace Chance { birthday(opts?: Options): Date | string; cf(opts?: Options): string; cpf(opts?: { formatted: boolean }): string; - first(opts?: AtLeastOneKey): string; + first(opts?: Partial): string; last(opts?: LastNameOptions): string; - name(opts?: AtLeastOneKey): string; - name_prefix(opts?: AtLeastOneKey): string; + name(opts?: Partial): string; + name_prefix(opts?: Partial): string; name_suffix(opts?: SuffixOptions): string; - prefix(opts?: AtLeastOneKey): string; + prefix(opts?: Partial): string; ssn(opts?: Options): string; suffix(opts?: SuffixOptions): string; @@ -76,7 +73,7 @@ declare namespace Chance { color(opts?: Options): string; company(): string; domain(opts?: Options): string; - email(opts?: AtLeastOneKey): string; + email(opts?: Partial): string; fbid(): string; google_analytics(): string; hashtag(): string; @@ -86,7 +83,7 @@ declare namespace Chance { profession(opts?: Options): string; tld(): string; twitter(): string; - url(opts?: AtLeastOneKey): string; + url(opts?: Partial): string; // Location address(opts?: Options): string;