From 2b9143fb9d52900ae2c714359bcd34f57b825b56 Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 16 Jul 2023 00:11:29 +0200 Subject: [PATCH] fix: RedisService typing --- src/types/extended.ts | 4 ++-- src/types/main.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/types/extended.ts b/src/types/extended.ts index 82cdfeb..d43b747 100644 --- a/src/types/extended.ts +++ b/src/types/extended.ts @@ -10,13 +10,13 @@ import type { RedisClusterConnectionContract, RedisConnectionContract, - RedisManagerContract, + RedisService, } from './main.js' import { Redis } from 'ioredis' declare module '@adonisjs/core/types' { export interface ContainerBindings { - redis: RedisManagerContract + redis: RedisService } export interface EventsList { diff --git a/src/types/main.ts b/src/types/main.ts index 830551e..b3208bd 100644 --- a/src/types/main.ts +++ b/src/types/main.ts @@ -160,3 +160,18 @@ export type RedisManagerFactory = { emitter: Emitter ): RedisManagerContract } + +/** + * List of connections inferred from user config + */ +export interface RedisConnections {} +export type InferConnections = T['connections'] + +/** + * Redis service is a singleton redis instance registered + * to the container + */ +export interface RedisService + extends RedisManagerContract< + RedisConnections extends RedisConnectionsList ? RedisConnections : never + > {}