Typescript:模块作为返回类型?

标签 typescript

有一个模块代表我需要作为返回类型的对象。 Typescript 对我的行为犹豫不决 public myThingGetter(): Promise<ThisIsTheModuleName> 。我在这里有什么选择?

最佳答案

public myThingGetter(): Promise. What are my options here?

Promise<ThisIsTheModuleName>type 声明空间中的注释。

我认为你需要使用Promise<typeof ThisIsTheModuleName>或者使用import而不是var/const等等

更多

此处介绍:https://basarat.gitbooks.io/typescript/content/docs/project/declarationspaces.html

关于Typescript:模块作为返回类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38087308/

相关文章:

typescript - 在 src 目录中创建 React App (TypeScript) 自动生成 react-app-env.d.ts

javascript - 显示小数点后 2 位数字的最佳实践

typescript - 从 Typescript 中的联合类型推断回调参数类型的最佳方法是什么?

html - 如何更改导航栏的背景?

javascript - 如何将可更新的 `this` 从静态方法传递给静态方法?

reactjs - useQuery 包装器查询键类型不匹配

javascript - Angular2如何更新另一个组件中的图像

typescript :调用另一个类的 "method"

typescript - TypeScript中如何区分模块级变量和局部变量

javascript - ESLint 扩展 vs 插件 v2020