Skip to content

Commit

Permalink
Merge pull request #174 from JasonHK/fix/ConfigService
Browse files Browse the repository at this point in the history
fix: fixes the infer bug of `ConfigService.get`
  • Loading branch information
kamilmysliwiec committed May 7, 2020
2 parents 68e0375 + 9df67bc commit a265145
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CONFIGURATION_TOKEN,
VALIDATED_ENV_PROPNAME,
} from './config.constants';
import { NoInferType } from './types';

@Injectable()
export class ConfigService {
Expand All @@ -29,7 +30,7 @@ export class ConfigService {
* @param propertyPath
* @param defaultValue
*/
get<T = any>(propertyPath: string, defaultValue: T): T;
get<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;
/**
* Get a configuration value (either custom configuration or process environment variable)
* based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
Expand Down
1 change: 1 addition & 0 deletions lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './config.type';
export * from './no-infer.type';
1 change: 1 addition & 0 deletions lib/types/no-infer.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type NoInferType<T> = [T][T extends any ? 0 : never];

0 comments on commit a265145

Please sign in to comment.