typescript - 如何在 TypeScript 中创建具有类型别名的对象?
问题描述
new BaseListState<BrandCriteria, Brand>()
这是有效的,我添加
export type BrandListState = BaseListState<BrandCriteria, Brand>;
然后
new BrandListState()
这是不允许的。有什么办法可以解决这个问题?
解决方案
您正在使用没有构造函数的类型别名(请参阅此处的文档),因此无法使用new
. 您需要为此创建类
class BrandListState extends BaseListState<BrandCriteria, Brand> {}
推荐阅读
- python - 如何将测试数据帧放在预测数据帧的同一数据帧中
- javascript - 单击另一个框中的选项时更改选择框中的选项
- mysql - 如何创建循环以将完成的文件发送到不同的目录(已关闭)
- laravel - 为什么 Laravel 中的观察者删除不起作用
- networking - 如何在线公开 Node-red 服务器(保持服务器在设备上运行)?
- c++ - 使用继承的模板参数类中的方法
- javascript - 无法从 fetch react 应用程序访问嵌套 JSON 结果
- arrays - 无法让数组在 Mac 上的 Office 365 Excel 中工作
- python - 如何在Python中计算多个列表中的字母数
- c# - 无法在 findResults.NextPageOffset 中隐式转换类型