首页 > 其他分享 >[Typescript]106. Medium - OnPropChnagedMethods

[Typescript]106. Medium - OnPropChnagedMethods

时间:2022-11-16 15:13:04浏览次数:73  
标签:Typescript void OnPropChnagedMethods Medium Key 106

type OnPropChnagedMethods<T> = {
  [Key in keyof T & string as `${Key}Changed`]: (cb: (newValue: T[Key]) => void) => void
}
declare function makeWatchedObject<T>(obj: T): T & OnPropChnagedMethods<T>;
let homer = makeWatchedObject({
  firstName: "Homer",
  age: 33,
  location: "Springfield"
})

标签:Typescript,void,OnPropChnagedMethods,Medium,Key,106
From: https://www.cnblogs.com/Answer1215/p/16895957.html

相关文章