From d4b7e07fa6de575777a0b979b210aad23dd8bec5 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 14 Sep 2015 11:43:48 +0300 Subject: [PATCH] 1. Use generic for the config.get method. 2. Include IUtil definition in the module scope. --- node-config/node-config-tests.ts | 4 ++- node-config/node-config.d.ts | 50 ++++++++++++++++---------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/node-config/node-config-tests.ts b/node-config/node-config-tests.ts index 9883a8a21..f20ea7f30 100644 --- a/node-config/node-config-tests.ts +++ b/node-config/node-config-tests.ts @@ -2,7 +2,9 @@ import config = require('config'); -var value: string = config.get(""); +var value1: string = config.get(""); +var value2: any = config.get(""); + var has: boolean = config.has(""); // util tests: diff --git a/node-config/node-config.d.ts b/node-config/node-config.d.ts index 3db296850..c37eddae9 100644 --- a/node-config/node-config.d.ts +++ b/node-config/node-config.d.ts @@ -3,32 +3,32 @@ // Definitions by: Roman Korneev // Definitions: https://github.com/borisyankov/DefinitelyTyped -// see https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities -interface IUtil { - // Extend an object (and any object it contains) with one or more objects (and objects contained in them). - extendDeep(mergeInto: any, mergeFrom: any, depth?: number): any; - - // Return a deep copy of the specified object. - cloneDeep(copyFrom: any, depth?: number): any; - - // Return true if two objects have equal contents. - equalsDeep(object1: any, object2: any, dept?: number): boolean; - - // Returns an object containing all elements that differ between two objects. - diffDeep(object1: any, object2: any, depth?: number): any; - - // Make a javascript object property immutable (assuring it cannot be changed from the current value). - makeImmutable(object: any, propertyName?: string, propertyValue?: string): any; - - // Make an object property hidden so it doesn't appear when enumerating elements of the object. - makeHidden(object: any, propertyName: string, propertyValue?: string): any; - - // Get the current value of a config environment variable - getEnv(varName: string): string; -} - declare module "config" { - export function get(setting: string): any; + // see https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities + interface IUtil { + // Extend an object (and any object it contains) with one or more objects (and objects contained in them). + extendDeep(mergeInto: any, mergeFrom: any, depth?: number): any; + + // Return a deep copy of the specified object. + cloneDeep(copyFrom: any, depth?: number): any; + + // Return true if two objects have equal contents. + equalsDeep(object1: any, object2: any, dept?: number): boolean; + + // Returns an object containing all elements that differ between two objects. + diffDeep(object1: any, object2: any, depth?: number): any; + + // Make a javascript object property immutable (assuring it cannot be changed from the current value). + makeImmutable(object: any, propertyName?: string, propertyValue?: string): any; + + // Make an object property hidden so it doesn't appear when enumerating elements of the object. + makeHidden(object: any, propertyName: string, propertyValue?: string): any; + + // Get the current value of a config environment variable + getEnv(varName: string): string; + } + + export function get(setting: string): T; export function has(setting: string): boolean; export var util: IUtil; }