Skip to content

Commit 2260be2

Browse files
committed
fix: have RedisKey#join preserve the class type
1 parent 0de00be commit 2260be2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/key.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ export class RedisKey<
3737
* Derive a new key by prefixing the current key with the given keys. When multiple keys are
3838
* passed in, they will be joined with a colon.
3939
*/
40-
join(...keys: (string | number)[]) {
40+
join(...keys: (string | number)[]): this {
4141
if (keys.length === 0) return this;
42-
return new RedisKey(`${this.name}:${keys.join(":")}`, this.schema);
42+
return new (this.constructor as new (name: string, schema: T) => this)(
43+
`${this.name}:${keys.join(":")}`,
44+
this.schema,
45+
);
4346
}
4447

4548
/**

0 commit comments

Comments
 (0)