Skip to content

Conversation

@dojineko
Copy link

@dojineko dojineko commented Feb 18, 2023

Added TypeScript type definitions for redis-lock 1.0.0

fix: #36
ref: misskey-dev/misskey#9971

The following is a record of how JSDoc handles this issue. If it is necessary, I would like to change the means of implementation.

+ /**
+  * @param {import('redis').RedisClientType} client
+  * @param {string} lockName
+  * @param {number} timeout
+  * @param {number} retryDelay
+  * @param {(timeout: number) => void} onLockAcquired
+  */
  async function acquireLock (client, lockName, timeout, retryDelay, onLockAcquired) {
+ /**
+  * @param {import('redis').RedisClientType} client
+  * @param {number} retryDelay
+  */
  function redisLock (client, retryDelay = DEFAULT_RETRY_DELAY) {
+     /**
+      * @param {string} lockName 
+      * @param {number} timeout
+      * @returns {Promise<string | undefined>}
+      */
      async function lock (lockName, timeout = DEFAULT_TIMEOUT) {

@rostamiani
Copy link

rostamiani commented Apr 6, 2023

The function output is not a Promise<string | undefined>, It's a function and should be Promise<() => Promise<void>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add TypeScript types file

3 participants