mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
refactor to use overloads on type WithPaginationModel
This commit is contained in:
18
types/sequelize-cursor-pagination/index.d.ts
vendored
18
types/sequelize-cursor-pagination/index.d.ts
vendored
@@ -38,20 +38,12 @@ declare namespace SequelizeCursorPagination {
|
||||
primaryKeyField?: string; // [default: 'id']
|
||||
}
|
||||
|
||||
type WithPaginationModel<MethodName extends string, Model, ModelInst, ModelAttrs> = Model & (
|
||||
{
|
||||
[key in MethodName]: (options?: PaginateRawOptions<ModelAttrs>) => {
|
||||
results: ModelAttrs[]
|
||||
cursors: Cursors
|
||||
}
|
||||
} &
|
||||
{
|
||||
[key in MethodName]: (options?: PaginateInstOptions<ModelAttrs>) => {
|
||||
results: ModelInst[]
|
||||
cursors: Cursors
|
||||
}
|
||||
type WithPaginationModel<MethodName extends string, Model, ModelInst, ModelAttrs> = Model & {
|
||||
[key in MethodName]: {
|
||||
(options?: PaginateRawOptions<ModelAttrs>): { results: ModelAttrs[], cursors: Cursors }
|
||||
(options?: PaginateInstOptions<ModelAttrs>): { results: ModelInst[], cursors: Cursors }
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
function withPagination<MethodName extends string = 'paginate'>(options?: WithPaginationOptions<MethodName>): (
|
||||
<Model extends Sequelize.Model<ModelInst, ModelAttrs>, ModelInst, ModelAttrs>(model: Model) => WithPaginationModel<MethodName, Model, ModelInst, ModelAttrs>
|
||||
|
||||
Reference in New Issue
Block a user