Effect CommunityEC
Effect Community2y ago
8 replies
nickrttn

`someKey` Not Optional in Schema Type if default is provided

Why, if I have the following schema, is someKey not optional in type T? I would expect this to be true: Schema.decodeUnknownSync(MySchema)({}) === { someKey: 'some default' } // true

import { Schema } from '@effect/schema';

const MySchema = Schema.Struct({
  someKey: Schema.optional(Schema.String, { default: () => 'some default' }),
});

type T = Schema.Schema.Type<typeof MySchema>;
Was this page helpful?