mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
@types/rosie - make attrs and opts optional for build and buildList (#20462)
* @types/rosie - make attrs and opts optional for build and buildList * @types/rosie - add 2 tests for build and buildlist param optionality
This commit is contained in:
committed by
Wesley Wigham
parent
98084c0199
commit
4f052feeaa
4
types/rosie/index.d.ts
vendored
4
types/rosie/index.d.ts
vendored
@@ -210,9 +210,9 @@ declare namespace rosie {
|
||||
* @param {object=} options
|
||||
* @return {*}
|
||||
*/
|
||||
build(attributes: { [k in keyof T]?: T[k] }, options?: any): T;
|
||||
build(attributes?: { [k in keyof T]?: T[k] }, options?: any): T;
|
||||
|
||||
buildList(size: number, attributes: { [k in keyof T]?: T[k] }, options: any): T[];
|
||||
buildList(size: number, attributes?: { [k in keyof T]?: T[k] }, options?: any): T[];
|
||||
|
||||
/**
|
||||
* Extends a given factory by copying over its attributes, options,
|
||||
|
||||
@@ -44,6 +44,14 @@ interface Person {
|
||||
|
||||
const personFactory = Factory.define<Person>('Person').attr('firstName', 'John').sequence('id');
|
||||
|
||||
// Building does not require the first (attributes) and second (options) arguments
|
||||
personFactory.build();
|
||||
personFactory.buildList(3);
|
||||
|
||||
// Building with attributes does not require the second (options) argument
|
||||
personFactory.build({ firstName: "John" });
|
||||
personFactory.buildList(3, { firstName: "John" });
|
||||
|
||||
// It will automatically type up to five dependencies
|
||||
personFactory.attr('fullName', ['firstName'], firstName => firstName);
|
||||
personFactory.attr('fullName', ['firstName', 'lastName'], (firstName, lastName) => lastName);
|
||||
|
||||
Reference in New Issue
Block a user