import MissingConfigurationValueError from '../errors/MissingConfigurationValueError' import type { NonUndefined, ValueOf } from '../types' const requireConfig = (isomorphicConfig: T, key: keyof T) => { const valueUnderKey = isomorphicConfig[key] if (typeof valueUnderKey === 'undefined') { throw new MissingConfigurationValueError( `Value for configuration key ${key} was undefined.` ) } return valueUnderKey as NonUndefined> } export default requireConfig