Skip to content

Commit b7b472e

Browse files
zorjisdepold
andauthored
fix(model.d): fix findAndCountAll.count type (#13736)
* fix(model.d): fix findAndCountAll.count type `findAndCountAll` should only return `count` as an array when the `group` option is provided. This means in that case, `options` is no longer optional because when `options` is not provided, it's never a group count. I also rearrange `findAndCountAll` order to ensure the single count overload is applied first. * refactor(model): add fix type for findAllAndCount * refactor(model): tidy up type with SetRequired Co-authored-by: Sascha Depold <[email protected]>
1 parent 7a3f63a commit b7b472e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

types/lib/model.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Sequelize, SyncOptions } from './sequelize';
99
import { LOCK, Transaction } from './transaction';
1010
import { Col, Fn, Literal, Where } from './utils';
1111
import Op = require('./operators');
12+
import { SetRequired } from '../type-helpers/set-required'
1213

1314
export interface Logging {
1415
/**
@@ -1955,12 +1956,12 @@ export abstract class Model<TModelAttributes extends {} = any, TCreationAttribut
19551956
*/
19561957
public static findAndCountAll<M extends Model>(
19571958
this: ModelStatic<M>,
1958-
options?: FindAndCountOptions<M['_attributes']> & { group: GroupOption }
1959-
): Promise<{ rows: M[]; count: number[] }>;
1959+
options?: Omit<FindAndCountOptions<M['_attributes']>, 'group'>
1960+
): Promise<{ rows: M[]; count: number }>;
19601961
public static findAndCountAll<M extends Model>(
19611962
this: ModelStatic<M>,
1962-
options?: FindAndCountOptions<M['_attributes']>
1963-
): Promise<{ rows: M[]; count: number }>;
1963+
options: SetRequired<FindAndCountOptions<M['_attributes']>, 'group'>
1964+
): Promise<{ rows: M[]; count: number[] }>;
19641965

19651966
/**
19661967
* Find the maximum value of field

0 commit comments

Comments
 (0)