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

fix(types): fix file blob type for uploadFile and uploadFiles #950

Merged
merged 12 commits into from
May 31, 2020
Merged

fix(types): fix file blob type for uploadFile and uploadFiles #950

merged 12 commits into from
May 31, 2020

Conversation

rscotten
Copy link
Contributor

@rscotten rscotten commented May 31, 2020

Description

This PR fixes a type issue in the PR #936 in which the uploadFile() function for file storage uploading was allowed to take a Blob type. Typing the file option to have File | Blob broke the type checking for the UploadFileOptions type definition, and my solution was to make the type generic with Conditional Types.

Check List

If not relevant to pull request, check off as complete

  • All tests passing
  • Docs updated with any changes or examples if applicable
  • Added tests to ensure new feature(s) work properly

Relevant Issues

#936

@codecov
Copy link

codecov bot commented May 31, 2020

Codecov Report

Merging #950 into master will not change coverage.
The diff coverage is 25.00%.

@@           Coverage Diff           @@
##           master     #950   +/-   ##
=======================================
  Coverage   88.33%   88.33%           
=======================================
  Files          29       29           
  Lines         797      797           
=======================================
  Hits          704      704           
  Misses         93       93           

@@ -10,6 +10,8 @@ import { Dispatch } from 'redux'
*/
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

type FileOrBlob<T> = T extends File ? File : Blob
Copy link
Owner

Choose a reason for hiding this comment

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

Nice!

@prescottprue prescottprue changed the base branch from master to v3.5.1 May 31, 2020 20:42
@prescottprue prescottprue changed the title Fix file blob type fix(types): fix file blob type for uploadFile and uploadFiles May 31, 2020
@prescottprue
Copy link
Owner

Thanks for getting this in so quickly!

@prescottprue prescottprue merged commit 3ef032d into prescottprue:v3.5.1 May 31, 2020
@prescottprue prescottprue mentioned this pull request May 31, 2020
3 tasks
prescottprue added a commit that referenced this pull request May 31, 2020
* fix(types): fix file blob type for uploadFile and uploadFiles (#950) - @rscotten
* chore(docs): cleanup minor typo in useFirestoreConnect.md (#949) - @gregfenton
* chore(tests): fix typo "merge" to "merges" in reducer test file (#948) - @yukimurasawa
* chore(docs): remove note about populate not being supported in firestore (#915)
* chore(examples): clarify explanation in `watchEvent` example snippet (#910)
* chore(docs): add correct syntax highlighting to example in firestore.md
* chore(build): improve lint command
* chore(build): only require jsdoc comments in source

Co-authored-by: Richard Scotten <[email protected]>
Co-authored-by: gregfenton <[email protected]>
Co-authored-by: yukimurasawa <[email protected]>
Co-authored-by: yukimurasawa <[email protected]>
@rscotten rscotten deleted the fix-file-blob-type branch May 31, 2020 21:29
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.

2 participants