Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add type definition #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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