Skip to content

Commit 3a3a9f9

Browse files
committed
fix(type): CacheModuleAsyncOptions
Reused type CacheModuleOptions causing isGlobal to leak incorrectly into async options. #349
1 parent c87d560 commit 3a3a9f9

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lib/interfaces/cache-module.interface.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import { ConfigurableModuleAsyncOptions, Provider, Type } from '@nestjs/common';
22
import { CacheManagerOptions } from './cache-manager.interface';
33

4-
export type CacheModuleOptions<
4+
export type CacheOptions<
55
StoreConfig extends Record<any, any> = Record<string, any>,
66
> =
77
// Store-specific configuration takes precedence over cache module options due
88
// to how `createCacheManager` is implemented.
9-
CacheManagerOptions &
10-
StoreConfig & {
11-
/**
12-
* If "true', register `CacheModule` as a global module.
13-
*/
14-
isGlobal?: boolean;
15-
};
9+
CacheManagerOptions & StoreConfig;
10+
11+
export type CacheModuleOptions<
12+
StoreConfig extends Record<any, any> = Record<string, any>,
13+
> = CacheOptions<StoreConfig> & {
14+
/**
15+
* If "true', register `CacheModule` as a global module.
16+
*/
17+
isGlobal?: boolean;
18+
};
1619

1720
/**
1821
* Interface describing a `CacheOptionsFactory`. Providers supplying configuration
@@ -26,8 +29,8 @@ export interface CacheOptionsFactory<
2629
StoreConfig extends Record<any, any> = Record<string, any>,
2730
> {
2831
createCacheOptions():
29-
| Promise<CacheModuleOptions<StoreConfig>>
30-
| CacheModuleOptions<StoreConfig>;
32+
| Promise<CacheOptions<StoreConfig>>
33+
| CacheOptions<StoreConfig>;
3134
}
3235

3336
/**
@@ -40,7 +43,7 @@ export interface CacheOptionsFactory<
4043
export interface CacheModuleAsyncOptions<
4144
StoreConfig extends Record<any, any> = Record<string, any>,
4245
> extends ConfigurableModuleAsyncOptions<
43-
CacheModuleOptions<StoreConfig>,
46+
CacheOptions<StoreConfig>,
4447
keyof CacheOptionsFactory
4548
> {
4649
/**
@@ -59,9 +62,7 @@ export interface CacheModuleAsyncOptions<
5962
*/
6063
useFactory?: (
6164
...args: any[]
62-
) =>
63-
| Promise<CacheModuleOptions<StoreConfig>>
64-
| CacheModuleOptions<StoreConfig>;
65+
) => Promise<CacheOptions<StoreConfig>> | CacheOptions<StoreConfig>;
6566
/**
6667
* Dependencies that a Factory may inject.
6768
*/

0 commit comments

Comments
 (0)