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: fix some types #4332

Merged
merged 1 commit into from Feb 27, 2023
Merged

@uppy/core: fix some types #4332

merged 1 commit into from Feb 27, 2023

Conversation

aduh95
Copy link
Member

@aduh95 aduh95 commented Feb 23, 2023

Fixes: #3618

Comment on lines 127 to +129
| typeof BasePlugin
| typeof UIPlugin
| BasePlugin
Copy link
Member

Choose a reason for hiding this comment

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

We have typeof BasePlugin but also BasePlugin? Should be perhaps be InstanceOf<typeof BasePlugin>?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not familiar with the nuances of that, I'd need to look it up. But basically what we were missing was that the user can either pass the plugin class, or a plugin instance. Can InstanceOf<> target both at once?

Copy link
Member

Choose a reason for hiding this comment

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

Theoretically I think it would satisfy both, but technically it means the initialized instance. Regardless, if we want to type the instance, there should at least be a InstanceOf type.

Copy link
Member Author

Choose a reason for hiding this comment

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

BasePlugin would target an instance of BasePlugin (or any other subclass of BasePlugin), why do we need the InstanceOf?

Copy link
Member Author

Choose a reason for hiding this comment

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

Cannot find name 'InstanceOf', also it doesn't seem to exist, or what am I missing?

Copy link
Member

Choose a reason for hiding this comment

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

Can we try to replace both with this? I think it should be stricter than current attempt

https://www.typescriptlang.org/docs/handbook/utility-types.html#instancetypetype

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for checking. I remembered this helped me with typing tus-node-server, perhaps I remember wrong. This is okay then!

Copy link
Member Author

@aduh95 aduh95 Feb 27, 2023

Choose a reason for hiding this comment

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

That being said, typeof doesn't seem to behave as we are trying to make it behave: https://www.typescriptlang.org/play?#code/MYGwhgzhAEDC0G8BQ1oA9oF5oAYDcK0AnlrgQL5JKiQwAi0ApmgC6MB2AJjPApdeCjQAookKoM2AIwFUqEtgDMFFEhZEADo2gAVHKXVaA9gDM40AD7RDjU9DprN2nVINO7sAjd0AmN8bM6AiRkYCN2CBZrRkicAC5dfWxYanDI6MipBL1SBzCIqLZIn2ykkSR+ZDlofPSilnjdV2TUgoyWLKbc1rqYlhLE0mEKqiq5WsK+xp0-bon2zpnSFPn6gZzsYf4kIA

EDIT: turns out TS applies the "if it walk like a duck and quack like a duck, …" principle, so the above is expected.

@aduh95 aduh95 merged commit cb5c0de into transloadit:main Feb 27, 2023
@aduh95 aduh95 deleted the core-types branch February 27, 2023 12:33
@github-actions github-actions bot mentioned this pull request Mar 7, 2023
github-actions bot added a commit that referenced this pull request Mar 7, 2023
| Package              | Version | Package              | Version |
| -------------------- | ------- | -------------------- | ------- |
| @uppy/audio          |   1.1.0 | @uppy/onedrive       |   3.1.0 |
| @uppy/box            |   2.1.0 | @uppy/provider-views |   3.1.0 |
| @uppy/core           |   3.1.0 | @uppy/screen-capture |   3.1.0 |
| @uppy/dashboard      |   3.3.0 | @uppy/unsplash       |   3.1.0 |
| @uppy/dropbox        |   3.1.0 | @uppy/url            |   3.2.0 |
| @uppy/facebook       |   3.1.0 | @uppy/utils          |   5.1.3 |
| @uppy/google-drive   |   3.1.0 | @uppy/webcam         |   3.3.0 |
| @uppy/image-editor   |   2.1.1 | @uppy/zoom           |   2.1.0 |
| @uppy/instagram      |   3.1.0 | uppy                 |   3.6.0 |
| @uppy/locales        |   3.0.7 |                      |         |

- @uppy/locales: add missing entries after build (Murderlon)
- @uppy/dashboard: update provider icon style (Alexander Zaytsev / #4345)
- @uppy/core: fix uppy.resetProgress() (Artur Paikin / #4337)
- @uppy/core: fix some types (Antoine du Hamel / #4332)
- @uppy/core: Fixed type of State.info to match reality being an array of info objects (Marc Bennewitz / #4321)
- @uppy/image-editor: Fix TypeScript error in image-editor types (Matthias Kunnen / #4334)
- meta: improve `importFromUploadURLs` docs (Mikael Finstad / #4323)
- @uppy/utils: workaround chrome crash (Mikael Finstad / #4310)
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.

Typescript: Argument of type 'this' is not assignable to parameter of type 'typeof UIPlugin'
2 participants