diff --git a/types/async-lock/async-lock-tests.ts b/types/async-lock/async-lock-tests.ts index 259749d4f0..c6866d270b 100644 --- a/types/async-lock/async-lock-tests.ts +++ b/types/async-lock/async-lock-tests.ts @@ -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) => { /* ... */ }); diff --git a/types/async-lock/index.d.ts b/types/async-lock/index.d.ts index 4a19590d73..5527482748 100644 --- a/types/async-lock/index.d.ts +++ b/types/async-lock/index.d.ts @@ -1,11 +1,12 @@ // Type definitions for async-lock // Project: https://github.com/rain1017/async-lock -// Definitions by: Elisée MAURER +// Definitions by: Elisée MAURER , Alejandro // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 -interface AsyncLockDoneCallback { - (err?: Error, ret?: any): void; +interface AsyncLockDoneCallback { + (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; + acquire(key: string | string[], + fn: (() => T | PromiseLike) | ((done: AsyncLockDoneCallback) => any), + opts?: AsyncLockOptions): PromiseLike; + acquire(key: string | string[], + fn: (done: AsyncLockDoneCallback) => any, + cb: AsyncLockDoneCallback, + opts?: AsyncLockOptions): void; isBusy(): boolean; } diff --git a/types/async-lock/tslint.json b/types/async-lock/tslint.json index a41bf5d19a..35039ba334 100644 --- a/types/async-lock/tslint.json +++ b/types/async-lock/tslint.json @@ -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,