From aaf133cc58bdca00fa171b045ec57fa5f4e1d3b9 Mon Sep 17 00:00:00 2001 From: JulienDuf Date: Thu, 16 Mar 2017 16:20:03 -0400 Subject: [PATCH 1/3] Sequelize : Return TInstance in all CreateAsssociationMixin --- sequelize/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sequelize/index.d.ts b/sequelize/index.d.ts index e21d8f6f88..f6789e2345 100644 --- a/sequelize/index.d.ts +++ b/sequelize/index.d.ts @@ -126,7 +126,7 @@ declare namespace sequelize { * @see http://docs.sequelizejs.com/en/latest/api/associations/belongs-to/ * @see Instance */ - interface BelongsToCreateAssociationMixin { + interface BelongsToCreateAssociationMixin { /** * Create a new instance of the associated model and associate it with this. * @param values The values used to create the association. @@ -135,7 +135,7 @@ declare namespace sequelize { ( values?: TAttributes, options?: BelongsToCreateAssociationMixinOptions | CreateOptions | BelongsToSetAssociationMixinOptions - ): Promise; + ): Promise; } /** @@ -240,7 +240,7 @@ declare namespace sequelize { * @see http://docs.sequelizejs.com/en/latest/api/associations/has-one/ * @see Instance */ - interface HasOneCreateAssociationMixin { + interface HasOneCreateAssociationMixin { /** * Create a new instance of the associated model and associate it with this. * @param values The values used to create the association. @@ -249,7 +249,7 @@ declare namespace sequelize { ( values?: TAttributes, options?: HasOneCreateAssociationMixinOptions | HasOneSetAssociationMixinOptions | CreateOptions - ): Promise; + ): Promise; } /** @@ -481,7 +481,7 @@ declare namespace sequelize { * @see http://docs.sequelizejs.com/en/latest/api/associations/has-many/ * @see Instance */ - interface HasManyCreateAssociationMixin { + interface HasManyCreateAssociationMixin { /** * Create a new instance of the associated model and associate it with this. * @param values The values used to create the association. @@ -490,7 +490,7 @@ declare namespace sequelize { ( values?: TAttributes, options?: HasManyCreateAssociationMixinOptions | CreateOptions - ): Promise; + ): Promise; } /** @@ -944,7 +944,7 @@ declare namespace sequelize { * @see http://docs.sequelizejs.com/en/latest/api/associations/belongs-to-many/ * @see Instance */ - interface BelongsToManyCreateAssociationMixin { + interface BelongsToManyCreateAssociationMixin { /** * Create a new instance of the associated model and associate it with this. * @param values The values used to create the association. @@ -953,7 +953,7 @@ declare namespace sequelize { ( values?: TAttributes, options?: BelongsToManyCreateAssociationMixinOptions | CreateOptions | TJoinTableAttributes - ): Promise; + ): Promise; } /** From fa9cca9acf60f761bee005a8786535d03b009a3d Mon Sep 17 00:00:00 2001 From: JulienDuf Date: Thu, 16 Mar 2017 16:25:30 -0400 Subject: [PATCH 2/3] Sequelize : Update Tests --- sequelize/sequelize-tests.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sequelize/sequelize-tests.ts b/sequelize/sequelize-tests.ts index ceff709a6b..3c89790f13 100644 --- a/sequelize/sequelize-tests.ts +++ b/sequelize/sequelize-tests.ts @@ -210,7 +210,7 @@ barcode.setProduct(product, { save: true }).then(() => { }); barcode.createProduct(); barcode.createProduct({ id: 1, name: 'Crowbar' }); -barcode.createProduct({ id: 1 }, { save: true, silent: true }).then(() => { }); +barcode.createProduct({ id: 1 }, { save: true, silent: true }).then((product) => { }); product.getWarehouse(); product.getWarehouse({ scope: null }).then(w => w.capacity); @@ -243,7 +243,7 @@ warehouse.addProduct(2, { validate: true }).then(() => { }); warehouse.createProduct(); warehouse.createProduct({ id: 1, name: 'baz' }); -warehouse.createProduct({ id: 1 }, { silent: true }).then(() => { }); +warehouse.createProduct({ id: 1 }, { silent: true }).then((product) => { }); warehouse.removeProducts(); warehouse.removeProducts([product]); @@ -281,7 +281,7 @@ warehouse.addBranch(2, { validate: true, distance: 1 }).then(() => { }); warehouse.createBranch(); warehouse.createBranch({ id: 1, address: 'baz' }); -warehouse.createBranch({ id: 1 }, { silent: true, distance: 1 }).then(() => { }); +warehouse.createBranch({ id: 1 }, { silent: true, distance: 1 }).then((branch) => { }); warehouse.removeBranches(); warehouse.removeBranches([branch]); @@ -319,7 +319,7 @@ customer.addBranch(2, { validate: true }).then(() => { }); customer.createBranch(); customer.createBranch({ id: 1, address: 'baz' }); -customer.createBranch({ id: 1 }, { silent: true }).then(() => { }); +customer.createBranch({ id: 1 }, { silent: true }).then((branch) => { }); customer.removeBranches(); customer.removeBranches([branch]); @@ -350,12 +350,12 @@ interface ProductInstance extends Sequelize.Instance, Product // hasOne association mixins: getBarcode: Sequelize.HasOneGetAssociationMixin; setBarcode: Sequelize.HasOneSetAssociationMixin; - createBarcode: Sequelize.HasOneCreateAssociationMixin; + createBarcode: Sequelize.HasOneCreateAssociationMixin; // belongsTo association mixins: getWarehouse: Sequelize.BelongsToGetAssociationMixin; setWarehouse: Sequelize.BelongsToSetAssociationMixin; - createWarehouse: Sequelize.BelongsToCreateAssociationMixin; + createWarehouse: Sequelize.BelongsToCreateAssociationMixin; }; interface BarcodeAttributes { @@ -368,7 +368,7 @@ interface BarcodeInstance extends Sequelize.Instance, Barcode // belongsTo association mixins: getProduct: Sequelize.BelongsToGetAssociationMixin; setProduct: Sequelize.BelongsToSetAssociationMixin; - createProduct: Sequelize.BelongsToCreateAssociationMixin; + createProduct: Sequelize.BelongsToCreateAssociationMixin; }; interface WarehouseAttributes { @@ -383,7 +383,7 @@ interface WarehouseInstance extends Sequelize.Instance, War setProducts: Sequelize.HasManySetAssociationsMixin; addProducts: Sequelize.HasManyAddAssociationsMixin; addProduct: Sequelize.HasManyAddAssociationMixin; - createProduct: Sequelize.HasManyCreateAssociationMixin; + createProduct: Sequelize.HasManyCreateAssociationMixin; removeProduct: Sequelize.HasManyRemoveAssociationMixin; removeProducts: Sequelize.HasManyRemoveAssociationsMixin; hasProduct: Sequelize.HasManyHasAssociationMixin; @@ -395,7 +395,7 @@ interface WarehouseInstance extends Sequelize.Instance, War setBranches: Sequelize.BelongsToManySetAssociationsMixin; addBranches: Sequelize.BelongsToManyAddAssociationsMixin; addBranch: Sequelize.BelongsToManyAddAssociationMixin; - createBranch: Sequelize.BelongsToManyCreateAssociationMixin; + createBranch: Sequelize.BelongsToManyCreateAssociationMixin; removeBranch: Sequelize.BelongsToManyRemoveAssociationMixin; removeBranches: Sequelize.BelongsToManyRemoveAssociationsMixin; hasBranch: Sequelize.BelongsToManyHasAssociationMixin; @@ -415,7 +415,7 @@ interface BranchInstance extends Sequelize.Instance, BranchAtt setWarehouses: Sequelize.BelongsToManySetAssociationsMixin; addWarehouses: Sequelize.BelongsToManyAddAssociationsMixin; addWarehouse: Sequelize.BelongsToManyAddAssociationMixin; - createWarehouse: Sequelize.BelongsToManyCreateAssociationMixin; + createWarehouse: Sequelize.BelongsToManyCreateAssociationMixin; removeWarehouse: Sequelize.BelongsToManyRemoveAssociationMixin; removeWarehouses: Sequelize.BelongsToManyRemoveAssociationsMixin; hasWarehouse: Sequelize.BelongsToManyHasAssociationMixin; @@ -427,7 +427,7 @@ interface BranchInstance extends Sequelize.Instance, BranchAtt setCustomers: Sequelize.BelongsToManySetAssociationsMixin; addCustomers: Sequelize.BelongsToManyAddAssociationsMixin; addCustomer: Sequelize.BelongsToManyAddAssociationMixin; - createCustomer: Sequelize.BelongsToManyCreateAssociationMixin; + createCustomer: Sequelize.BelongsToManyCreateAssociationMixin; removeCustomer: Sequelize.BelongsToManyRemoveAssociationMixin; removeCustomers: Sequelize.BelongsToManyRemoveAssociationsMixin; hasCustomer: Sequelize.BelongsToManyHasAssociationMixin; @@ -453,7 +453,7 @@ interface CustomerInstance extends Sequelize.Instance, Custo setBranches: Sequelize.BelongsToManySetAssociationsMixin; addBranches: Sequelize.BelongsToManyAddAssociationsMixin; addBranch: Sequelize.BelongsToManyAddAssociationMixin; - createBranch: Sequelize.BelongsToManyCreateAssociationMixin; + createBranch: Sequelize.BelongsToManyCreateAssociationMixin; removeBranch: Sequelize.BelongsToManyRemoveAssociationMixin; removeBranches: Sequelize.BelongsToManyRemoveAssociationsMixin; hasBranch: Sequelize.BelongsToManyHasAssociationMixin; From 392de6a2c281f37c9493580c1827673cd4877266 Mon Sep 17 00:00:00 2001 From: JulienDuf Date: Thu, 16 Mar 2017 18:03:27 -0400 Subject: [PATCH 3/3] Sequelize : Fix type for belongsTo and hasMany createMixin --- sequelize/index.d.ts | 8 ++++---- sequelize/sequelize-tests.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sequelize/index.d.ts b/sequelize/index.d.ts index f6789e2345..d667c0592f 100644 --- a/sequelize/index.d.ts +++ b/sequelize/index.d.ts @@ -126,7 +126,7 @@ declare namespace sequelize { * @see http://docs.sequelizejs.com/en/latest/api/associations/belongs-to/ * @see Instance */ - interface BelongsToCreateAssociationMixin { + interface BelongsToCreateAssociationMixin { /** * Create a new instance of the associated model and associate it with this. * @param values The values used to create the association. @@ -135,7 +135,7 @@ declare namespace sequelize { ( values?: TAttributes, options?: BelongsToCreateAssociationMixinOptions | CreateOptions | BelongsToSetAssociationMixinOptions - ): Promise; + ): Promise; } /** @@ -240,7 +240,7 @@ declare namespace sequelize { * @see http://docs.sequelizejs.com/en/latest/api/associations/has-one/ * @see Instance */ - interface HasOneCreateAssociationMixin { + interface HasOneCreateAssociationMixin { /** * Create a new instance of the associated model and associate it with this. * @param values The values used to create the association. @@ -249,7 +249,7 @@ declare namespace sequelize { ( values?: TAttributes, options?: HasOneCreateAssociationMixinOptions | HasOneSetAssociationMixinOptions | CreateOptions - ): Promise; + ): Promise; } /** diff --git a/sequelize/sequelize-tests.ts b/sequelize/sequelize-tests.ts index 3c89790f13..9425bd4f84 100644 --- a/sequelize/sequelize-tests.ts +++ b/sequelize/sequelize-tests.ts @@ -350,12 +350,12 @@ interface ProductInstance extends Sequelize.Instance, Product // hasOne association mixins: getBarcode: Sequelize.HasOneGetAssociationMixin; setBarcode: Sequelize.HasOneSetAssociationMixin; - createBarcode: Sequelize.HasOneCreateAssociationMixin; + createBarcode: Sequelize.HasOneCreateAssociationMixin; // belongsTo association mixins: getWarehouse: Sequelize.BelongsToGetAssociationMixin; setWarehouse: Sequelize.BelongsToSetAssociationMixin; - createWarehouse: Sequelize.BelongsToCreateAssociationMixin; + createWarehouse: Sequelize.BelongsToCreateAssociationMixin; }; interface BarcodeAttributes { @@ -368,7 +368,7 @@ interface BarcodeInstance extends Sequelize.Instance, Barcode // belongsTo association mixins: getProduct: Sequelize.BelongsToGetAssociationMixin; setProduct: Sequelize.BelongsToSetAssociationMixin; - createProduct: Sequelize.BelongsToCreateAssociationMixin; + createProduct: Sequelize.BelongsToCreateAssociationMixin; }; interface WarehouseAttributes {