Run ❯
Get your
own Node
server
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
// Key remapping demo (runtime helper) type User = { id: number; name: string; email: string }; function makeGetters
>(obj: T) { const out: any = {}; for (const k of Object.keys(obj)) { const cap = k.charAt(0).toUpperCase() + k.slice(1); out["get" + cap] = () => obj[k]; } return out as { [K in keyof T as `get${Capitalize
}`]: () => T[K]; }; } const u: User = { id: 7, name: "Bob", email: "bob@example.com" }; const g = makeGetters(u); console.log(g.getId()); console.log(g.getName()); console.log(g.getEmail());
7 Bob bob@example.com