mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
[react-native-share] Syncing with flow types from repo (#29736)
The types `Options` and `MultiOptions` as well as `OpenReturn` and `ShareSingleReturn` are taken directly from7535726eb4/index.jsand have only have been transformed to interfaces. The signature of the `shareSingle` call is missing `social` in the official repo as well, but from the native code it becomes apearent that it is required:7535726eb4/ios/RNShare.m (L85-L122)
This commit is contained in:
committed by
Sheetal Nandi
parent
2ed0fa2d7e
commit
da2e09f603
49
types/react-native-share/index.d.ts
vendored
49
types/react-native-share/index.d.ts
vendored
@@ -1,32 +1,55 @@
|
||||
// Type definitions for react-native-share 1.0
|
||||
// Type definitions for react-native-share 1.1
|
||||
// Project: https://github.com/react-native-community/react-native-share#readme
|
||||
// Definitions by: Mark Nelissen <https://github.com/marknelissen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
declare namespace Share {
|
||||
function open(options: OpenOptions): Promise<any>;
|
||||
function shareSingle(options: ShareSingleOptions): Promise<any>;
|
||||
function open(options: Options | MultipleOptions): Promise<OpenReturn>;
|
||||
function shareSingle(
|
||||
options: Options & { social: SupportedSocialApps }
|
||||
): Promise<ShareSingleReturn>;
|
||||
}
|
||||
|
||||
export default Share;
|
||||
|
||||
interface OpenOptions {
|
||||
url: string;
|
||||
type?: string;
|
||||
interface OpenReturn {
|
||||
app?: string;
|
||||
dismissedAction?: boolean;
|
||||
}
|
||||
|
||||
interface ShareSingleReturn {
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
url: string;
|
||||
urls?: string[];
|
||||
type?: string;
|
||||
message?: string;
|
||||
title?: string;
|
||||
subject?: string;
|
||||
excludedActivityTypes?: string;
|
||||
showAppsToview?: boolean;
|
||||
failOnCancel?: boolean;
|
||||
showAppsToView?: boolean;
|
||||
}
|
||||
|
||||
interface ShareSingleOptions {
|
||||
url: string;
|
||||
interface MultipleOptions {
|
||||
url?: string;
|
||||
urls: string[];
|
||||
type?: string;
|
||||
message: string;
|
||||
message?: string;
|
||||
title?: string;
|
||||
subject?: string;
|
||||
social: SupportedSocialApps;
|
||||
excludedActivityTypes?: string;
|
||||
failOnCancel?: boolean;
|
||||
showAppsToView?: boolean;
|
||||
}
|
||||
|
||||
type SupportedSocialApps = 'twitter' | 'facebook' | 'whatsapp' | 'googleplus' | 'email';
|
||||
type SupportedSocialApps =
|
||||
| "facebook"
|
||||
| "pagesmanager"
|
||||
| "twitter"
|
||||
| "whatsapp"
|
||||
| "instagram"
|
||||
| "googleplus"
|
||||
| "email";
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
import Share from 'react-native-share';
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
// $ExpectType Promise<OpenReturn>
|
||||
Share.open({
|
||||
url: '',
|
||||
message: '',
|
||||
});
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
// $ExpectType Promise<OpenReturn>
|
||||
Share.open({
|
||||
title: '',
|
||||
message: '',
|
||||
urls: [],
|
||||
});
|
||||
|
||||
// $ExpectType Promise<OpenReturn>
|
||||
Share.open({
|
||||
url: '',
|
||||
type: '',
|
||||
@@ -14,17 +21,17 @@ Share.open({
|
||||
title: '',
|
||||
subject: '',
|
||||
excludedActivityTypes: '',
|
||||
showAppsToview: true,
|
||||
showAppsToView: true,
|
||||
});
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
// $ExpectType Promise<ShareSingleReturn>
|
||||
Share.shareSingle({
|
||||
url: '',
|
||||
message: '',
|
||||
social: 'facebook',
|
||||
});
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
// $ExpectType Promise<ShareSingleReturn>
|
||||
Share.shareSingle({
|
||||
url: '',
|
||||
type: '',
|
||||
|
||||
Reference in New Issue
Block a user