Skip to content

Commit e27bf5c

Browse files
committed
chore(types): stop using TAnySchema anywhere
1 parent 0e65d00 commit e27bf5c

File tree

6 files changed

+19
-34
lines changed

6 files changed

+19
-34
lines changed

src/channel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TAnySchema, TSchema, TString, Type } from "@sinclair/typebox";
1+
import { TSchema, TString, Type } from "@sinclair/typebox";
22
import { isString } from "radashi";
33
import { RedisKey } from "./key";
44
import { RedisTransform } from "./transform";
@@ -7,7 +7,7 @@ import { RedisTransform } from "./transform";
77
* Channels use the `SUBSCRIBE` command.
88
*/
99
export class RedisChannel<
10-
T extends TSchema = TAnySchema,
10+
T extends TSchema = TSchema,
1111
> extends RedisTransform<T> {
1212
declare $$typeof: "RedisChannel";
1313
constructor(
@@ -32,7 +32,7 @@ export class RedisChannel<
3232
* Channel patterns use the `PSUBSCRIBE` command.
3333
*/
3434
export class RedisChannelPattern<
35-
T extends TSchema = TAnySchema,
35+
T extends TSchema = TSchema,
3636
> extends RedisTransform<T> {
3737
declare $$typeof: "RedisChannelPattern";
3838
constructor(

src/key.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import { Static, StaticDecode, TAnySchema, TSchema } from "@sinclair/typebox";
1+
import { Static, StaticDecode, TSchema } from "@sinclair/typebox";
22
import { Decode, Encode } from "@sinclair/typebox/value";
33
import { RedisValue } from "./command";
44
import { RedisTransform } from "./transform";
55

6-
export type TRedisHash<TValue extends TSchema = TAnySchema> = Record<
6+
export type TRedisHash<TValue extends TSchema = TSchema> = Record<
77
string,
88
TValue
99
>;
1010

1111
/**
1212
* The value type of a Redis key that points to a primitive value or a hash map.
1313
*/
14-
export type Value<T extends TSchema | TRedisHash<TSchema>> = [T] extends [
15-
TSchema,
16-
]
14+
export type Value<T extends TSchema | TRedisHash> = T extends TSchema
1715
? StaticDecode<T>
1816
: { [K in RedisField<T>]?: StaticDecode<T[K]> };
1917

@@ -28,7 +26,7 @@ export type RedisField<T extends TSchema | TRedisHash> = T extends TSchema
2826
* A Redis key that points to a primitive value or a hash map.
2927
*/
3028
export class RedisKey<
31-
T extends TSchema | TRedisHash = TAnySchema | TRedisHash,
29+
T extends TSchema | TRedisHash = TSchema | TRedisHash,
3230
> extends RedisTransform<T> {
3331
declare $$typeof: "RedisKey";
3432
constructor(
@@ -56,7 +54,7 @@ export class RedisKey<
5654
}
5755
}
5856

59-
export class RedisSet<T extends TSchema = TAnySchema> extends RedisKey<T> {
57+
export class RedisSet<T extends TSchema = TSchema> extends RedisKey<T> {
6058
declare $$typeof: "RedisKey" & { subtype: "RedisSet" };
6159
}
6260

src/modifier.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
Static,
3-
TAnySchema,
4-
TSchema,
5-
TTuple,
6-
TUndefined,
7-
} from "@sinclair/typebox";
1+
import { Static, TSchema, TTuple, TUndefined } from "@sinclair/typebox";
82
import { Encode } from "@sinclair/typebox/value";
93
import { RedisValue } from "./command";
104

@@ -50,7 +44,7 @@ export function encodeModifiers(
5044

5145
export type RedisModifierFunction<
5246
K extends string = string,
53-
T extends TSchema = TAnySchema,
47+
T extends TSchema = TSchema,
5448
> = (...args: StaticModifierArgs<T>) => RedisModifier<K>;
5549

5650
export class RedisModifier<K extends string = string> {

src/stream.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
import {
2-
TAnySchema,
3-
TObject,
4-
TRecord,
5-
TSchema,
6-
TString,
7-
} from "@sinclair/typebox";
1+
import { TObject, TRecord, TSchema, TString } from "@sinclair/typebox";
82
import { RedisValue } from "./command";
93
import { Value } from "./key";
104
import { RedisTransform } from "./transform";
115

126
/** Any valid schema for a Redis stream entry. */
13-
export type TRedisStreamEntry<TValue extends TSchema = TAnySchema> =
14-
| TObject
15-
| TRecord<TString, TValue>;
7+
export type TRedisStreamEntry =
8+
| TObject<Record<string, TSchema>>
9+
| TRecord<TString, TSchema>;
1610

1711
export type ReadStreamSpecialId = "$" | "+" | ">";
1812

src/subscriber.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TAnySchema, TSchema } from "@sinclair/typebox";
1+
import { TSchema } from "@sinclair/typebox";
22
import { castArray } from "radashi";
33
import { RedisChannel, RedisChannelPattern } from "./channel";
44
import { RedisClient } from "./client";
@@ -7,15 +7,15 @@ import { Value } from "./key";
77
import { RedisClientOptions } from "./type";
88
import { stringifyResult } from "./utils/stringify-result";
99

10-
export interface SubscribeCallback<T extends TSchema = TAnySchema> {
10+
export interface SubscribeCallback<T extends TSchema = TSchema> {
1111
(
1212
message: Value<T>,
1313
channel: string,
1414
pattern: RedisChannel<T> | RedisChannelPattern<T>,
1515
): void;
1616
}
1717

18-
type SubscriptionKey<T extends TSchema = TAnySchema> =
18+
type SubscriptionKey<T extends TSchema = TSchema> =
1919
| RedisChannel<T>
2020
| RedisChannelPattern<T>;
2121

@@ -177,7 +177,7 @@ export class Subscriber {
177177
/**
178178
* Message events are streamed from a `client.subscribe` call.
179179
*/
180-
export class MessageEvent<T extends TSchema = TAnySchema> {
180+
export class MessageEvent<T extends TSchema = TSchema> {
181181
#stream: TransformStream;
182182

183183
constructor(

src/transform.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
TAnySchema,
32
TBoolean,
43
TNumber,
54
Transform,
@@ -11,7 +10,7 @@ import { RedisValue } from "./command";
1110
import { TRedisHash, Value } from "./key";
1211

1312
export abstract class RedisTransform<
14-
T extends TSchema | TRedisHash = TAnySchema | TRedisHash,
13+
T extends TSchema | TRedisHash = TSchema | TRedisHash,
1514
> {
1615
readonly schema: T;
1716
constructor(schema: T) {

0 commit comments

Comments
 (0)