[Typescript] Identity function - Reverse mapped types with identity function 02
import { Equal, Expect } from '../helpers/type-utils';
export function makeEventHandlers<
T extends { [Key in keyof T]: (key: Key) => void }
>(obj: T) {
return obj;
}
const obj = makeEventHandlers({
click: (name) => {
console.log(name);
type test = Expect<Equal<typeof name, 'click'>>;
},
focus: (name) => {
console.log(name);
type test = Expect<Equal<typeof name, 'focus'>>;
},
});