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

fix: support TypeScript interface as parameters of hmset and mset #1545

Merged
merged 2 commits into from Mar 30, 2022

Conversation

luin
Copy link
Collaborator

@luin luin commented Mar 27, 2022

Closes #1536

There is a limit on the TypeScript side microsoft/TypeScript#15300 (comment) that you can't assign an interface to a record:

interface User {
  name: string;
  age: string;
}

let newUser: User = {
  name: "suman",
  age: "34",
};

const record: Record<string, string> = newUser; // Error here

Given hmset and mset already support ES6 Map, I think it's should be fine to loosen the typing here for convenience.

It's possible that developers may pass invalid object values (e.g. redis.hmset("user-hash", new WeakMap([[{ name: "Bob" }, "value"]]))) but I think that's fine since the usage doesn't make sense and it will trigger an runtime error anyway.

@luin luin requested a review from marcbachmann March 27, 2022 03:14
@luin luin merged commit 3444791 into main Mar 30, 2022
@luin luin deleted the hmset-record branch March 30, 2022 02:10
github-actions bot pushed a commit that referenced this pull request Mar 30, 2022
## [5.0.2](v5.0.1...v5.0.2) (2022-03-30)

### Bug Fixes

* allow option maxRetriesPerRequest to be null ([#1553](#1553)) ([d62a808](d62a808)), closes [#1550](#1550)
* support TypeScript interface as parameters of hmset and mset ([#1545](#1545)) ([3444791](3444791)), closes [#1536](#1536)
@github-actions
Copy link

🎉 This PR is included in version 5.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

janus-dev87 added a commit to janus-dev87/ioredis-work that referenced this pull request Mar 1, 2024
## [5.0.2](redis/ioredis@v5.0.1...v5.0.2) (2022-03-30)

### Bug Fixes

* allow option maxRetriesPerRequest to be null ([#1553](redis/ioredis#1553)) ([d62a808](redis/ioredis@d62a808)), closes [#1550](redis/ioredis#1550)
* support TypeScript interface as parameters of hmset and mset ([#1545](redis/ioredis#1545)) ([3444791](redis/ioredis@3444791)), closes [#1536](redis/ioredis#1536)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hmset in typescript object
2 participants