Skip to content

Commit dc67c76

Browse files
authored
fix: add listener types (#246)
* Fix types for addListener Update the types to account for the following 1: Can be called with `null` to include all uploads 2: Returns an `EventSubscription` instead of void Adds "@types/react-native": "^0.64.0" as a devDependency to get the correct type for `EventSubscription` * Fix broken link to CONTRIBUTING.MD
1 parent ec141a2 commit dc67c76

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ Why should I use this file uploader instead of others that I've Googled like [re
313313

314314
# Contributing
315315

316-
See [CONTRIBUTING.md](https://github.com/Vydia/react-native-background-upload/CONTRIBUTING.md).
316+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
317317

318318
# Common Issues
319319

index.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
declare module "react-native-background-upload" {
2+
import type { EventSubscription } from 'react-native';
23

34
export interface EventData {
45
id: string;
@@ -112,10 +113,10 @@ declare module "react-native-background-upload" {
112113

113114
export default class Upload {
114115
static startUpload(options: UploadOptions | MultipartUploadOptions): Promise<uploadId>
115-
static addListener(event: 'progress', uploadId: uploadId, callback: (data: ProgressData ) => void): void
116-
static addListener(event: 'error', uploadId: uploadId, callback: (data: ErrorData) => void): void
117-
static addListener(event: 'completed', uploadId: uploadId, callback: (data: CompletedData) => void): void
118-
static addListener(event: 'cancelled', uploadId: uploadId, callback: (data: EventData) => void): void
116+
static addListener(event: 'progress', uploadId: uploadId | null, callback: (data: ProgressData ) => void): EventSubscription
117+
static addListener(event: 'error', uploadId: uploadId | null, callback: (data: ErrorData) => void): EventSubscription
118+
static addListener(event: 'completed', uploadId: uploadId | null, callback: (data: CompletedData) => void): EventSubscription
119+
static addListener(event: 'cancelled', uploadId: uploadId | null, callback: (data: EventData) => void): EventSubscription
119120
static getFileInfo(path: string): Promise<FileInfo>
120121
static cancelUpload(uploadId: uploadId): Promise<boolean>
121122
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@semantic-release/github": "^5.5.5",
3939
"@semantic-release/npm": "^5.3.4",
4040
"@semantic-release/release-notes-generator": "^7.3.5",
41+
"@types/react-native": "^0.64.0",
4142
"eslint": "^6.8.0",
4243
"husky": "^4.2.3",
4344
"lint-staged": "^10.0.8",

yarn.lock

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,37 @@
381381
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
382382
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==
383383

384+
"@types/prop-types@*":
385+
version "15.7.3"
386+
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
387+
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
388+
389+
"@types/react-native@^0.64.0":
390+
version "0.64.4"
391+
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.64.4.tgz#9f11bef7dd5520801884829c73b19d75aa42e73c"
392+
integrity sha512-VqnlmadGkD5usREvnuyVpWDS1W8f6cCz6MP5fZdgONsaZ9/Ijfb9Iq9MZ5O3bnW1OyJixDX9HtSp3COsFSLD8Q==
393+
dependencies:
394+
"@types/react" "*"
395+
396+
"@types/react@*":
397+
version "17.0.3"
398+
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.3.tgz#ba6e215368501ac3826951eef2904574c262cc79"
399+
integrity sha512-wYOUxIgs2HZZ0ACNiIayItyluADNbONl7kt8lkLjVK8IitMH5QMyAh75Fwhmo37r1m7L2JaFj03sIfxBVDvRAg==
400+
dependencies:
401+
"@types/prop-types" "*"
402+
"@types/scheduler" "*"
403+
csstype "^3.0.2"
404+
384405
"@types/retry@^0.12.0":
385406
version "0.12.0"
386407
resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.0.tgz#2b35eccfcee7d38cd72ad99232fbd58bffb3c84d"
387408
integrity sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==
388409

410+
"@types/scheduler@*":
411+
version "0.16.1"
412+
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.1.tgz#18845205e86ff0038517aab7a18a62a6b9f71275"
413+
integrity sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==
414+
389415
"@typescript-eslint/eslint-plugin@^1.5.0":
390416
version "1.13.0"
391417
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.13.0.tgz#22fed9b16ddfeb402fd7bcde56307820f6ebc49f"
@@ -1232,6 +1258,11 @@ crypto-random-string@^1.0.0:
12321258
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e"
12331259
integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=
12341260

1261+
csstype@^3.0.2:
1262+
version "3.0.8"
1263+
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.8.tgz#d2266a792729fb227cd216fb572f43728e1ad340"
1264+
integrity sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==
1265+
12351266
currently-unhandled@^0.4.1:
12361267
version "0.4.1"
12371268
resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea"

0 commit comments

Comments
 (0)