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

Cannot redeclare block-scoped variable 'addCommand' #310

Closed
CanTheAlmighty opened this issue Jul 1, 2021 · 5 comments
Closed

Cannot redeclare block-scoped variable 'addCommand' #310

CanTheAlmighty opened this issue Jul 1, 2021 · 5 comments

Comments

@CanTheAlmighty
Copy link
Contributor

CanTheAlmighty commented Jul 1, 2021

Hi, I just moved from tedis to this library with very few issues, but I'm getting a compile time issue:

Cannot redeclare block-scoped variable 'addCommand'

To isolate the issue, I created an empty typescript project:

{
  "name": "crashy",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@types/node": "^15.14.0",
    "handy-redis": "^2.2.1",
    "redis": "^3.1.2",
    "typescript": "^4.3.5"
  }
}

With the above, the dependencies currently are (yarn.lock summarized):

// Format
// Package file : Installed Version
@types/redis@^2.8.27:  version "2.8.30"
redis@^3.1.2: version "3.1.2"
handy-redis@^2.2.1: version "2.2.1"

And used a very generic typescript config file.

With all of the above, I get the following conflict:


1410 export function addCommand(command: string): void;
                     ~~~~~~~~~~

  node_modules/handy-redis/dist/node_redis/index.d.ts:5:11
    5     const addCommand: (name: string) => void;
                ~~~~~~~~~~
    'addCommand' was also declared here.

node_modules/handy-redis/dist/node_redis/index.d.ts:5:11 - error TS2451: Cannot redeclare block-scoped variable 'addCommand'.

5     const addCommand: (name: string) => void;
            ~~~~~~~~~~

  node_modules/@types/redis/index.d.ts:1410:17
    1410 export function addCommand(command: string): void;
                         ~~~~~~~~~~
    'addCommand' was also declared here.
@CanTheAlmighty
Copy link
Contributor Author

I went to the DefinitleTyped repo (aka @types/redis) and there was this very interesting commit 8 days ago (since time of posting):

DefinitelyTyped/DefinitelyTyped@fa3bd98

  • move add_command to correct location

This seems to be the source of the clash, as addCommand was moved from RedisClient.addCommand to a top-level function

@CanTheAlmighty
Copy link
Contributor Author

Opened a PR: #311

@UrielCh
Copy link

UrielCh commented Jul 2, 2021

same issue, I'll rolling back to handy-redis 1.8.3, waiting for a new version.

@CanTheAlmighty
Copy link
Contributor Author

CanTheAlmighty commented Jul 2, 2021

same issue, I'll rolling back to handy-redis 1.8.3, waiting for a new version.

Alternatively, you can manually change yarn.lock and force it to keep the older version of the package

"@types/redis@^2.8.27":
  version "2.8.27"
  resolved "https://registry.yarnpkg.com/@types/redis/-/redis-2.8.27.tgz#9bc89b472f3fc4a57a06c1823f2fc860c6c2fdf3"
  integrity sha512-RRHarqPp3mgqHz+qzLVuQCJAIVaB3JBaczoj24QVVYu08wiCmB8vbOeNeK9lIH+pyT7+R/bbEPghAZZuhbZm0g==
  dependencies:
    "@types/node" "*"```

@mmkal
Copy link
Owner

mmkal commented Jul 3, 2021

Fixed by #311, released in v2.2.2.

@mmkal mmkal closed this as completed Jul 3, 2021
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

No branches or pull requests

3 participants