说我有以下代码:
async promiseOne() {
return 1
} // => Promise<number>
const promisedOne = promiseOne()
typeof promisedOne // => Promised<number>
Run Code Online (Sandbox Code Playgroud)
我将如何提取承诺结果的类型(在这个简化的情况下是一个数字),因为它是自己的类型?
假设我有类似的类型React.ComponentClass<Props>
,我想引用该Props
部分,但它在我当前的上下文中未命名.
为了显示:
typeof x
在这种情况下,我可以使用,Something
但这不会让我直接访问该Something
类型.
我想要的是这样的:
GetPropsType<typeof x>
所以我可以提取React.ComponentClass<Props>
类型Props
任何相当的东西都会很棒.
typescript ×2