mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-29 08:58:23 +08:00
async-lock: Generics in returned values (#23131)
* async-lock: Generics in returned values * Revert promise with "done" test to prove it still works as before * Add test where fn is a promise
This commit is contained in:
committed by
Sheetal Nandi
parent
257c8bc48a
commit
7968b99ad1
@@ -10,6 +10,14 @@ lock.acquire("key", (done) => {
|
||||
done();
|
||||
}).then(() => { /* ... */ });
|
||||
|
||||
lock.acquire("key", () => "stringValue")
|
||||
// Check returned value's type is inherited properly
|
||||
.then((str) => str.replace("s", "S"));
|
||||
|
||||
lock.acquire("key", async () => "stringValue")
|
||||
// Check returned value's type is inherited properly
|
||||
.then((str) => str.replace("s", "S"));
|
||||
|
||||
lock.acquire([ "key1", "key2" ], (done) => {
|
||||
done();
|
||||
}, (err, ret) => { /* ... */ });
|
||||
|
||||
16
types/async-lock/index.d.ts
vendored
16
types/async-lock/index.d.ts
vendored
@@ -1,11 +1,12 @@
|
||||
// Type definitions for async-lock
|
||||
// Project: https://github.com/rain1017/async-lock
|
||||
// Definitions by: Elisée MAURER <https://github.com/elisee>
|
||||
// Definitions by: Elisée MAURER <https://github.com/elisee>, Alejandro <https://github.com/afharo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
|
||||
interface AsyncLockDoneCallback {
|
||||
(err?: Error, ret?: any): void;
|
||||
interface AsyncLockDoneCallback<T> {
|
||||
(err?: Error, ret?: T): void;
|
||||
}
|
||||
|
||||
interface AsyncLockOptions {
|
||||
@@ -18,8 +19,13 @@ interface AsyncLockOptions {
|
||||
declare class AsyncLock {
|
||||
constructor(options?: AsyncLockOptions);
|
||||
|
||||
acquire(key: string | string[], fn: (done: AsyncLockDoneCallback) => any, cb: AsyncLockDoneCallback, opts?: AsyncLockOptions): void;
|
||||
acquire(key: string | string[], fn: (done: AsyncLockDoneCallback) => any, opts?: AsyncLockOptions): PromiseLike<any>;
|
||||
acquire<T>(key: string | string[],
|
||||
fn: (() => T | PromiseLike<T>) | ((done: AsyncLockDoneCallback<T>) => any),
|
||||
opts?: AsyncLockOptions): PromiseLike<T>;
|
||||
acquire<T>(key: string | string[],
|
||||
fn: (done: AsyncLockDoneCallback<T>) => any,
|
||||
cb: AsyncLockDoneCallback<T>,
|
||||
opts?: AsyncLockOptions): void;
|
||||
|
||||
isBusy(): boolean;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,11 @@
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
|
||||
Reference in New Issue
Block a user