fix: Types on overridden findByPk methods (#5908)

This commit is contained in:
Tom Moor
2023-10-01 15:02:56 -04:00
committed by GitHub
parent e2a6d828a9
commit 41a6f77998
6 changed files with 59 additions and 16 deletions

View File

@@ -1,9 +1,16 @@
/* eslint-disable lines-between-class-members */
import find from "lodash/find";
import findIndex from "lodash/findIndex";
import remove from "lodash/remove";
import uniq from "lodash/uniq";
import randomstring from "randomstring";
import { Identifier, Transaction, Op, FindOptions } from "sequelize";
import {
Identifier,
Transaction,
Op,
FindOptions,
NonNullFindOptions,
} from "sequelize";
import {
Sequelize,
Table,
@@ -362,8 +369,17 @@ class Collection extends ParanoidModel {
* Overrides the standard findByPk behavior to allow also querying by urlId
*
* @param id uuid or urlId
* @returns collection instance
* @param options FindOptions
* @returns A promise resolving to a collection instance or null
*/
static async findByPk(
id: Identifier,
options?: NonNullFindOptions<Collection>
): Promise<Collection>;
static async findByPk(
id: Identifier,
options?: FindOptions<Collection>
): Promise<Collection | null>;
static async findByPk(
id: Identifier,
options: FindOptions<Collection> = {}