forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
89 lines (73 loc) · 3.29 KB
/
index.d.ts
File metadata and controls
89 lines (73 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { ConfigPaths, ConfigPathValues, HasBeenAugmented } from "./utils";
declare var c: c.IConfig;
declare namespace c {
// 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;
extendDeep(mergeInto: any, mergeFrom1: any, mergeFrom2: any, depth?: number): any;
extendDeep(mergeInto: any, ...mergeFrom: any): any;
// Return a deep copy of the specified object.
cloneDeep(copyFrom: any, depth?: number): any;
// Set objects given a path as a string list
setPath(object: object, path: string[], value?: any): void;
// 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;
// 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[];
// Returns a new deep copy of the current config object, or any part of the config if provided.
toObject(config?: any): any;
/**
* This allows module developers to attach their configurations onto the default configuration object
* so they can be configured by the consumers of the module.
*/
setModuleDefaults(moduleName: string, defaults: any): any;
}
/**
* By augmenting this interface with your own config, you can greatly improve the IntelliSense for the `get` method:
* - Dot notation paths for the `setting` parameter
* - Correctly typed return values
*
* @example
* declare module 'config' {
* interface IConfig extends MyConfig {}
* }
*
* @example
* declare module 'config' {
* interface IConfig {
* myConfig: {
* myString: string;
* myNumber: number;
* };
* }
* }
*
* @example
* const knownToBeStringTyped = config.get('myConfig.myString');
*/
interface IConfig {
get: HasBeenAugmented<IConfig> extends true
? <T extends ConfigPaths<IConfig>>(setting: T) => ConfigPathValues<IConfig, T>
: <T>(setting: string) => T;
has(setting: ConfigPaths<IConfig>): boolean;
has(setting: string): boolean;
util: IUtil;
}
interface IConfigSource {
name: string;
original?: string | undefined;
parsed: any;
}
}
export = c;