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

@uppy/core: use variadic arguments for uppy.use #4888

Merged
merged 6 commits into from
Apr 11, 2024

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Jan 23, 2024

We want TS to report an error when opts is defined as mandatory in the plugin constructor and missing from the .use call.

@aduh95 aduh95 added the 4.0 For the 4.0 major version label Jan 23, 2024
@aduh95 aduh95 requested a review from Murderlon January 23, 2024 14:25
Copy link
Contributor

github-actions bot commented Jan 23, 2024

Diff output files
diff --git a/packages/@uppy/core/lib/Uppy.js b/packages/@uppy/core/lib/Uppy.js
index 49d6503..708c152 100644
--- a/packages/@uppy/core/lib/Uppy.js
+++ b/packages/@uppy/core/lib/Uppy.js
@@ -790,13 +790,16 @@ export class Uppy {
   getID() {
     return this.opts.id;
   }
-  use(Plugin, opts) {
+  use(Plugin) {
     if (typeof Plugin !== "function") {
       const msg = `Expected a plugin class, but got ${Plugin === null ? "null" : typeof Plugin}.`
         + " Please verify that the plugin was imported and spelled correctly.";
       throw new TypeError(msg);
     }
-    const plugin = new Plugin(this, opts);
+    for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
+      args[_key2 - 1] = arguments[_key2];
+    }
+    const plugin = new Plugin(this, ...args);
     const pluginId = plugin.id;
     if (!pluginId) {
       throw new Error("Your plugin must have an id");

@Murderlon
Copy link
Member

I don't understand the benefit of this 🤔

@aduh95
Copy link
Contributor Author

aduh95 commented Jan 23, 2024

I don't understand the benefit of this 🤔

See the types error, it already shows issues with our types (where the opts argument is specified as mandatory instead of, well, optional)

packages/@uppy/core/src/Uppy.ts Outdated Show resolved Hide resolved
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
@Murderlon
Copy link
Member

Do we want to merge this into main instead?

@aduh95
Copy link
Contributor Author

aduh95 commented Jan 31, 2024

It seems safer to keep it for 4.0 only. It's not very urgent anyway, it's just a nice-to-have.

@Murderlon Murderlon mentioned this pull request Mar 19, 2024
38 tasks
@aduh95 aduh95 merged commit 09e6a0f into transloadit:4.x Apr 11, 2024
16 checks passed
@aduh95 aduh95 deleted the use-variadics branch April 11, 2024 10:13
github-actions bot added a commit that referenced this pull request Apr 11, 2024
| Package                   |      Version | Package                   |      Version |
| ------------------------- | ------------ | ------------------------- | ------------ |
| @uppy/angular             | 0.7.0-beta.2 | @uppy/instagram           | 4.0.0-beta.2 |
| @uppy/audio               | 2.0.0-beta.2 | @uppy/onedrive            | 4.0.0-beta.2 |
| @uppy/aws-s3              | 4.0.0-beta.2 | @uppy/progress-bar        | 4.0.0-beta.2 |
| @uppy/aws-s3-multipart    | 4.0.0-beta.2 | @uppy/provider-views      | 4.0.0-beta.2 |
| @uppy/box                 | 3.0.0-beta.2 | @uppy/react               | 4.0.0-beta.2 |
| @uppy/companion           | 5.0.0-beta.2 | @uppy/remote-sources      | 2.0.0-beta.2 |
| @uppy/companion-client    | 4.0.0-beta.2 | @uppy/screen-capture      | 4.0.0-beta.2 |
| @uppy/compressor          | 2.0.0-beta.2 | @uppy/status-bar          | 4.0.0-beta.2 |
| @uppy/core                | 4.0.0-beta.2 | @uppy/thumbnail-generator | 4.0.0-beta.2 |
| @uppy/dashboard           | 4.0.0-beta.2 | @uppy/transloadit         | 4.0.0-beta.2 |
| @uppy/drag-drop           | 4.0.0-beta.2 | @uppy/tus                 | 4.0.0-beta.2 |
| @uppy/drop-target         | 3.0.0-beta.2 | @uppy/unsplash            | 4.0.0-beta.2 |
| @uppy/dropbox             | 4.0.0-beta.2 | @uppy/url                 | 4.0.0-beta.2 |
| @uppy/facebook            | 4.0.0-beta.2 | @uppy/utils               | 6.0.0-beta.2 |
| @uppy/file-input          | 4.0.0-beta.2 | @uppy/webcam              | 4.0.0-beta.2 |
| @uppy/golden-retriever    | 4.0.0-beta.2 | @uppy/zoom                | 3.0.0-beta.2 |
| @uppy/google-drive        | 4.0.0-beta.2 | uppy                      | 4.0.0-beta.2 |

- @uppy/aws-s3: default to multipart depending on the size of input (Antoine du Hamel / #5076)
- @uppy/aws-s3: remove deprecated `prepareUploadParts` option (Antoine du Hamel / #5075)
- @uppy/core: use variadic arguments for `uppy.use` (Antoine du Hamel / #4888)
- @uppy/aws-s3: remove legacy plugin (Antoine du Hamel / #5070)
- @uppy/locales: do not build `dist/` folder (Merlijn Vos / #5055)
- @uppy/angular: fix Angular version requirement in peerDeps (Antoine du Hamel / #5067)
- @uppy/transloadit: remove deprecated options (Merlijn Vos / #5056)




| Package          | Version | Package          | Version |
| ---------------- | ------- | ---------------- | ------- |
| @uppy/companion  |  4.13.1 | uppy             |  3.24.1 |
| @uppy/file-input |   3.1.1 |                  |         |

- @uppy/companion: upgrade redis (Mikael Finstad / #5065)
- meta: fix `watch:*` scripts (Antoine du Hamel / #5046)
- meta: include more packages in `compare_diff` CI (Antoine du Hamel / #5044)
- @uppy/file-input: add missing export (Antoine du Hamel / #5045)
- meta: Bump express from 4.18.1 to 4.19.2 in /packages/@uppy/companion (dependabot[bot] / #5036)
- @uppy/companion: Bump express from 4.18.1 to 4.19.2 (dependabot[bot] / #5037)
Murderlon added a commit that referenced this pull request Apr 17, 2024
* 4.x: (34 commits)
  Release: uppy@3.24.3 (#5091)
  docs: add back markdown files (#5064)
  meta: fix custom provider example (#5079)
  @uppy/utils: add fetcher (#5073)
  Fix prettier
  @uppy/dashboard: add missing `x-zip-compress` archive type (#5081)
  Bump docker/metadata-action from 4 to 5 (#5086)
  Bump actions/setup-node from 3 to 4 (#5087)
  Bump docker/setup-qemu-action from 2 to 3 (#5089)
  meta: bump supercharge/redis-github-action from 1.4.0 to 1.8.0 (#5090)
  meta: bump actions/cache from 3 to 4 (#5088)
  Release: uppy@4.0.0-beta.3 (#5085)
  meta: add `dependabot.yml` to keep GHA up-to-date (#5083)
  Release: uppy@3.24.2 (#5084)
  @uppy/core: fix `setOptions` not re-rendereing plugin UI (#5082)
  Release: uppy@4.0.0-beta.2 (#5077)
  @uppy/aws-s3: default to multipart depending on the size of input (#5076)
  @uppy/aws-s3: remove deprecated `prepareUploadParts` option (#5075)
  fixup! @uppy/core: use variadic arguments for `uppy.use` (#4888)
  @uppy/core: use variadic arguments for `uppy.use` (#4888)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.0 For the 4.0 major version pending end-to-end tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants