mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Remove AtLeastOneKey constraint (#43590)
Co-authored-by: Jacob Easley <jeasley@verisk.com>
This commit is contained in:
parent
8409a77939
commit
28d8d42967
@ -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: '.'});
|
||||
|
||||
27
types/chance/index.d.ts
vendored
27
types/chance/index.d.ts
vendored
@ -5,13 +5,10 @@
|
||||
// Carlos Sanchez <https://github.com/cafesanu>
|
||||
// Colby M. White <https://github.com/colbywhite>
|
||||
// Zachary Dow <https://github.com/NewDark90>
|
||||
// Jacob Easley <https://github.com/jacobez>
|
||||
// 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<T, U = { [K in keyof T]: Pick<T, K> }> = Partial<T> & 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<CharacterOptions>): string;
|
||||
character(opts?: Partial<CharacterOptions>): string;
|
||||
floating(opts?: Options): number;
|
||||
integer(opts?: AtLeastOneKey<IntegerOptions>): number;
|
||||
integer(opts?: Partial<IntegerOptions>): number;
|
||||
letter(opts?: Options): string;
|
||||
natural(opts?: Options): number;
|
||||
string(opts?: AtLeastOneKey<StringOptions>): string;
|
||||
string(opts?: Partial<StringOptions>): string;
|
||||
|
||||
// Text
|
||||
paragraph(opts?: Options): string;
|
||||
sentence(opts?: AtLeastOneKey<SentenceOptions>): string;
|
||||
sentence(opts?: Partial<SentenceOptions>): string;
|
||||
syllable(opts?: Options): string;
|
||||
word(opts?: AtLeastOneKey<WordOptions>): string;
|
||||
word(opts?: Partial<WordOptions>): 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<FirstNameOptions>): string;
|
||||
first(opts?: Partial<FirstNameOptions>): string;
|
||||
last(opts?: LastNameOptions): string;
|
||||
name(opts?: AtLeastOneKey<NameOptions>): string;
|
||||
name_prefix(opts?: AtLeastOneKey<PrefixOptions>): string;
|
||||
name(opts?: Partial<NameOptions>): string;
|
||||
name_prefix(opts?: Partial<PrefixOptions>): string;
|
||||
name_suffix(opts?: SuffixOptions): string;
|
||||
prefix(opts?: AtLeastOneKey<PrefixOptions>): string;
|
||||
prefix(opts?: Partial<PrefixOptions>): 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<EmailOptions>): string;
|
||||
email(opts?: Partial<EmailOptions>): 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<UrlOptions>): string;
|
||||
url(opts?: Partial<UrlOptions>): string;
|
||||
|
||||
// Location
|
||||
address(opts?: Options): string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user