Skip to content

Commit

Permalink
fix: RedisService typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Jul 15, 2023
1 parent 47c33cf commit 2b9143f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/types/extended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions src/types/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,18 @@ export type RedisManagerFactory = {
emitter: Emitter<any>
): RedisManagerContract<ConnectionList>
}

/**
* List of connections inferred from user config
*/
export interface RedisConnections {}
export type InferConnections<T extends { connections: RedisConnectionsList }> = T['connections']

/**
* Redis service is a singleton redis instance registered
* to the container
*/
export interface RedisService
extends RedisManagerContract<
RedisConnections extends RedisConnectionsList ? RedisConnections : never
> {}

0 comments on commit 2b9143f

Please sign in to comment.