Create an async version of the given function type, by boxing the return type in `Promise` while keeping the same parameter types.
5
6
Use-case: You have two functions, one synchronous and one asynchronous that do the same thing. Instead of having to duplicate the type definition, you can use `Asyncify` to reuse the synchronous type.
7
8
@example
9
```
10
import type {Asyncify} from 'type-fest';
11
12
// Synchronous function.
13
function getFooSync(someArg: SomeType): Foo {
14
// …
15
}
16
17
type AsyncifiedFooGetter = Asyncify<typeof getFooSync>;
18
//=> type AsyncifiedFooGetter = (someArg: SomeType) => Promise<Foo>;
// TypeScript now knows that `someArg` is `SomeType` automatically.
23
// It also knows that this function must return `Promise<Foo>`.
24
// If you have `@typescript-eslint/promise-function-async` linter rule enabled, it will even report that "Functions that return promises must be async.".