Issue with Default Values in Nested Structs in Effect Typescript Library

Hey, I am trying to understand why a property with a default value can be omitted at construction (as I expect) when it is a first level prop of a struct ; but is flagged as required when it is a nested prop of a struct.

e.g:

const Foo = Schema.Struct({
  bar: Schema.optionalWith(Schema.String, {
    default: () => "baz",
  }),
});
// all good
Foo.make({});

const FooWithNesting = Schema.Struct({
  bar: Schema.Struct({
    baz: Schema.optionalWith(Schema.String, {
      default: () => "buzz",
    }),
  }),
});
// Property 'baz' is missing in type '{}' but required in type '{ readonly baz: string; }'.ts(2741)
FooWithNesting.make({
  bar: {},
});
Was this page helpful?