Solución
solution.tsTypeScript
interface Config {
host?: string;
port?: number;
ssl?: boolean;
}
export function buildConnectionString(config: Config): string {
// Extrae host, port y ssl con destructuring y valores por defecto
const { host = 'localhost', port = 3000, ssl = false } = config;
return `${ ssl ? 'ssl' : 'tcp' }://${ host }:${port}`;
}0respuestas