Skip to content

Commit

Permalink
fix(types): scope typing (#10803)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz authored and sushantdhiman committed Apr 20, 2019
1 parent 3926991 commit 032d996
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
20 changes: 10 additions & 10 deletions types/lib/model.d.ts
Expand Up @@ -239,36 +239,36 @@ export interface WhereOperators {

/**
* MySQL/PG only
*
*
* Matches regular expression, case sensitive
*
*
* Example: `[Op.regexp]: '^[h|a|t]'` becomes `REGEXP/~ '^[h|a|t]'`
*/
[Op.regexp]?: string;

/**
* MySQL/PG only
*
*
* Does not match regular expression, case sensitive
*
*
* Example: `[Op.notRegexp]: '^[h|a|t]'` becomes `NOT REGEXP/!~ '^[h|a|t]'`
*/
[Op.notRegexp]?: string;

/**
* PG only
*
*
* Matches regular expression, case insensitive
*
*
* Example: `[Op.iRegexp]: '^[h|a|t]'` becomes `~* '^[h|a|t]'`
*/
[Op.iRegexp]?: string;

/**
* PG only
*
*
* Does not match regular expression, case insensitive
*
*
* Example: `[Op.notIRegexp]: '^[h|a|t]'` becomes `!~* '^[h|a|t]'`
*/
[Op.notIRegexp]?: string;
Expand Down Expand Up @@ -1655,7 +1655,7 @@ export abstract class Model<T = any, T2 = any> extends Hooks {
*/
public static scope<M extends { new (): Model }>(
this: M,
options?: string | string[] | ScopeOptions | WhereAttributeHash
options?: string | ScopeOptions | (string | ScopeOptions)[] | WhereAttributeHash
): M;

public static addScope(name: string, scope: FindOptions, options?: AddScopeOptions): void;
Expand Down
8 changes: 8 additions & 0 deletions types/test/models/User.ts
Expand Up @@ -55,6 +55,9 @@ User.init(
firstName: a,
},
};
},
custom2() {
return {}
}
},
sequelize,
Expand All @@ -79,3 +82,8 @@ export const Group = User.belongsTo(UserGroup, { as: 'group', foreignKey: 'group
// associations refer to their Model
const userType: ModelCtor<User> = User.associations.group.source;
const groupType: ModelCtor<UserGroup> = User.associations.group.target;

User.scope([
'custom2',
{ method: [ 'custom', 32 ] }
])

0 comments on commit 032d996

Please sign in to comment.