diff --git a/types/react-native-app-link/index.d.ts b/types/react-native-app-link/index.d.ts new file mode 100644 index 0000000000..b6b0c9750e --- /dev/null +++ b/types/react-native-app-link/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for react-native-app-link 1.0 +// Project: https://github.com/datwheat/react-native-app-link#readme +// Definitions by: John Wright +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface AppLinkOptions { + readonly appName: string; + readonly appStoreId: number; + readonly appStoreLocale: string; + readonly playStoreId: string; +} + +declare namespace AppLink { + function maybeOpenURL(url: string, options: AppLinkOptions): Promise; + function openInStore(options: AppLinkOptions): Promise; +} + +export default AppLink; + +import maybeOpenURL = AppLink.maybeOpenURL; +import openInStore = AppLink.openInStore; +export { maybeOpenURL, openInStore }; diff --git a/types/react-native-app-link/react-native-app-link-tests.ts b/types/react-native-app-link/react-native-app-link-tests.ts new file mode 100644 index 0000000000..9ce9d2aa91 --- /dev/null +++ b/types/react-native-app-link/react-native-app-link-tests.ts @@ -0,0 +1,37 @@ +import AppLink, { maybeOpenURL, openInStore } from 'react-native-app-link'; + +AppLink.maybeOpenURL('instagram://user?username=microsoft', { + appName: 'instagram', + appStoreId: 389801252, + appStoreLocale: 'gb', + playStoreId: 'com.instagram.android' +}).then(() => { + // do stuff +}); + +maybeOpenURL('instagram://user?username=microsoft', { + appName: 'instagram', + appStoreId: 389801252, + appStoreLocale: 'gb', + playStoreId: 'com.instagram.android' +}).then(() => { + // do stuff +}); + +AppLink.openInStore({ + appName: 'whatsapp-messenger', + appStoreId: 310633997, + appStoreLocale: 'gb', + playStoreId: 'com.whatsapp' +}).then(() => { + // do stuff +}); + +openInStore({ + appName: 'whatsapp-messenger', + appStoreId: 310633997, + appStoreLocale: 'gb', + playStoreId: 'com.whatsapp' +}).then(() => { + // do stuff +}); diff --git a/types/react-native-app-link/tsconfig.json b/types/react-native-app-link/tsconfig.json new file mode 100644 index 0000000000..ea3535d7b6 --- /dev/null +++ b/types/react-native-app-link/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "react-native-app-link-tests.ts" + ] +} diff --git a/types/react-native-app-link/tslint.json b/types/react-native-app-link/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-app-link/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }