return list of type for Factory.buildList (#46623)

This commit is contained in:
Tristan Siegel 2020-09-08 07:42:13 -04:00 committed by GitHub
parent 8340511f34
commit 4c0f56b8da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -39,7 +39,7 @@ declare namespace rosie {
* @param {object=} options
* @return {Array.<*>}
*/
buildList(name: string, size: number, attributes?: any, options?: any): any[];
buildList<T>(name: string, size: number, attributes?: { [k in keyof T]?: T[k] | boolean }, options?: any): T[];
/**
* Locates a factory by name and calls #attributes on it.

View File

@ -44,6 +44,8 @@ interface Person {
}
const personFactory = Factory.define<Person>('Person').attr('firstName', 'John').sequence('id');
// building a list with a type definition returns that type
Factory.buildList<Person>('Person', 420, { age: 69 })
// Building does not require the first (attributes) and second (options) arguments
personFactory.build();