Sunny-117 / js-challenges

✨✨✨ Challenge your JavaScript programming limits step by step

Home Page:https://juejin.cn/column/7244788137410560055

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

myReadonly

FailurMan opened this issue · comments

//使用ts实现获取readonly方法
type MyReadonly<T> = {
  readonly [P in keyof T]: T[P];
};

type MyReadonly<T extends Record<string, any>> = {
readonly [K in keyof T]:T[K]
}