typescript - 基于另一种类型的子集的类型,其键以特定字符串开头
问题描述
我正在尝试从另一种类型创建一个类型。该类型将包含基于其前缀的键子集。
基本类型示例:
interface Foo {
axisControl: FormControl;
directionControl: FormControl;
filteredAxis: Observable<string[]>;
filteredDirection: Observable<string[]>;
}
type Bar = // I want to write something only based on the prefix "filtered"
预期结果:
{
filteredAxis: Observable<string[]>;
filteredDirection: Observable<string[]>;
}
这可能吗?怎么做?
到目前为止我已经尝试过:
Pick<Foo, `filtered${string}`>
但这会引发错误。
解决方案
推荐阅读
- c# - 如何有效地将多个文件从 .NET Core Web API 上传到 Azure Blob?
- c++ - ESP32 使用 BLE 和 WiFi API 调用给出错误代码 -1
- javascript - Mongo Db 查找并检索用户并获取所有卡片数据
- javascript - javascript中导出变量之间的区别
- python - Matlab中的长度函数到python
- javascript - 通过比较它们的键来合并两个 javascript 映射
- javascript - 使用 scrollIntoView() 并滚动到所选元素的底部
- android - Android 10 - 以编程方式连接 Wi-Fi 网络
- javascript - 如何用 d3-array 中的 group 和 rollup 总结一个数组?
- javascript - 护照JS | 使用授权码获取访问令牌