mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
expo: Add Expo.Linking API. (#26793)
* expo: Add Expo.Linking API. * expo: Add myself to the list of packagers.
This commit is contained in:
parent
9629215c7a
commit
cb5f92bed9
@ -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'] || '');
|
||||
};
|
||||
|
||||
() => (
|
||||
<Svg width={100} height={50}>
|
||||
<Svg.Rect
|
||||
|
||||
18
types/expo/index.d.ts
vendored
18
types/expo/index.d.ts
vendored
@ -9,6 +9,7 @@
|
||||
// Moshe Feuchtwanger <https://github.com/moshfeu>
|
||||
// Michael Prokopchuk <https://github.com/prokopcm>
|
||||
// Tina Roh <https://github.com/tinaroh>
|
||||
// Nathan Phillip Brink <https://github.com/binki>
|
||||
// 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<LinearGradientProps> { }
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* Linking
|
||||
*/
|
||||
export interface LinkInfo {
|
||||
path: string;
|
||||
queryParams: Partial<StringHashMap>;
|
||||
}
|
||||
|
||||
export interface LinkingStatic extends ReactNativeLinkingStatic {
|
||||
makeUrl(path: string, queryParams?: HashMap): string;
|
||||
parse(url: string): LinkInfo;
|
||||
parseInitialURLAsync(): Promise<LinkInfo>;
|
||||
}
|
||||
export const Linking: LinkingStatic;
|
||||
|
||||
/**
|
||||
* Location
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user