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

Commit 032d9968 by Chocobozzz Committed by Sushant

fix(types): scope typing (#10803)

1 parent 39269912
Showing with 18 additions and 10 deletions
...@@ -239,36 +239,36 @@ export interface WhereOperators { ...@@ -239,36 +239,36 @@ export interface WhereOperators {
/** /**
* MySQL/PG only * MySQL/PG only
* *
* Matches regular expression, case sensitive * Matches regular expression, case sensitive
* *
* Example: `[Op.regexp]: '^[h|a|t]'` becomes `REGEXP/~ '^[h|a|t]'` * Example: `[Op.regexp]: '^[h|a|t]'` becomes `REGEXP/~ '^[h|a|t]'`
*/ */
[Op.regexp]?: string; [Op.regexp]?: string;
/** /**
* MySQL/PG only * MySQL/PG only
* *
* Does not match regular expression, case sensitive * Does not match regular expression, case sensitive
* *
* Example: `[Op.notRegexp]: '^[h|a|t]'` becomes `NOT REGEXP/!~ '^[h|a|t]'` * Example: `[Op.notRegexp]: '^[h|a|t]'` becomes `NOT REGEXP/!~ '^[h|a|t]'`
*/ */
[Op.notRegexp]?: string; [Op.notRegexp]?: string;
/** /**
* PG only * PG only
* *
* Matches regular expression, case insensitive * Matches regular expression, case insensitive
* *
* Example: `[Op.iRegexp]: '^[h|a|t]'` becomes `~* '^[h|a|t]'` * Example: `[Op.iRegexp]: '^[h|a|t]'` becomes `~* '^[h|a|t]'`
*/ */
[Op.iRegexp]?: string; [Op.iRegexp]?: string;
/** /**
* PG only * PG only
* *
* Does not match regular expression, case insensitive * Does not match regular expression, case insensitive
* *
* Example: `[Op.notIRegexp]: '^[h|a|t]'` becomes `!~* '^[h|a|t]'` * Example: `[Op.notIRegexp]: '^[h|a|t]'` becomes `!~* '^[h|a|t]'`
*/ */
[Op.notIRegexp]?: string; [Op.notIRegexp]?: string;
...@@ -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!