不要怂,就是干,撸起袖子干!

Commit 8f2a0d52 by JacobLey Committed by GitHub

fix(typings): model init returns model class, not instance (#13214)

1 parent deeb5c6d
Showing with 4 additions and 4 deletions
...@@ -1622,10 +1622,10 @@ export abstract class Model<TModelAttributes extends {} = any, TCreationAttribut ...@@ -1622,10 +1622,10 @@ export abstract class Model<TModelAttributes extends {} = any, TCreationAttribut
* @param options These options are merged with the default define options provided to the Sequelize constructor * @param options These options are merged with the default define options provided to the Sequelize constructor
* @return Return the initialized model * @return Return the initialized model
*/ */
public static init<M extends Model>( public static init<MS extends ModelStatic<Model>, M extends InstanceType<MS>>(
this: ModelStatic<M>, this: MS,
attributes: ModelAttributes<M, M['_attributes']>, options: InitOptions<M> attributes: ModelAttributes<M, M['_attributes']>, options: InitOptions<M>
): Model; ): MS;
/** /**
* Remove attribute from model definition * Remove attribute from model definition
......
...@@ -52,7 +52,7 @@ MyModel.update({}, { where: { foo: 'bar' }, paranoid: false}); ...@@ -52,7 +52,7 @@ MyModel.update({}, { where: { foo: 'bar' }, paranoid: false});
const sequelize = new Sequelize('mysql://user:user@localhost:3306/mydb'); const sequelize = new Sequelize('mysql://user:user@localhost:3306/mydb');
MyModel.init({ const model: typeof MyModel = MyModel.init({
virtual: { virtual: {
type: new DataTypes.VIRTUAL(DataTypes.BOOLEAN, ['num']), type: new DataTypes.VIRTUAL(DataTypes.BOOLEAN, ['num']),
get() { get() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!