Solución
solution.tsTypeScript
const mathModule = { add: (a: number, b: number) => a + b, sub: (a: number, b: number) => a - b };
const stringModule = { upper: (s: string) => s.toUpperCase(), lower: (s: string) => s.toLowerCase() };
// Implementa createIndex: combina ambos módulos en un solo objeto (spread)
function createIndex() {
const unifiedModule = {...mathModule, ...stringModule}
return unifiedModule
};
function runIndexDemo(): [number, string, number, string] {
const idx = createIndex() as any;
return [idx.add(3, 2), idx.upper("hi"), idx.sub(10, 4), idx.lower("WORLD")];
}
export { runIndexDemo };0respuestas