Skip to content

fix(types): optional properties on RedisOptions allow explicit undefined#2066

Open
avocadojesus wants to merge 1 commit intoredis:mainfrom
avocadojesus:fix/username-and-password-have-explicit-undefined-types
Open

fix(types): optional properties on RedisOptions allow explicit undefined#2066
avocadojesus wants to merge 1 commit intoredis:mainfrom
avocadojesus:fix/username-and-password-have-explicit-undefined-types

Conversation

@avocadojesus
Copy link

@avocadojesus avocadojesus commented Jan 16, 2026

when exactOptionalPropertyTypes is true in the consuming application's tsconfig, you cannot send in an explicit undefined for these fields, causing the developer to jump through extra hoops needlessly to get i.e. the username and password provided to the options in a type-safe manner. This fix corrects this by explicitly specifying undefined as an allowed type on the username and password properties within RedisOptions.

new Redis({
  ...
  password: process.env.REDIS_PASSWORD,
})

@jit-ci
Copy link

jit-ci bot commented Jan 16, 2026

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@jit-ci
Copy link

jit-ci bot commented Jan 16, 2026

❌ Security scan failed

Security scan failed: Branch fix/username-and-password-have-explicit-undefined-types does not exist in the remote repository


💡 Need to bypass this check? Comment @sera bypass to override.

@avocadojesus
Copy link
Author

@sera bypass

@avocadojesus avocadojesus changed the title optional properties on RedisOptions allow explicit undefined fix(types): optional properties on RedisOptions allow explicit undefined Jan 16, 2026
@PavelPashov
Copy link
Contributor

@avocadojesus Appreciate you putting this together.

When you get a chance, could you apply the same change to keep things consistent in:

@avocadojesus avocadojesus force-pushed the fix/username-and-password-have-explicit-undefined-types branch from 94d04eb to e2ddbb7 Compare January 29, 2026 20:24
@avocadojesus
Copy link
Author

avocadojesus commented Jan 29, 2026

@avocadojesus Appreciate you putting this together.

When you get a chance, could you apply the same change to keep things consistent in:

* [ClusterOptions](https://github.com/redis/ioredis/blob/4cf4d9974788bf1505694a49022f86d473cd3067/lib/cluster/ClusterOptions.ts#L31)

* [SentinelConnectionOptions](https://github.com/redis/ioredis/blob/4cf4d9974788bf1505694a49022f86d473cd3067/lib/connectors/SentinelConnector/index.ts#L34)

absolutely, done! Thanks for maintaining the project and giving me the time of day, I appreciate you 🙏 . Curious, I noticed prettier kicking in, so i went ahead and ran the npm run format, thinking it would remove any changes in code. To the contrary, it kept many of the changes my prettier had made, and then found many more changes to make in files that I did not even touch. I did not end up committing any of them, but I just wanted to say sorry for the prettier spam in this PR.

…erOptions

when exactOptionalPropertyTypes is true in the consuming application's tsconfig, you cannot send in an explicit undefined for these fields, causing the developer to jump through extra hoops needlessly to get i.e. the username and password provided to the options in a type-safe manner. This fix corrects this by explicitly specifying undefined as an allowed type on the username and password properties within RedisOptions, SentinelConnectionOptions, and ClusterOptions.

```ts
new Redis({
  ...
  password: process.env.REDIS_PASSWORD,
})
```
@avocadojesus avocadojesus force-pushed the fix/username-and-password-have-explicit-undefined-types branch from e2ddbb7 to 505bce6 Compare January 30, 2026 21:22
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.

2 participants