1 | // Type definitions for rc 1.2
|
2 | // Project: https://github.com/dominictarr/rc
|
3 | // Definitions by: Daniel Rosenwasser <https://github.com/DanielRosenwasser>
|
4 | // BendingBender <https://github.com/BendingBender>
|
5 | // kusyka911 <https://github.com/kusyka911>
|
6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
7 | // TypeScript Version: 2.2
|
8 |
|
9 | interface RcResultType<T> {
|
10 | /**
|
11 | * Contains all parsed configurations from different sources
|
12 | * like '/etc/${appname}rc', '/etc/${appname}/config', and other.
|
13 | */
|
14 | configs: T[];
|
15 | /**
|
16 | * same as RcResultType.configs[RcResultType.configs.length - 1]
|
17 | */
|
18 | config: T;
|
19 | /**
|
20 | * For compatibility with previous versions of '@types/rc'
|
21 | */
|
22 | [key: string]: any;
|
23 | }
|
24 |
|
25 | declare function rc<T extends object = { [key: string]: any }>(
|
26 | name: string,
|
27 | defaults?: T,
|
28 | /**
|
29 | * Parsed argv object. For example, if args is `--foo bar`, then this value should be `{foo: 'bar'}`
|
30 | * If `argv` is `null` or `undefined`, then `rc`'s default parser will parse `process.argv`.
|
31 | */
|
32 | argv?: T | null,
|
33 | /**
|
34 | * Custom config file parser.
|
35 | * This function will be passed the string contents of each
|
36 | * discovered configuration file should return a parsed object dictionary.
|
37 | */
|
38 | parse?: ((content: string) => { [key: string]: any }) | null
|
39 | ): T & RcResultType<T>;
|
40 |
|
41 | export = rc;
|
42 |
|
\ | No newline at end of file |