From d5ba0bbe9ad37eb4cf93a917bc2fb3b5bf494814 Mon Sep 17 00:00:00 2001 From: John Wright Date: Mon, 15 Apr 2019 17:12:02 +0100 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20react-native-a?= =?UTF-8?q?pp-link=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/react-native-app-link/index.d.ts | 22 +++++++++++ .../react-native-app-link-tests.ts | 37 +++++++++++++++++++ types/react-native-app-link/tsconfig.json | 23 ++++++++++++ types/react-native-app-link/tslint.json | 1 + 4 files changed, 83 insertions(+) create mode 100644 types/react-native-app-link/index.d.ts create mode 100644 types/react-native-app-link/react-native-app-link-tests.ts create mode 100644 types/react-native-app-link/tsconfig.json create mode 100644 types/react-native-app-link/tslint.json 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..2078562fe7 --- /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" } From 4957d1c0b7a190436b4ba6d47740c64ce7e5ca4a Mon Sep 17 00:00:00 2001 From: John Wright Date: Mon, 15 Apr 2019 17:29:10 +0100 Subject: [PATCH 2/2] =?UTF-8?q?style:=20=F0=9F=92=84=20missing=20whitespac?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/react-native-app-link/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-app-link/index.d.ts b/types/react-native-app-link/index.d.ts index 2078562fe7..b6b0c9750e 100644 --- a/types/react-native-app-link/index.d.ts +++ b/types/react-native-app-link/index.d.ts @@ -19,4 +19,4 @@ export default AppLink; import maybeOpenURL = AppLink.maybeOpenURL; import openInStore = AppLink.openInStore; -export {maybeOpenURL, openInStore}; +export { maybeOpenURL, openInStore };