The expected configuration object type that extends ConfigProperties
.
The expected return type of the configuration object property.
The key corresponding to the configuration value to retrieve.
A promise that resolves to the configuration value associated with the given key.
Generated using TypeDoc
Retrieves a configuration value from the
ConfigService
. This method has three signatures:When a specific configuration type is known (i.e., extends ConfigProperties), and the expected property type is known, you can provide the type as TConfig and the return type as TReturn, which is the type of the property specified by key.
When the specific configuration object type is known but the property type is not specified, the method will return a Promise with the type inferred from the configuration type.
When the type is not known, you can call the method with a string key, and it will return a Promise with an unknown type.
The expected configuration object type that extends
ConfigProperties
.// Use with a known config type and known property type type ExampleConfig = {host: string; url: string}; const host = await ConfigPowers.get<ExampleConfig, string>('host'); console.log(host); // Outputs the host value from the configuration
// Use with a known config type but unknown property type type ExampleConfig = {host: string; url: string}; const configValue = await ConfigPowers.get('host');
console.log(configValue); // Outputs the value from the configuration, type inferred from ExampleConfig
// Use with an unknown config type const value = await ConfigPowers.get('someKey'); console.log(value); // Outputs the value from the configuration of unknown type