Fix TypeScript types for the addListener method for two scenarios:
1: addListener supports a null uploadId to include all uploads.
2: return type is EventSubscription not void
Adds "@types/react-native": "^0.64.x" as a devDependency to get correct types for EventSubscription.
Examples of where these incorrect types causes issues:
1: Want to call addListener with null but get a typescript error
// TS error: Argument of type 'null' is not assignable to parameter of type 'string'.
Upload.addListener('cancelled', null, () => {})
2: In an instance where a reference to the returned EventSubscription is desired a unsafe typecast workaround is required to get to the correct typing.
Current situation:
const subscription = (Upload.addListener('progress', uploadId, (response) => {
...
}) as unknown) as EventSubscription;
Summary
Fix TypeScript types for the
addListener
method for two scenarios:1:
addListener
supports a nulluploadId
to include all uploads. 2: return type isEventSubscription
not voidAdds
"@types/react-native": "^0.64.x"
as a devDependency to get correct types forEventSubscription
.Examples of where these incorrect types causes issues:
1: Want to call addListener with
null
but get a typescript error2: In an instance where a reference to the returned
EventSubscription
is desired a unsafe typecast workaround is required to get to the correct typing. Current situation:After fix:
Also fixes link to the contributing doc from readme.
Test Plan
Verify
addListener
works as expected with updated typesCompatibility
Checklist
README.md