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'>>;
},
});
标签:function,02,Typescript,obj,name,makeEventHandlers,Expect,type From: https://www.cnblogs.com/Answer1215/p/17151515.html