From a44d4a24d38836cbae0385371c6645f1f15c5079 Mon Sep 17 00:00:00 2001 From: Naz Date: Mon, 31 Jul 2023 13:07:20 +0800 Subject: [PATCH] Fixed "any" types for Knex transaction objects no issue - We should use specific types wherever possible instead of "any" as it's an antipattern that spreads like cancer through the codebase. --- ghost/collections/src/CollectionRepository.ts | 9 +++++---- ghost/collections/src/CollectionsService.ts | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ghost/collections/src/CollectionRepository.ts b/ghost/collections/src/CollectionRepository.ts index 1dd88b5933..9976a70633 100644 --- a/ghost/collections/src/CollectionRepository.ts +++ b/ghost/collections/src/CollectionRepository.ts @@ -1,10 +1,11 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import {Collection} from './Collection'; +import {Knex} from "knex"; export interface CollectionRepository { - createTransaction(fn: (transaction: any) => Promise): Promise - save(collection: Collection, options?: {transaction: any}): Promise - getById(id: string, options?: {transaction: any}): Promise - getBySlug(slug: string, options?: {transaction: any}): Promise + createTransaction(fn: (transaction: Knex.Transaction) => Promise): Promise + save(collection: Collection, options?: {transaction: Knex.Transaction}): Promise + getById(id: string, options?: {transaction: Knex.Transaction}): Promise + getBySlug(slug: string, options?: {transaction: Knex.Transaction}): Promise getAll(options?: any): Promise } diff --git a/ghost/collections/src/CollectionsService.ts b/ghost/collections/src/CollectionsService.ts index a8dcbbbd7b..c5ebbce3a4 100644 --- a/ghost/collections/src/CollectionsService.ts +++ b/ghost/collections/src/CollectionsService.ts @@ -23,8 +23,7 @@ const messages = { }; interface SlugService { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - generate(desired: string, options: {transaction: any}): Promise; + generate(desired: string, options: {transaction: Knex.Transaction}): Promise; } type CollectionsServiceDeps = { @@ -95,12 +94,12 @@ type QueryOptions = { include?: string; page?: number; limit?: number; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - transaction?: any; + transaction?: Knex.Transaction; } interface PostsRepository { getAll(options: QueryOptions): Promise; + getBulk(ids: string[], transaction?: Knex.Transaction): Promise; } export class CollectionsService {