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

Typescript patches #255

Merged
merged 5 commits into from
Mar 31, 2021
Merged

Conversation

johnnaegle
Copy link
Contributor

Description

PR for #253

This fixes a few of issues with the type definitions in this project. I inferred most of these fixes by debugging and reverse engineering the types.

A couple notable ones:

  • FileInfo: the uuid/mimeType can both be null for new files when the validator is invoked
  • The dialog API fileColl typing is wrong. In general with the existing type defs it looks like there is confusing between what is a FileInfo and what is a FileUpload.
  • The FileGroup type was missing.

Without the types being exported, its hard to write typed functions, so FileGroup is now exported

Checklist

Reverse-engineer and fix type type problems:

DialogApi:
  fileColl: FileInfo[] => CollectionOfPromises<FileInfo>;

The fileColl property is not an array of file infos.  It is a collection of promises that resolve to file infos when they are uploaded.

This is initialized here:
  https://github.com/uploadcare/uploadcare-widget/blob/1b33ac45986bffeb311bdb1293170b3925932aa1/src/widget/dialog.js#L265

```javascript
    // files collection
    this.files = new CollectionOfPromises(files)
```

Second, FileUpload is cancelable.  This is added in uploadcare-widget:
https://github.com/uploadcare/uploadcare-widget/blob/1b33ac45986bffeb311bdb1293170b3925932aa1/src/files/base.js#L230

```javascript
api.cancel = this.__cancel.bind(this)
```
FileInfo: the uuid/mimeType can both be null for new files when the validator is invoked
…a FileGruop. The difference being a promise that resolves to a FileGroup vs a FileGroup
@nd0ut nd0ut merged commit 438b9e4 into uploadcare:master Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants