Skip to content

Commit

Permalink
fix: fixes the infer bug of ConfigService.get
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonHK committed Apr 11, 2020
1 parent 0fb4bd7 commit 9df67bc
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 9df67bc

Please sign in to comment.