mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #19616 from newyankeecodeshop/react-native-globals
[react-native]: Add global declarations for RN polyfills
This commit is contained in:
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* This file is necessary to declare global functions that might also be included by `--lib dom`.
|
||||
* Due to a TypeScript bug, these cannot be placed inside a `declare global` block in index.d.ts.
|
||||
*/
|
||||
|
||||
//
|
||||
// Timer Functions
|
||||
//
|
||||
declare function clearInterval(handle: number): void;
|
||||
declare function clearTimeout(handle: number): void;
|
||||
declare function setInterval(handler: (...args: any[]) => void, timeout: number): number;
|
||||
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): number;
|
||||
declare function clearImmediate(handle: number): void;
|
||||
declare function setImmediate(handler: (...args: any[]) => void): number;
|
||||
|
||||
declare function cancelAnimationFrame(handle: number): void;
|
||||
declare function requestAnimationFrame(callback: (time: number) => void): number;
|
||||
Vendored
+57
-18
@@ -11,7 +11,7 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// USING: these definitions are meant to be used with the TSC compiler target set to ES6
|
||||
// USING: these definitions are meant to be used with the TSC compiler target set to at least ES2015.
|
||||
//
|
||||
// USAGE EXAMPLES: check the RNTSExplorer project at https://github.com/bgrieder/RNTSExplorer
|
||||
//
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
/// <reference types="react" />
|
||||
|
||||
/// <reference path="globals.d.ts" />
|
||||
|
||||
export type MeasureOnSuccessCallback = (
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -642,15 +644,23 @@ type GeolocationReturnType = {
|
||||
coords: {
|
||||
latitude: number
|
||||
longitude: number
|
||||
altitude?: number
|
||||
accuracy?: number
|
||||
altitudeAccuracy?: number
|
||||
heading?: number
|
||||
speed?: number
|
||||
altitude: number | null
|
||||
accuracy: number
|
||||
altitudeAccuracy: number | null
|
||||
heading: number | null
|
||||
speed: number | null
|
||||
}
|
||||
timestamp: number
|
||||
}
|
||||
|
||||
type GeolocationError = {
|
||||
code: number;
|
||||
message: string;
|
||||
PERMISSION_DENIED: number;
|
||||
POSITION_UNAVAILABLE: number;
|
||||
TIMEOUT: number;
|
||||
}
|
||||
|
||||
interface PerpectiveTransform {
|
||||
perspective: number;
|
||||
}
|
||||
@@ -8373,23 +8383,25 @@ export interface I18nManagerStatic {
|
||||
}
|
||||
|
||||
export interface GeolocationStatic {
|
||||
/*
|
||||
* Invokes the success callback once with the latest location info. Supported
|
||||
* options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool)
|
||||
* On Android, this can return almost immediately if the location is cached or
|
||||
* request an update, which might take a while.
|
||||
*/
|
||||
getCurrentPosition(geo_success: (position: GeolocationReturnType) => void, geo_error?: (error: Error) => void, geo_options?: GetCurrentPositionOptions): void
|
||||
/**
|
||||
* Invokes the success callback once with the latest location info. Supported
|
||||
* options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool)
|
||||
* On Android, this can return almost immediately if the location is cached or
|
||||
* request an update, which might take a while.
|
||||
*/
|
||||
getCurrentPosition(geo_success: (position: GeolocationReturnType) => void, geo_error?: (error: GeolocationError) => void, geo_options?: GetCurrentPositionOptions): void
|
||||
|
||||
/*
|
||||
* Invokes the success callback whenever the location changes. Supported
|
||||
* options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool), distanceFilter(m)
|
||||
*/
|
||||
watchPosition(success: (position: Geolocation) => void, error?: (error: Error) => void, options?: WatchPositionOptions): void
|
||||
/**
|
||||
* Invokes the success callback whenever the location changes. Supported
|
||||
* options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool), distanceFilter(m)
|
||||
*/
|
||||
watchPosition(success: (position: GeolocationReturnType) => void, error?: (error: GeolocationError) => void, options?: WatchPositionOptions): number
|
||||
|
||||
clearWatch(watchID: number): void
|
||||
|
||||
stopObserving(): void
|
||||
|
||||
requestAuthorization(): void;
|
||||
}
|
||||
|
||||
export interface OpenCameraDialogOptions {
|
||||
@@ -9230,6 +9242,33 @@ export var PointPropType: React.Requireable<any>
|
||||
declare global {
|
||||
function require(name: string): any;
|
||||
|
||||
/**
|
||||
* Console polyfill
|
||||
* @see https://facebook.github.io/react-native/docs/javascript-environment.html#polyfills
|
||||
*/
|
||||
interface Console {
|
||||
error(message?: any, ...optionalParams: any[]): void
|
||||
info(message?: any, ...optionalParams: any[]): void
|
||||
log(message?: any, ...optionalParams: any[]): void
|
||||
warn(message?: any, ...optionalParams: any[]): void
|
||||
trace(message?: any, ...optionalParams: any[]): void
|
||||
debug(message?: any, ...optionalParams: any[]): void
|
||||
table(...data: any[]): void;
|
||||
}
|
||||
|
||||
var console: Console
|
||||
|
||||
/**
|
||||
* Navigator object for accessing location API
|
||||
* @see https://facebook.github.io/react-native/docs/javascript-environment.html#polyfills
|
||||
*/
|
||||
interface Navigator {
|
||||
readonly product: string;
|
||||
readonly geolocation: Geolocation;
|
||||
}
|
||||
|
||||
var navigator: Navigator;
|
||||
|
||||
/**
|
||||
* This contains the non-native `XMLHttpRequest` object, which you can use if you want to route network requests
|
||||
* through DevTools (to trace them):
|
||||
|
||||
Reference in New Issue
Block a user