From ca01ce404a3fa522720260b7206538cbd63bfbe5 Mon Sep 17 00:00:00 2001 From: Forrest Bice Date: Fri, 8 Sep 2017 12:17:13 -0700 Subject: [PATCH] Defining ConfigJS `setModuleDefaults` Types Adding missing type definition for `setModuleDefaults` found here https://github.com/lorenwest/node-config/blob/083a783daa5e2426d679890ae7e3fb3149100d13/lib/config.js#L358 --- types/config/config-tests.ts | 2 ++ types/config/index.d.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/types/config/config-tests.ts b/types/config/config-tests.ts index 507ecc463c..7952705265 100644 --- a/types/config/config-tests.ts +++ b/types/config/config-tests.ts @@ -34,3 +34,5 @@ var configSources: config.IConfigSource[] = config.util.getConfigSources(); var configSource: config.IConfigSource = configSources[0]; var configSourceName: string = configSource.name; var configSourceOriginal: string | undefined = configSource.original; + +var moduleDefaults: any = config.util.setModuleDefaults("moduleName", {}); diff --git a/types/config/index.d.ts b/types/config/index.d.ts index 2f7ee3eaf1..ea5e5a940a 100644 --- a/types/config/index.d.ts +++ b/types/config/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for node-config // Project: https://github.com/lorenwest/node-config // Definitions by: Roman Korneev +// Forrest Bice +// James Donald // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -31,12 +33,19 @@ declare namespace c { // Get the current value of a config environment variable getEnv(varName: string): string; - + // Return the config for the project based on directory param if not directory then return default one (config). loadFileConfigs(configDir: string): any; // Return the sources for the configurations getConfigSources(): IConfigSource[]; + + /** + * This allows module developers to attach their configurations onto + * the 6 years agoInitial 0.4 checkin default configuration object so + * they can be configured by the consumers of the module. + */ + setModuleDefaults(moduleName:string, defaults:any): any; } interface IConfig {