Repository: sequelize/sequelize
File: packages/core/src/model.d.ts (TypeScript)

Code before:
   * User.findAndCountAll({
   *   include: [
   *      { model: Profile, required: true}
   *   ],
   *   limit: 3
   * });
   * ```
   * Because the include for `Profile` has `required` set it will result in an inner join, and only the users
   * who have a profile will be counted. If we remove `required` from the include, both users with and
   * without profiles will be counted
   *
   * This function also support grouping, when `group` is provided, the count will be an array of objects
   * containing the count for each group and the projected attributes.
   * ```js
   * User.findAndCountAll({
   *   group: 'type'
   * });
   * ```
   */
  static findAndCountAll<M extends Model>(
    this: ModelStatic<M>,
    options?: Omit<FindAndCountOptions<Attributes<M>>, 'group' | 'countGroupedRows'>,
  ): Promise<{ rows: M[]; count: number }>;
  static findAndCountAll<M extends Model>(
    this: ModelStatic<M>,
    options: SetRequired<FindAndCountOptions<Attributes<M>>, 'group' | 'countGroupedRows'>,
  ): Promise<{ rows: M[]; count: GroupedCountResultItem[] }>;

  /**
   * Finds the maximum value of field
   */
  static max<T extends DataType | unknown, M extends Model>(
    this: ModelStatic<M>,
    field: keyof Attributes<M>,
    options?: AggregateOptions<T, Attributes<M>>,
  ): Promise<T | null>;

  /**
   * Finds the minimum value of field
   */
  static min<T extends DataType | unknown, M extends Model>(
    this: ModelStatic<M>,
    field: keyof Attributes<M>,
    options?: AggregateOptions<T, Attributes<M>>,
  ): Promise<T | null>;

  /**
   * Retrieves the sum of field
   */
  static sum<T extends DataType | unknown, M extends Model>(
    this: ModelStatic<M>,

Review comment (suggestion):
```suggestion
    options: SetRequired<FindAndCountOptions<Attributes<M>>, 'group'>,
```

Code after:
   * User.findAndCountAll({
   *   include: [
   *      { model: Profile, required: true}
   *   ],
   *   limit: 3
   * });
   * ```
   * Because the include for `Profile` has `required` set it will result in an inner join, and only the users
   * who have a profile will be counted. If we remove `required` from the include, both users with and
   * without profiles will be counted
   *
   * This function also support grouping, when `group` is provided, the count will be an array of objects
   * containing the count for each group and the projected attributes.
   * ```js
   * User.findAndCountAll({
   *   group: 'type'
   * });
   * ```
   */
  static findAndCountAll<M extends Model>(
    this: ModelStatic<M>,
    options?: Omit<FindAndCountOptions<Attributes<M>>, 'group' | 'countGroupedRows'>,
  ): Promise<{ rows: M[]; count: number }>;
  static findAndCountAll<M extends Model>(
    this: ModelStatic<M>,
    options: SetRequired<FindAndCountOptions<Attributes<M>>, 'group'>,
  ): Promise<{ rows: M[]; count: GroupedCountResultItem[] }>;

  /**
   * Finds the maximum value of field
   */
  static max<T extends DataType | unknown, M extends Model>(
    this: ModelStatic<M>,
    field: keyof Attributes<M>,
    options?: AggregateOptions<T, Attributes<M>>,
  ): Promise<T | null>;

  /**
   * Finds the minimum value of field
   */
  static min<T extends DataType | unknown, M extends Model>(
    this: ModelStatic<M>,
    field: keyof Attributes<M>,
    options?: AggregateOptions<T, Attributes<M>>,
  ): Promise<T | null>;

  /**
   * Retrieves the sum of field
   */
  static sum<T extends DataType | unknown, M extends Model>(
    this: ModelStatic<M>,