Skip to content

Commit 0c4232d

Browse files
wangzilingsxzz
andauthored
types: omit async & sync method after QuansyncFn#bind (#15)
* feat: enable `bind this` feature * types: fix the type of the `QuansyncFn.bind` * test: enhance the test case for the `bind this` scenario * type: enhance the `bind` type of the `QuansyncFn` * tests: remove the unnecessary tests * chore: remove the unnecessary codes * docs: add the annotations for the special `bind` type * refactor --------- Co-authored-by: 三咲智子 Kevin Deng <[email protected]>
1 parent 2719b42 commit 0c4232d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ export type QuansyncAwaitableGenerator<Return = any, Yield = unknown> =
2727
export type QuansyncFn<Return = any, Args extends any[] = []> =
2828
((...args: Args) => QuansyncAwaitableGenerator<Return>)
2929
& {
30+
/**
31+
* **Warning**: The `async` and `sync` methods will be lost after invoked.
32+
*/
33+
bind: <T, A extends any[], B extends any[]>(
34+
this: (this: T, ...args: [...A, ...B]) => QuansyncAwaitableGenerator<Return>,
35+
thisArg: T,
36+
...args: A
37+
) => ((...args: B) => QuansyncAwaitableGenerator<Return>)
38+
3039
sync: (...args: Args) => Return
3140
async: (...args: Args) => Promise<Return>
3241
}

0 commit comments

Comments
 (0)