Skip to content

feat: expose errors from entrypoint#1242

Merged
prakashsvmx merged 5 commits intominio:masterfrom
aldy505:feat/expose-errors
Nov 22, 2023
Merged

feat: expose errors from entrypoint#1242
prakashsvmx merged 5 commits intominio:masterfrom
aldy505:feat/expose-errors

Conversation

@aldy505
Copy link
Copy Markdown
Contributor

@aldy505 aldy505 commented Nov 20, 2023

Closes #1171

I originally wanted to expose it via package.json, so that we'd have something like:

  "exports": {
    ".": {
      "types": "./dist/main/minio.d.ts",
      "require": "./dist/main/minio.js",
      "default": "./dist/esm/minio.mjs"
    },
    "./errors": {
      "types": "./dist/main/errors.d.ts",
      "require": "./dist/main/errors.js",
      "default": "./dist/esm/errors.mjs"
    },
    "./dist/main/internal/*": null,
    "./dist/main/*": {
      "types": "./dist/main/*",
      "require": "./dist/main/*",
      "default": null
    },
    "./dist/esm/internal/*": null,
    "./dist/esm/*": {
      "types": "./dist/esm/*",
      "import": "./dist/esm/*",
      "default": null
    },
    "./package.json": "./package.json"
  },

But that would mean two different lines on every MinIO import usage.

import * as Minio from "minio";
import { S3Error } from "minio/errors";

Instead of just

import * as Minio from "minio";

// Then use it later on as
try {
  // do stuff
} catch (error: unknown) {
  if (error instanceof Minio.S3Error) {
    // assert stuff
  }
}

Copy link
Copy Markdown
Contributor

@trim21 trim21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should also add exporting in minio.d.ts

@aldy505
Copy link
Copy Markdown
Contributor Author

aldy505 commented Nov 20, 2023

I just realized that we're doing export * from 'notification.ts', yet it's not defined on the declaration file either. Should that be handled?

@aldy505 aldy505 requested a review from trim21 November 20, 2023 11:37
@trim21
Copy link
Copy Markdown
Contributor

trim21 commented Nov 20, 2023

notification.js is a js file and can't be exported in minio.d.ts, I have a working-in-progress PR for this #1226.

and it has been declared, instead of separated file but directly in minio.d.ts file.

Copy link
Copy Markdown
Contributor

@trim21 trim21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@prakashsvmx prakashsvmx merged commit cab0fe5 into minio:master Nov 22, 2023
@aldy505 aldy505 deleted the feat/expose-errors branch November 22, 2023 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add error classes in export of the package

3 participants