diff --git a/types/rosie/index.d.ts b/types/rosie/index.d.ts index 6651a7248c..d8cb96a231 100644 --- a/types/rosie/index.d.ts +++ b/types/rosie/index.d.ts @@ -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, diff --git a/types/rosie/rosie-tests.ts b/types/rosie/rosie-tests.ts index 9ed4efa468..e44b05b255 100644 --- a/types/rosie/rosie-tests.ts +++ b/types/rosie/rosie-tests.ts @@ -44,6 +44,14 @@ interface Person { const personFactory = Factory.define('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);