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

Commit a39c63a4 by Andrew Schmadel Committed by Sushant

fix(types): return a usable type when using the sequelize.models lookup (#11293)

1 parent 98a40891
...@@ -19,6 +19,7 @@ import { ...@@ -19,6 +19,7 @@ import {
UpdateOptions, UpdateOptions,
WhereAttributeHash, WhereAttributeHash,
WhereOperators, WhereOperators,
ModelCtor,
} from './model'; } from './model';
import { ModelManager } from './model-manager'; import { ModelManager } from './model-manager';
import * as Op from './operators'; import * as Op from './operators';
...@@ -767,7 +768,7 @@ export class Sequelize extends Hooks { ...@@ -767,7 +768,7 @@ export class Sequelize extends Hooks {
* Dictionary of all models linked with this instance. * Dictionary of all models linked with this instance.
*/ */
public readonly models: { public readonly models: {
[key: string]: typeof Model; [key: string]: ModelCtor<Model>;
}; };
/** /**
...@@ -1109,7 +1110,7 @@ export class Sequelize extends Hooks { ...@@ -1109,7 +1110,7 @@ export class Sequelize extends Hooks {
* *
* @param modelName The name of a model defined with Sequelize.define * @param modelName The name of a model defined with Sequelize.define
*/ */
public model(modelName: string): typeof Model; public model(modelName: string): ModelCtor<Model>;
/** /**
* Checks whether a model with the given name is defined * Checks whether a model with the given name is defined
......
...@@ -49,4 +49,8 @@ Sequelize.afterConnect(() => { ...@@ -49,4 +49,8 @@ Sequelize.afterConnect(() => {
const rnd: Fn = sequelize.random(); 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
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!