react-native-fs
react-native-fs copied to clipboard
`downloadFile`: Make type of `begin` required when `progress` is used
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
for the project I'm working on.
Related to: https://github.com/itinance/react-native-fs/issues/760
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-fs/index.d.ts b/node_modules/react-native-fs/index.d.ts
index da3fa7d..aa99cd0 100644
--- a/node_modules/react-native-fs/index.d.ts
+++ b/node_modules/react-native-fs/index.d.ts
@@ -41,13 +41,17 @@ type DownloadFileOptions = {
cacheable?: boolean // Whether the download can be stored in the shared NSURLCache (iOS only)
progressInterval?: number
progressDivider?: number
- begin?: (res: DownloadBeginCallbackResult) => void
- progress?: (res: DownloadProgressCallbackResult) => void
resumable?: () => void // only supported on iOS yet
connectionTimeout?: number // only supported on Android yet
readTimeout?: number // supported on Android and iOS
backgroundTimeout?: number // Maximum time (in milliseconds) to download an entire resource (iOS only, useful for timing out background downloads)
-}
+} & ({
+ begin: (res: DownloadBeginCallbackResult) => void;
+ progress: (res: DownloadProgressCallbackResult) => void;
+ } | {
+ begin?: (res: DownloadBeginCallbackResult) => void;
+ progress?: undefined;
+ })
type DownloadBeginCallbackResult = {
jobId: number // The download job ID, required if one wishes to cancel the download. See `stopDownload`.
This issue body was partially generated by patch-package.