From 4f052feeaa2688d055eb5b6bdcd8302f703f61aa Mon Sep 17 00:00:00 2001 From: Bjorn Hougaard Date: Tue, 10 Oct 2017 15:47:53 -0400 Subject: [PATCH] @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 --- types/rosie/index.d.ts | 4 ++-- types/rosie/rosie-tests.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) 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);