diff --git a/types/expo/expo-tests.tsx b/types/expo/expo-tests.tsx index 4f51cb0050..210c3400a9 100644 --- a/types/expo/expo-tests.tsx +++ b/types/expo/expo-tests.tsx @@ -25,6 +25,7 @@ import { ImagePicker, ImageManipulator, FaceDetector, + Linking, Svg, IntentLauncherAndroid, KeepAwake, @@ -400,6 +401,38 @@ async () => { result.faces[0]; }; +async () => { + function isBoolean(x: boolean) { + } + function isString(x: string) { + } + // Two examples of members inherited from react-native Linking + // to prove that inheritence is working. + Linking.addEventListener('url', (e) => { + e.url === ''; + }); + isBoolean(await Linking.canOpenURL('expo://')); + + // Extensions added by expo. + + isString(Linking.makeUrl('path')); + isString(Linking.makeUrl('path', { q: 2, u: 'ery', })); + + const { + path, + queryParams, + } = Linking.parse(''); + isString(path); + isString(queryParams['x'] || ''); + + const { + path: path2, + queryParams: queryParams2, + } = await Linking.parseInitialURLAsync(); + isString(path2); + isString(queryParams2['y'] || ''); +}; + () => ( // Michael Prokopchuk // Tina Roh +// Nathan Phillip Brink // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -18,6 +19,7 @@ import { ColorPropType, ImageRequireSource, ImageURISource, + LinkingStatic as ReactNativeLinkingStatic, NativeEventEmitter, ViewProps, ViewStyle, @@ -36,6 +38,7 @@ export type ResizeModeStretch = 'stretch'; export type URISource = ImageURISource; export interface HashMap { [key: string]: any; } +export interface StringHashMap { [key: string]: string; } /** Access the device accelerometer sensor(s) to respond to changes in acceleration in 3d space. */ export namespace Accelerometer { @@ -1712,6 +1715,21 @@ export interface LinearGradientProps { export class LinearGradient extends Component { } // #endregion +/** + * Linking + */ +export interface LinkInfo { + path: string; + queryParams: Partial; +} + +export interface LinkingStatic extends ReactNativeLinkingStatic { + makeUrl(path: string, queryParams?: HashMap): string; + parse(url: string): LinkInfo; + parseInitialURLAsync(): Promise; +} +export const Linking: LinkingStatic; + /** * Location */