Skip to content

Commit bd3ddf5

Browse files
authored
fix: wrong interface used within mixin (#13685)
1 parent d2a9420 commit bd3ddf5

3 files changed

Lines changed: 13 additions & 16 deletions

File tree

types/lib/associations/belongs-to-many.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {
99
Model,
1010
ModelCtor,
1111
ModelType,
12-
Transactionable,
13-
WhereOptions,
12+
Transactionable
1413
} from '../model';
1514
import { Association, AssociationScope, ForeignKeyOptions, ManyToManyOptions, MultiAssociationAccessors } from './base';
1615

@@ -304,7 +303,7 @@ export interface BelongsToManyCreateAssociationMixinOptions extends CreateOption
304303
* @see Instance
305304
*/
306305
export type BelongsToManyCreateAssociationMixin<TModel extends Model> = (
307-
values?: Model['_creationAttributes'],
306+
values?: TModel['_creationAttributes'],
308307
options?: BelongsToManyCreateAssociationMixinOptions
309308
) => Promise<TModel>;
310309

types/lib/associations/has-many.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
InstanceUpdateOptions,
77
Model,
88
ModelCtor,
9-
Transactionable,
9+
Transactionable
1010
} from '../model';
1111
import { Association, ManyToManyOptions, MultiAssociationAccessors } from './base';
1212

@@ -210,7 +210,7 @@ export interface HasManyCreateAssociationMixinOptions extends CreateOptions<any>
210210
* @see Instance
211211
*/
212212
export type HasManyCreateAssociationMixin<TModel extends Model> = (
213-
values?: Model['_creationAttributes'],
213+
values?: TModel['_creationAttributes'],
214214
options?: HasManyCreateAssociationMixinOptions
215215
) => Promise<TModel>;
216216

types/test/typescriptDocs/ModelInit.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
* Keep this file in sync with the code in the "Usage" section in typescript.md
33
*/
44
import {
5-
Sequelize,
6-
Model,
7-
ModelDefined,
8-
DataTypes,
9-
HasManyGetAssociationsMixin,
10-
HasManyAddAssociationMixin,
11-
HasManyHasAssociationMixin,
12-
Association,
13-
HasManyCountAssociationsMixin,
14-
HasManyCreateAssociationMixin,
15-
Optional,
5+
Association, DataTypes, HasManyAddAssociationMixin, HasManyCountAssociationsMixin,
6+
HasManyCreateAssociationMixin, HasManyGetAssociationsMixin, HasManyHasAssociationMixin, Model,
7+
ModelDefined, Optional, Sequelize
168
} from "sequelize";
179

1810
const sequelize = new Sequelize("mysql://root:asd123@localhost:3306/mydb");
@@ -59,6 +51,7 @@ interface ProjectAttributes {
5951
id: number;
6052
ownerId: number;
6153
name: string;
54+
description?: string;
6255
}
6356

6457
interface ProjectCreationAttributes extends Optional<ProjectAttributes, "id"> {}
@@ -114,6 +107,10 @@ Project.init(
114107
type: new DataTypes.STRING(128),
115108
allowNull: false,
116109
},
110+
description: {
111+
type: new DataTypes.STRING(128),
112+
allowNull: true,
113+
},
117114
},
118115
{
119116
sequelize,
@@ -204,6 +201,7 @@ async function doStuffWithUser() {
204201

205202
const project = await newUser.createProject({
206203
name: "first!",
204+
ownerId: 123,
207205
});
208206

209207
const ourUser = await User.findByPk(1, {

0 commit comments

Comments
 (0)