typescript - Typescript:为库类方法创建类型
问题描述
在很多情况下,我想基于类方法(通常由库类提供)创建辅助类型。但我似乎无法弄清楚。
理想情况下,以下内容会很棒。但在这种情况下它似乎不起作用。
// Library code
declare class LibClass {
Method1(something: number): Promise<string>;
}
// My application code
type LibMethodType = ReturnType<LibClass.Method1>
有人对如何解决这个问题有任何建议吗?
解决方案
推荐阅读
- python - 具有 2 个组件的 pca 输出 1 个功能
- r - 从 R 对象中删除不必要和重复的模式并更改为标准时间格式
- python - 使用 win32com.shell (python) 复制 iphone 文件
- dart - Dart AOT 是如何工作的?
- kubernetes - 我可以使用从 pod 中的 init 容器创建的配置映射吗
- datastax-enterprise - 使用 DSE 高级复制与手动多 DC 设置进行灾难恢复之间的区别?
- spring - Spring Boot端口转发80到8080
- rotation - 如何围绕自身边界的中心旋转 UIBezierPath?
- r - 在 ggplot2 中绘制 shapefile:Print() 错误
- java - 异常处理,第一个 try/catch 块在接受正确输入之前不会重复