From 906fd6a455461991e28516716fe59d8f9417642f Mon Sep 17 00:00:00 2001 From: Andrew Schmadel Date: Wed, 7 Aug 2019 10:10:55 -0400 Subject: [PATCH] fix(types): return a usable type when using the sequelize.models lookup --- types/lib/sequelize.d.ts | 3 ++- types/test/sequelize.ts | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/types/lib/sequelize.d.ts b/types/lib/sequelize.d.ts index cf517bcc707e..4f5b649dd952 100644 --- a/types/lib/sequelize.d.ts +++ b/types/lib/sequelize.d.ts @@ -19,6 +19,7 @@ import { UpdateOptions, WhereAttributeHash, WhereOperators, + ModelCtor, } from './model'; import { ModelManager } from './model-manager'; import * as Op from './operators'; @@ -767,7 +768,7 @@ export class Sequelize extends Hooks { * Dictionary of all models linked with this instance. */ public readonly models: { - [key: string]: typeof Model; + [key: string]: ModelCtor; }; /** diff --git a/types/test/sequelize.ts b/types/test/sequelize.ts index a01d57925cdd..216db5b181cc 100644 --- a/types/test/sequelize.ts +++ b/types/test/sequelize.ts @@ -49,4 +49,8 @@ Sequelize.afterConnect(() => { const rnd: Fn = sequelize.random(); -const myModel: typeof Model = sequelize.models.asd; +class Model1 extends Model{} +class Model2 extends Model{} +const myModel: typeof Model1 = sequelize.models.asd; +myModel.hasOne(Model2) +myModel.findAll(); \ No newline at end of file