Proposal to Change `Overrideable` Signature in VariantSchema for Optional Properties

Regarding Overrideable from experimental VariantSchema: would you accept a PR changing it's signature to:

export interface Overrideable<To, From, R = never>
  extends Schema.PropertySignature<"?:", (To & Brand<"Override">) | undefined, never, ":", From, true, R>
{}


The only difference it allowing the prop to be missing in
Type


The reason is that I'd like to be able to do the following, without type error (the last example):

class User extends Model.Class<User>('User')({
  id: Model.Generated(Schema.Int),
  name: Schema.String,
  createdAt: Model.DateTimeInsertFromDate,
}) {}

Effect
  .gen(function*() {
    const repo = yield* Model.makeRepository(User, {
      tableName: 'users',
      idColumn: 'id',
      spanPrefix: 'UserRepository',
    })

    // OK
    yield* repo.insert({
      name: 'Alice',
      createdAt: undefined,
    })

    yield* repo.insert(User.insert.make({
      name: 'Alice',
    }))

    // Error:  Property 'createdAt' is missing...
    yield* repo.insert({
      name: 'Alice',
    })
  })
Was this page helpful?