From 9b2cc39299405438a25bc5db56b0365d1efc6831 Mon Sep 17 00:00:00 2001 From: WeRDyin Date: Mon, 22 Nov 2021 19:03:16 +0800 Subject: [PATCH] fix(types): add instance member declaration (#13684) * fix(types): add instance member declaration * test(types): add static/instance members test cases Co-authored-by: Sascha Depold --- types/lib/sequelize.d.ts | 8 ++++++++ types/test/sequelize.ts | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/types/lib/sequelize.d.ts b/types/lib/sequelize.d.ts index a17d0fdb9021..4237e8b92d53 100644 --- a/types/lib/sequelize.d.ts +++ b/types/lib/sequelize.d.ts @@ -426,6 +426,7 @@ export class Sequelize extends Hooks { * @param args All further arguments will be passed as arguments to the function */ public static fn: typeof fn; + public fn: typeof fn; /** * Creates a object representing a column in the DB. This is often useful in conjunction with @@ -434,6 +435,7 @@ export class Sequelize extends Hooks { * @param col The name of the column */ public static col: typeof col; + public col: typeof col; /** * Creates a object representing a call to the cast function. @@ -442,6 +444,7 @@ export class Sequelize extends Hooks { * @param type The type to cast it to */ public static cast: typeof cast; + public cast: typeof cast; /** * Creates a object representing a literal, i.e. something that will not be escaped. @@ -449,6 +452,7 @@ export class Sequelize extends Hooks { * @param val */ public static literal: typeof literal; + public literal: typeof literal; /** * An AND query @@ -456,6 +460,7 @@ export class Sequelize extends Hooks { * @param args Each argument will be joined by AND */ public static and: typeof and; + public and: typeof and; /** * An OR query @@ -463,6 +468,7 @@ export class Sequelize extends Hooks { * @param args Each argument will be joined by OR */ public static or: typeof or; + public or: typeof or; /** * Creates an object representing nested where conditions for postgres's json data-type. @@ -473,6 +479,7 @@ export class Sequelize extends Hooks { * ''". */ public static json: typeof json; + public json: typeof json; /** * A way of specifying attr = condition. @@ -493,6 +500,7 @@ export class Sequelize extends Hooks { * etc.) */ public static where: typeof where; + public where: typeof where; /** * A hook that is run before validation diff --git a/types/test/sequelize.ts b/types/test/sequelize.ts index 150b61449e67..54931e58255d 100644 --- a/types/test/sequelize.ts +++ b/types/test/sequelize.ts @@ -1,4 +1,4 @@ -import { Config, Sequelize, Model, QueryTypes, ModelCtor } from 'sequelize'; +import { Config, Sequelize, Model, QueryTypes, ModelCtor, Op } from 'sequelize'; import { Fn } from 'sequelize/lib/utils'; Sequelize.useCLS({ @@ -20,6 +20,24 @@ export const sequelize = new Sequelize({ } }); +// static members +Sequelize.fn('max', Sequelize.col('age')) +Sequelize.literal('1-2') +Sequelize.cast('123', 'integer') +Sequelize.and() +Sequelize.or() +Sequelize.json('data.id') +Sequelize.where(Sequelize.col("ABS"), Op.is, null); + +// instance members +sequelize.fn('max', sequelize.col('age')) +sequelize.literal('1-2') +sequelize.cast('123', 'integer') +sequelize.and() +sequelize.or() +sequelize.json('data.id') +sequelize.where(sequelize.col("ABS"), Op.is, null); + const databaseName = sequelize.getDatabaseName(); const conn = sequelize.connectionManager;