Handling function overloading in TypeScript, especially when exporting types or classes, can some...

is it possible to fix service level function type exporting in case of using overloading?
here is an example:
import { type GetObjectCommandInput, type GetObjectCommandOutput } from "@aws-sdk/client-s3";
import type { HttpHandlerOptions, RequestPresigningArguments } from "@aws-sdk/types";
import { Effect } from "effect";
import { InvalidObjectStateError, NoSuchKeyError, S3ServiceError, SdkError } from "./Errors";

export interface S3Service$ {
  readonly _: unique symbol;

  getObject(
    args: GetObjectCommandInput,
    options?: { readonly presigned?: false } & HttpHandlerOptions,
  ): Effect.Effect<GetObjectCommandOutput, SdkError | InvalidObjectStateError | NoSuchKeyError>;
  getObject(
    args: GetObjectCommandInput,
    options?: { readonly presigned: true } & RequestPresigningArguments,
  ): Effect.Effect<string, SdkError | S3ServiceError>;
}

export class S3Service extends Effect.Tag("@effect-aws/client-s3/S3Service")<S3Service, S3Service$>() {
  //   declare static readonly getObject: S3Service$["getObject"];
}

// ...........

S3Service.getObject({ Bucket: "test", Key: "test" }, { presigned: true });


the S3Service.getObject is not visible for typescript in this case, so I have to explicitly redeclare it in the service class to make it work
Was this page helpful?