Effect CommunityEC
Effect Community3y ago
8 replies
attila

Transforming `S.record(S.string, S.unknown)` to `S.struct({ a: S.string })` using `S.transform`

Is it possible to go from S.record(S.string, S.unknown) to S.struct({ a: S.string }) other than:
S.transform(
  S.record(S.string, S.unknown),
  S.struct({ a: S.string }),
  (a) => a as { a: string },
  identity,
)


S.record(S.string, S.unknown).pipe(S.compose(S.struct({ a: S.string }))) would be ideal but it doesn't type check.
Was this page helpful?