sindresorhus/type-fest

Proposal: `AsyncFunction`

开放

#121 创建于 2020年8月18日

 (22 条评论) (2 个反应) (0 位负责人)TypeScript (471 个派生)batch import
corehelp wantedtype addition

仓库指标

星标
 (12,328 个星标)
PR 合并指标
 (平均合并 3天 5小时) (30 天内合并 11 个 PR)

描述

To make it easier to constrain a type to be an async function. We can currently do T extends Function, but there's no way to enforce it to be async.

We already have an internal type for this:

https://github.com/sindresorhus/type-fest/blob/78019f42ea888b0cdceb41a4a78163868de57555/source/async-return-type.d.ts#L3

But I'm thinking it could be more reusable:

type AsyncFunction<Arguments extends readonly any[] = readonly any[], ReturnValue = unknown> = (...arguments_: Arguments) => Promise<ReturnValue>;

Thoughts?

贡献者指南