diff --git a/src/tson.ts b/src/tson.ts index 9a5d92cb..e792f4ed 100644 --- a/src/tson.ts +++ b/src/tson.ts @@ -77,22 +77,17 @@ export function tsonStringifier(opts: TsonOptions): TsonStringifyFn { export function tsonSerializer(opts: TsonOptions): TsonSerializeFn { const handlers = (() => { - // warmup the type handlers const types = opts.types.map((handler) => { - const key = handler.key as TsonTypeHandlerKey | undefined; - const serialize = handler.serialize; - type Serializer = ( value: unknown, nonce: TsonNonce, walk: WalkFn, ) => TsonSerializedValue; - const $serialize: Serializer = serialize + const $serialize: Serializer = handler.serialize ? (value, nonce, walk): TsonTuple => [ - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - key!, - walk(serialize(value)), + handler.key as TsonTypeHandlerKey, + walk(handler.serialize(value)), nonce, ] : (value, _nonce, walk) => walk(value); diff --git a/src/types.ts b/src/types.ts index e9b1049d..a03940f9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -36,11 +36,6 @@ export interface TsonTransformerNone { */ key?: never; serialize?: never; - - /** - * Won't be deserialized nor serialized - */ - transform: false; } export interface TsonTransformerSerializeDeserialize< TValue, @@ -59,10 +54,6 @@ export interface TsonTransformerSerializeDeserialize< * JSON-serializable value */ serialize: (v: TValue) => TSerializedType; - /** - * Use a transformer to serialize and deserialize the value? - */ - transform?: true; } export type TsonTransformer =