Add type safety when defining model's attributes

This commit is contained in:
henrikra
2018-08-22 15:56:19 +03:00
parent 6b5ceb41aa
commit d18a809f9c
+15 -1
View File
@@ -4672,6 +4672,20 @@ declare namespace sequelize {
}
/**
* Interface for Attributes provided for a column
*
* @see Sequelize.define
*/
type DefineModelAttributes<T> = {
/**
* The description of a database column for model
*/
[P in keyof T]: string | DataTypeAbstract | DefineAttributeColumnOptions;
}
/**
* Interface for query options
*
@@ -5976,7 +5990,7 @@ declare namespace sequelize {
* @param options These options are merged with the default define options provided to the Sequelize
* constructor
*/
define<TInstance, TAttributes>(modelName: string, attributes: DefineAttributes,
define<TInstance, TAttributes>(modelName: string, attributes: DefineModelAttributes<TAttributes>,
options?: DefineOptions<TInstance>): Model<TInstance, TAttributes>;
/**