当您查看打字稿异步功能时,您可以清楚地看到async
和Promise<type>
的冗余。
public async test(): Promise<string> {
return "Test";
}
是否可以配置typecrypt,以处理没有Promise<T>
类型的异步类型?就像T
一样:
public async test(): string {
return "Test";
}
我在尝试跳过Promise< >
时遇到了这个问题:The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<number>'?ts(1064)
Question is about how to avoid writing boilerplate. We know that async fn() will always return a Promise, so why do I have to write Promise<T>
-@ josh3736