Ensuring a Struct conforms to a certain shape in TypeScript can be tricky, especially when dealin...

How can I make sure a Struct conforms to a certain shape? Getting type errors with this:
import { Schema as S } from 'effect';

const a = S.Struct({
  variableKeyNotOptional: S.String,
  alwaysDefinedOptional: S.String.pipe(S.optional),
  alwaysDefinedNotOptional: S.String,
});

type B = S.Struct<
  Record<string, S.Schema.Any> & {
    alwaysDefinedOptional: S.optional<S.Schema.Any>['from']
    alwaysDefinedNotOptional: S.Schema.Any;
  }
>;

const b = a satisfies B; // error

Or is this a limitation to optional?
Was this page helpful?