Skip to content

Commit 4368a4f

Browse files
committed
🐛 isAsyncFunction should use Promise<unknown>
1 parent 49ab144 commit 4368a4f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

is.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ export function isSyncFunction(
473473
*/
474474
export function isAsyncFunction(
475475
x: unknown,
476-
): x is (...args: unknown[]) => unknown {
476+
): x is (...args: unknown[]) => Promise<unknown> {
477477
return Object.prototype.toString.call(x) === "[object AsyncFunction]";
478478
}
479479

is_test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,18 +759,33 @@ Deno.test("isFunction", async (t) => {
759759
await testWithExamples(t, isFunction, {
760760
validExamples: ["syncFunction", "asyncFunction"],
761761
});
762+
type _ = AssertTrue<
763+
IsExact<PredicateType<typeof isFunction>, (...args: unknown[]) => unknown>
764+
>;
762765
});
763766

764767
Deno.test("isSyncFunction", async (t) => {
765768
await testWithExamples(t, isSyncFunction, {
766769
validExamples: ["syncFunction"],
767770
});
771+
type _ = AssertTrue<
772+
IsExact<
773+
PredicateType<typeof isSyncFunction>,
774+
(...args: unknown[]) => unknown
775+
>
776+
>;
768777
});
769778

770779
Deno.test("isAsyncFunction", async (t) => {
771780
await testWithExamples(t, isAsyncFunction, {
772781
validExamples: ["asyncFunction"],
773782
});
783+
type _ = AssertTrue<
784+
IsExact<
785+
PredicateType<typeof isAsyncFunction>,
786+
(...args: unknown[]) => Promise<unknown>
787+
>
788+
>;
774789
});
775790

776791
Deno.test("isInstanceOf<T>", async (t) => {

0 commit comments

Comments
 (0)