Function Overloading Issue with Optional Parameter in Dual Function Definition

hi, i am creating a dual fucntion, where there is optional parameter, so below function will look like fromModel(options?)(profileSkill) or fromModel(profileSkill, options?), now profile is that, i have to define the options paramater else it gives the error, fromModel(profileSkill, undefined) works, fromModel()(profileSkill) works, fromModel(undefined)(profileSkill) works, but fromModel(profileSkill) does not work, gives runtime error
static fromModel: FunctionUtility.Dual<
  [options?: ProfileSkillRecordFromModelOptions],
  [self: ProfileSkill],
  Effect.Effect<ProfileSkillRecord, InternalServerException | SchemaParseException>
> = Function.dual(
  2,
  (
    self: ProfileSkill,
    options?: ProfileSkillRecordFromModelOptions
  ): Effect.Effect<ProfileSkillRecord, InternalServerException | SchemaParseException> => {
    return Effect.gen(function* () {
      const data = yield* ProfileSkillRecord.modelToSchemaEncodedData(options)(self)
      return yield* Effect.suspend(() =>
        Schema.decode(ProfileSkillRecord)(data).pipe(
          parseErrorToSchemaParseException('Unexpected error while decoding the profile skill record.', { data })
        )
      ).pipe(
        withTelemetrySpan('decode_profile_skill_record', {
          attributes: {
            profile_skill_uid: self.uid,
          },
        })
      )
    }).pipe(
      withTelemetrySpan('make_profile_skill_record', {
        attributes: {
          profile_skill_uid: self.uid,
        },
      })
    )
  }
)
Was this page helpful?