Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@nestjs/config): better generic support for
registerAs
Add support to specify the return type of a config factory. BREAKING CHANGE: The commit will break the code which already utilizing the generic of `registerAs` function.
- Loading branch information
Showing
4 changed files
with
13 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
type ConfigFactoryReturnValue = | ||
| Record<string, any> | ||
| Promise<Record<string, any>>; | ||
import { ConfigObject } from '../types'; | ||
|
||
type ConfigFactoryReturnValue<T extends ConfigObject> = T | Promise<T>; | ||
|
||
export type ConfigFactory< | ||
T extends ConfigFactoryReturnValue = ConfigFactoryReturnValue | ||
> = () => T; | ||
T extends ConfigObject = ConfigObject | ||
> = () => ConfigFactoryReturnValue<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type ConfigObject = Record<string, any>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './config.type'; | ||
export * from './config-object.type'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters