typescript - 递归地为对象中的每个键添加后缀
问题描述
功能被最小化。它应该将“blabla”添加到每个对象键作为后缀(递归)。
错误
Type 'any[]' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be
unrelated to 'any[]'.
(2322)
输入
addBlabla([{ a: [{ b: 1 }] }])
输出
{
ablabla: {
b: number; // not a "bblabla"
}[];
}[]
解决方案
TS 游乐场:https ://tsplay.dev/wQKyVm
我删除Array.isArray
了部分,因为 Array 也是对象(typeof)。
推荐阅读
- wordpress - 编辑woocommerce单品布局页面
- android - Anko doAsync 如何在 uiThread 之前等待重新创建活动
- php - Paas Excel 工作表数据在数组中并使用 Codeigniter 发送到模型
- python-3.x - 用于电子签名的 MKS/PTC Integrity CLI 命令
- c# - 无法在 .NET 4.5 MVC 应用程序上实现 JSNLog
- sql - 用 CLOB 插入
- java - onChildAdded 触发器后没有数据插入到 firebase
- php - Laravel 5.6 会话不是持久的
- git - git smudge 过滤器在最后一个文件上失败
- sql - t sql 根据前一行日期值递增日期列值