t-comm
Version:
专业、稳定、纯粹的工具库
16 lines (15 loc) • 373 B
TypeScript
/**
* 深度赋值
* @param keyStr 以点拼接的 key,比如 foo.bar
* @param target 目标对象
* @param value 目标值
* @example
* ```ts
* const obj = { a: { b: 1 } };
* deepSet('a.c', obj, 2);
*
* console.log(obj);
* // { a: { b: 1, c: 2 } }
* ```
*/
export declare function deepSet(keyStr: string, target: Record<string, any>, value: unknown): void;