// Makes `function.name` return given name
function nameFunction(name: string, body: (args?: any[]) => any) {
return {
[name](...args: any[]) {
return body(...args);
}
}[name];
}
In javascript I can do dynamic keys with such syntax:
let key = "jk_96";
let o = {
[key]: ()=>{ console.log('Yup');}
}
How is allowed in typescript to skip :
after key name, and what [name]
after closing brace of objects means?