@nickyzj2023/utils
    Preparing search index...

    Function mapKeys

    • 递归处理对象里的 key

      Type Parameters

      • T

        要转换的对象

      Parameters

      • obj: T
      • getNewKey: (key: string) => string

      Returns DeepMapKeys<T>

      无法完整推导出类型,只能做到有递归,key 全为 string,value 为同层级的所有类型的联合

      const obj = { a: { b: 1 } };
      const result = mapKeys(obj, (key) => key.toUpperCase());
      console.log(result); // { A: { B: 1 } }