Effect CommunityEC
Effect Community3y ago
4 replies
imagio

Effect-schema-class: Issue with Optional Properties

@Tim Smart I'm just getting started looking at effect-schema-class, it seems like maybe optional properties are broken? For example:

export class MembershipModel extends SchemaClass({
    userId: S.string,
    accepted: S.boolean,
    invitedById: S.string,
    joinedAt: pipe(S.number, S.optional).withDefault(() => Date.now()),
    activeAt: pipe(S.number, S.optional).withDefault(() => 0),
}) {}

const foo = new MembershipModel({
    userId: "foo",
    accepted: true,
    invitedById: "bar",
})


results in

Argument of type '{ userId: string; accepted: true; invitedById: string; }' is not assignable to parameter of type '{ readonly userId: string; readonly accepted: boolean; readonly invitedById: string; readonly joinedAt: number; readonly activeAt: number; }'.

  Type '{ userId: string; accepted: true; invitedById: string; }' is missing the following properties from type '{ readonly userId: string; readonly accepted: boolean; readonly invitedById: string; readonly joinedAt: number; readonly activeAt: number; }': joinedAt, activeAtts(2345)
Was this page helpful?