minio / minio-js

MinIO Client SDK for Javascript
https://docs.min.io/docs/javascript-client-quickstart-guide.html
Apache License 2.0
920 stars 271 forks source link

Incorrect return type for `TypedClient.getBucketVersioning()` #1296

Closed SleepyLeslie closed 2 months ago

SleepyLeslie commented 3 months ago

The function here definitely returns something, so its return type shouldn't be Promise<void>.

https://github.com/minio/minio-js/blob/86339689677b8e316984f94dfa96f741776fdd8f/src/internal/client.ts#L2095

Here is my suggestion. I didn't look very closely so I might have missed some fields.

type VersioningStatus = {
  "Status": "Enabled" | "Suspended",
  "ExcludeFolders": boolean,
  "ExcludedPrefixes": {"Prefix": string}[]
}

getBucketVersioning(bucketName: string): Promise<"" | VersioningStatus>;

Note that it currently returns an empty string when versioning has never been toggled on. It might be a good idea to return {Status: "Disabled"} instead.

prakashsvmx commented 3 months ago

Yes. We will update it. Thank you for the feedback.

SleepyLeslie commented 2 months ago

Thanks @prakashsvmx for the fix. But the new typing still doesn't address the possible return value '' when versioning has never been enabled. Will that be fixed?

fflorent commented 2 months ago

Thanks @prakashsvmx for the fix. But the new typing still doesn't address the possible return value '' when versioning has never been enabled. Will that be fixed?

Opened https://github.com/minio/minio-js/issues/1303 to track your question.