-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support defining the type when extending a factory with params() #75
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,10 +124,12 @@ export class Factory<T, I = any> { | |
* @param params | ||
* @returns a new factory | ||
*/ | ||
params(params: DeepPartial<T>): this { | ||
params<TOverride extends T = T>( | ||
params: DeepPartial<TOverride>, | ||
): Factory<TOverride, I> { | ||
const factory = this.clone(); | ||
factory._params = merge({}, this._params, params, mergeCustomizer); | ||
return factory; | ||
return factory as unknown as Factory<TOverride, I>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue, and I'm not sure yet how to solve it, is that even though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are absolutely right, |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern is that if
admin: true
were not supplied, then the factory happily compiles but does not actually return anAdminUser
.