Solución
solution.tsTypeScript
interface AppConfig {
database?: { connection?: { host: string; timeout?: number } } | null;
}
export function getTimeout(config: AppConfig): number {
// Accede a database.connection.timeout con ?. y usa ?? para el valor por defecto
return config?.database?.connection?.timeout ?? 5000
}0respuestas