Repository: sequelize/sequelize
File: packages/core/test/types/model.ts (TypeScript)

Code before:

MyModel.findOne({
  include: [{ model: OtherModel, paranoid: true }],
});

MyModel.hasOne(OtherModel, { as: 'OtherModelAlias' });

MyModel.findOne({ include: ['OtherModelAlias'] });

MyModel.findOne({ include: OtherModel });

MyModel.findAndCountAll({ include: OtherModel }).then(({ count, rows }) => {
  expectTypeOf(count).toEqualTypeOf<number>();
  expectTypeOf(rows).toEqualTypeOf<MyModel[]>();
});

MyModel.findAndCountAll({
  include: OtherModel,
  group: ['MyModel.int'],
  countGroupedRows: true,
}).then(({ count, rows }) => {
  expectTypeOf(count).toEqualTypeOf<Array<{ [key: string]: unknown; count: number }>>();
  expectTypeOf(rows).toEqualTypeOf<MyModel[]>();
});

MyModel.count({ include: OtherModel }).then(count => {
  expectTypeOf(count).toEqualTypeOf<number>();
});

MyModel.count({ include: [MyModel], where: { $int$: [10, 120] } }).then(count => {
  expectTypeOf(count).toEqualTypeOf<number>();
});

MyModel.count({ group: 'type' }).then(result => {
  expectTypeOf(result).toEqualTypeOf<Array<{ [key: string]: unknown; count: number }>>();
  expectTypeOf(result[0]).toMatchTypeOf<{ count: number }>();
});

MyModel.increment('int', { by: 1 }).then(result => {
  expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>();
});

MyModel.increment({ int: 2 }, {}).then(result => {
  expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>();
});

MyModel.increment(['int'], { by: 3 }).then(result => {
  expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>();
});

MyModel.decrement('int', { by: 1 }).then(result => {

Review comment (suggestion):
```suggestion
MyModel.findAndCountAll({ include: OtherModel, group: ['MyModel.int'] }).then(({ count, rows }) => {
  expectTypeOf(count).toEqualTypeOf<Array<{ [key: string]: unknown; count: number }>>();
  expectTypeOf(rows).toEqualTypeOf<MyModel[]>();
});

MyModel.findAndCountAll({
  include: OtherModel,
  group: ['MyModel.int'],
  countGroupedRows: true,
}).then(({ count, rows }) => {
```

Code after:

MyModel.findOne({
  include: [{ model: OtherModel, paranoid: true }],
});

MyModel.hasOne(OtherModel, { as: 'OtherModelAlias' });

MyModel.findOne({ include: ['OtherModelAlias'] });

MyModel.findOne({ include: OtherModel });

MyModel.findAndCountAll({ include: OtherModel }).then(({ count, rows }) => {
  expectTypeOf(count).toEqualTypeOf<number>();
  expectTypeOf(rows).toEqualTypeOf<MyModel[]>();
});

MyModel.findAndCountAll({ include: OtherModel, group: ['MyModel.int'] }).then(({ count, rows }) => {
  expectTypeOf(count).toEqualTypeOf<Array<{ [key: string]: unknown; count: number }>>();
  expectTypeOf(rows).toEqualTypeOf<MyModel[]>();
});

MyModel.findAndCountAll({
  include: OtherModel,
  group: ['MyModel.int'],
  countGroupedRows: true,
}).then(({ count, rows }) => {
  expectTypeOf(count).toEqualTypeOf<Array<{ [key: string]: unknown; count: number }>>();
  expectTypeOf(rows).toEqualTypeOf<MyModel[]>();
});

MyModel.count({ include: OtherModel }).then(count => {
  expectTypeOf(count).toEqualTypeOf<number>();
});

MyModel.count({ include: [MyModel], where: { $int$: [10, 120] } }).then(count => {
  expectTypeOf(count).toEqualTypeOf<number>();
});

MyModel.count({ group: 'type' }).then(result => {
  expectTypeOf(result).toEqualTypeOf<Array<{ [key: string]: unknown; count: number }>>();
  expectTypeOf(result[0]).toMatchTypeOf<{ count: number }>();
});

MyModel.increment('int', { by: 1 }).then(result => {
  expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>();
});

MyModel.increment({ int: 2 }, {}).then(result => {
  expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>();
});