Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose errors from entrypoint #1242

Merged
merged 5 commits into from
Nov 22, 2023

Conversation

aldy505
Copy link
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
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
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
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
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
14 checks passed
@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