override model function and call base implementation #16185
Unanswered
michaelxh
asked this question in
Help & Questions
Replies: 2 comments 1 reply
-
Specify the generic when you call the parent method: public static override async findOne<M extends Model>(
this: ModelStatic<M>,
options: NonNullFindOptions<Attributes<M>>
): Promise<M> {
return super.findOne<M>(options);
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
I ended up using
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm having difficult overriding model functions and calling the base implementation.
Here is an example using sequelize-typescript
Here are the typecheck errors I get ...
Given the current usage of ModelStatic on the typings of Model methods, I'm not sure there is a way to override model functions as
super
will never have a constructor defined that returns the inheriting classM
.Have others found a way to override sequelize static methods? This is especially useful for methods that do not have hooks, such as aggregate.
Beta Was this translation helpful? Give feedback.
All reactions