Fix FileReader.result TypeScript type to include null#56380
Fix FileReader.result TypeScript type to include null#56380Nedunchezhiyan-M wants to merge 1 commit intofacebook:mainfrom
Conversation
The TypeScript declaration for FileReader.result is typed as string | ArrayBuffer, but the actual implementation returns null when no read operation has completed or when the read was aborted. This matches the WHATWG FileReader spec where result is null in the EMPTY and LOADING states.
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
655d038 to
d5e7e3e
Compare
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
The TypeScript declaration for
FileReader.resultis typed asstring | ArrayBuffer, but the implementation (inLibraries/Blob/FileReader.js) returns?ReaderResultwhich can benull. Per the WHATWG FileReader spec,resultisnullin theEMPTYandLOADINGstates.This causes type mismatches when users check for null before using the result.
Changelog:
[GENERAL] [FIXED] - Fix FileReader.result TypeScript type to include null, matching the spec and implementation
Test Plan
FileReader.resulttyped asstring | ArrayBuffer | nullmatches the WHATWG specLibraries/Blob/FileReader.js:178which returns?ReaderResult