/**
 * Get first defined value.
 *
 * Specialized "replacement" for `a || b || c` used frequently to get value from various sources
 * (defaults, configs  constants).
 * In contrast to `||`, this function provides proper typing for usual use cases (constant as last
 * argument) and correct treatment of `null` and `undefined`.
 *
 * If last parameter is "defined" then return type is `T`, otherwise return type is `T | undefined`.
 *
 * Usage example:
 *
 *     interface Config {
 *         x?: number;
 *     }
 *     const someConfig: Config = {};
 *     const val: number | undefined = undefined;
 *     const DEFAULT = 5;
 *     const x = getOptionValue(val, someConfig.x, DEFAULT);
 *         // typeof x === 'number' because DEFAULT is defined
 *     const y = getOptionValue(val, someConfig.x);
 *         // typeof y === 'number | undefined' because someConfig.x is possibly undefined
 */ export function getOptionValue < T > ( a ) ; export function getOptionValue < T > ( a , b ) ; export function getOptionValue < T > ( a , b , c ) ; export function getOptionValue < T > ( a , b , c , d ) ; export function getOptionValue < T > ( ... values ) ; export function getOptionValue < T > ( ... values ) { for ( const candidate of values ) { if ( candidate !== undefined && candidate !== null ) { return candidate ; } } return undefined ; }