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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
@uppy/provider-views: migrate to TS #4919
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Diff output files
|
aduh95
reviewed
Feb 22, 2024
aduh95
reviewed
Feb 22, 2024
aduh95
reviewed
Feb 22, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
packages/@uppy/provider-views/src/ProviderView/ProviderView.tsx
Outdated
Show resolved
Hide resolved
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
aduh95
reviewed
Feb 23, 2024
* main: @uppy/file-input: refactor to TypeScript (#4954)
No dependency changes detected. Learn more about Socket for GitHub 鈫楋笌 馃憤 No dependency changes detected in pull request |
aduh95
reviewed
Feb 26, 2024
aduh95
reviewed
Feb 26, 2024
aduh95
reviewed
Feb 26, 2024
aduh95
reviewed
Feb 27, 2024
This reverts commit 7e1b8a4.
aduh95
approved these changes
Feb 27, 2024
Merged
github-actions bot
added a commit
that referenced
this pull request
Feb 28, 2024
| Package | Version | Package | Version | | ---------------------- | ------- | ---------------------- | ------- | | @uppy/box | 2.2.1 | @uppy/onedrive | 3.2.1 | | @uppy/companion-client | 3.7.4 | @uppy/progress-bar | 3.1.0 | | @uppy/core | 3.9.3 | @uppy/provider-views | 3.10.0 | | @uppy/dashboard | 3.7.5 | @uppy/status-bar | 3.3.0 | | @uppy/file-input | 3.1.0 | @uppy/utils | 5.7.4 | | @uppy/form | 3.2.0 | @uppy/xhr-upload | 3.6.4 | | @uppy/image-editor | 2.4.4 | uppy | 3.23.0 | | @uppy/informer | 3.1.0 | | | - @uppy/form: migrate to TS (Merlijn Vos / #4937) - @uppy/box: fetchPreAuthToken in box too (Mikael Finstad / #4969) - @uppy/progress-bar: refactor to TypeScript (Mikael Finstad / #4921) - @uppy/onedrive: fix custom oauth2 credentials for onedrive (Mikael Finstad / #4968) - @uppy/companion-client,@uppy/utils,@uppy/xhr-upload: improvements for #4922 (Mikael Finstad / #4960) - @uppy/utils: fix various type issues (Mikael Finstad / #4958) - @uppy/provider-views: migrate to TS (Merlijn Vos / #4919) - @uppy/utils: simplify `findDOMElements` (Mikael Finstad / #4957) - @uppy/xhr-upload: fix getResponseData regression (Merlijn Vos / #4964) - @uppy/informer: migrate to TS (Merlijn Vos / #4967) - @uppy/core: remove unused import (Antoine du Hamel / #4972) - @uppy/image-editor: remove default target (Merlijn Vos / #4966) - @uppy/angular: Build fixes (Mikael Finstad / #4959) - meta: Fix flaky e2e test (Murderlon) - meta: fix e2e flake (Mikael Finstad / #4961) - meta: add support for `Fragment` short syntax (Antoine du Hamel / #4953) - @uppy/file-input: refactor to TypeScript (Antoine du Hamel / #4954)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This one was painfully tricky.
Separated plugins
provider-views
andcompanion-client
always belong together and operate on each other, but they are separate plugins, and not direct dependencies of each other. Most code just references code of the other plugin, but we can't use types from the other plugin as we don't have access to it.To prevent incorrect types or introducing a breaking change by merging the packages, I deemed the best approach to duplicate some of the types into
utils
(CompanionClientProvider
,CompanionFile
) and createUnknownProviderPlugin
andUnknownSearchProviderPlugin
incore
.It's duplicate, but type safe! For instance, Inside
companion-client
theProvider
classimplements CompanionClientProvider
. Any mismatch in types will be caught on either side. TheUnknownProviderPlugin
type is actually the single source of truth, as it's imported inProvider
and used forgetPlugin
.Faulty inheritance
Another place of needless complexity, is the
View
base class, which is used forProviderView
andSearchProviderView
(that was my abstraction 馃槵馃敨 ).View
sets theprovider
property on the class, but that's different forProviderView
andSearchProviderView
. Some type trickery is needed for this.The "tag file"
In Uppy we have
UppyFile
,CompanionFile
(introduced here), andTagfile
. The last one no one understands why it's there (as seen from an existing todo comment). Having this third type going around the codebase started posing problems, as nowRestricter
and some methods onUppy
now needed to deal with this.For
Restricter
I solved this with yet another type:ValidateableFile
. There had to be a type to indicate the minimal amount of properties present in order to validate it, then all file types can have overlap with it. UnfortunatelyRestrictionError
has to maintainUppyFile
, so only inRestricter
a cast fromValidateableFile
toUppyFile
is required to please TS. Feel free to try locally to improve this.In conclusion, this plugin is screaming to be rewritten.