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

Commit 032d9968 by Chocobozzz Committed by Sushant

fix(types): scope typing (#10803)

1 parent 39269912
...@@ -1655,7 +1655,7 @@ export abstract class Model<T = any, T2 = any> extends Hooks { ...@@ -1655,7 +1655,7 @@ export abstract class Model<T = any, T2 = any> extends Hooks {
*/ */
public static scope<M extends { new (): Model }>( public static scope<M extends { new (): Model }>(
this: M, this: M,
options?: string | string[] | ScopeOptions | WhereAttributeHash options?: string | ScopeOptions | (string | ScopeOptions)[] | WhereAttributeHash
): M; ): M;
public static addScope(name: string, scope: FindOptions, options?: AddScopeOptions): void; public static addScope(name: string, scope: FindOptions, options?: AddScopeOptions): void;
......
...@@ -55,6 +55,9 @@ User.init( ...@@ -55,6 +55,9 @@ User.init(
firstName: a, firstName: a,
}, },
}; };
},
custom2() {
return {}
} }
}, },
sequelize, sequelize,
...@@ -79,3 +82,8 @@ export const Group = User.belongsTo(UserGroup, { as: 'group', foreignKey: 'group ...@@ -79,3 +82,8 @@ export const Group = User.belongsTo(UserGroup, { as: 'group', foreignKey: 'group
// associations refer to their Model // associations refer to their Model
const userType: ModelCtor<User> = User.associations.group.source; const userType: ModelCtor<User> = User.associations.group.source;
const groupType: ModelCtor<UserGroup> = User.associations.group.target; const groupType: ModelCtor<UserGroup> = User.associations.group.target;
User.scope([
'custom2',
{ method: [ 'custom', 32 ] }
])
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!