Created
April 30, 2019 20:28
-
-
Save vovkasm/dd19b27f7b56d6290754ff953d86c2b9 to your computer and use it in GitHub Desktop.
Typescript globals for react-native
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module '*.png' { | |
import { ImageRequireSource } from 'react-native' | |
const content: ImageRequireSource | |
export default content | |
} | |
declare module 'react-native/Libraries/Components/TextInput/TextInputState' { | |
export function blurTextInput(textFieldID?: number): void | |
export function currentlyFocusedField(): number | null | |
export function focusTextInput(textFieldID?: number): void | |
export function isTextInput(textFieldID: number): boolean | |
} | |
// RN globals | |
interface AddEventListenerOptions extends EventListenerOptions { | |
once?: boolean | |
passive?: boolean | |
} | |
interface Event { | |
readonly bubbles: boolean | |
cancelBubble: boolean | |
readonly cancelable: boolean | |
readonly composed: boolean | |
readonly currentTarget: EventTarget | null | |
readonly defaultPrevented: boolean | |
readonly eventPhase: number | |
readonly isTrusted: boolean | |
returnValue: boolean | |
readonly srcElement: Element | null | |
readonly target: EventTarget | null | |
readonly timeStamp: number | |
readonly type: string | |
deepPath(): EventTarget[] | |
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void | |
preventDefault(): void | |
stopImmediatePropagation(): void | |
stopPropagation(): void | |
readonly AT_TARGET: number | |
readonly BUBBLING_PHASE: number | |
readonly CAPTURING_PHASE: number | |
readonly NONE: number | |
} | |
interface EventInit { | |
bubbles?: boolean | |
cancelable?: boolean | |
composed?: boolean | |
} | |
interface EventListener { | |
(evt: Event): void | |
} | |
interface EventListenerObject { | |
handleEvent(evt: Event): void | |
} | |
interface EventListenerOptions { | |
capture?: boolean | |
} | |
type EventListenerOrEventListenerObject = EventListener | EventListenerObject | |
interface EventTarget { | |
addEventListener( | |
type: string, | |
listener: EventListenerOrEventListenerObject | null, | |
options?: boolean | AddEventListenerOptions, | |
): void | |
dispatchEvent(evt: Event): boolean | |
removeEventListener( | |
type: string, | |
listener?: EventListenerOrEventListenerObject | null, | |
options?: EventListenerOptions | boolean, | |
): void | |
} | |
interface ProgressEvent extends Event { | |
readonly type: 'progress' | |
readonly total: number | |
readonly loaded: number | |
readonly lengthComputable: boolean | |
} | |
declare var Event: { | |
prototype: Event | |
new (typeArg: string, eventInitDict?: EventInit): Event | |
readonly AT_TARGET: number | |
readonly BUBBLING_PHASE: number | |
readonly CAPTURING_PHASE: number | |
readonly NONE: number | |
} | |
type BodyInit = | |
| Blob | |
| Int8Array | |
| Int16Array | |
| Int32Array | |
| Uint8Array | |
| Uint16Array | |
| Uint32Array | |
| Uint8ClampedArray | |
| Float32Array | |
| Float64Array | |
| DataView | |
| ArrayBuffer | |
| FormData | |
| string | |
| null | |
type BinaryType = 'blob' | 'arraybuffer' | |
interface CloseEvent extends Event { | |
readonly code: number | |
readonly reason: string | |
readonly wasClean: boolean | |
/** @deprecated */ | |
initCloseEvent( | |
typeArg: string, | |
canBubbleArg: boolean, | |
cancelableArg: boolean, | |
wasCleanArg: boolean, | |
codeArg: number, | |
reasonArg: string, | |
): void | |
} | |
interface CloseEventInit extends EventInit { | |
code?: number | |
reason?: string | |
wasClean?: boolean | |
} | |
declare var CloseEvent: { | |
prototype: CloseEvent | |
new (type: string, eventInitDict?: CloseEventInit): CloseEvent | |
} | |
interface MessageEventInit extends EventInit { | |
data?: any | |
} | |
interface MessageEvent extends Event { | |
readonly data: any | |
} | |
declare var MessageEvent: { | |
prototype: MessageEvent | |
new (type: string, eventInitDict?: MessageEventInit): MessageEvent | |
} | |
interface WebSocketEventMap { | |
close: CloseEvent | |
error: Event | |
message: MessageEvent | |
open: Event | |
} | |
declare interface WebSocket extends EventTarget { | |
binaryType: BinaryType | |
readonly bufferedAmount: number | |
readonly extensions: string | |
onclose: ((this: WebSocket, ev: CloseEvent) => any) | null | |
onerror: ((this: WebSocket, ev: Event) => any) | null | |
onmessage: ((this: WebSocket, ev: MessageEvent) => any) | null | |
onopen: ((this: WebSocket, ev: Event) => any) | null | |
readonly protocol: string | |
readonly readyState: number | |
readonly url: string | |
close(code?: number, reason?: string): void | |
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void | |
readonly CLOSED: number | |
readonly CLOSING: number | |
readonly CONNECTING: number | |
readonly OPEN: number | |
addEventListener<K extends keyof WebSocketEventMap>( | |
type: K, | |
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, | |
options?: boolean | AddEventListenerOptions, | |
): void | |
addEventListener( | |
type: string, | |
listener: EventListenerOrEventListenerObject, | |
options?: boolean | AddEventListenerOptions, | |
): void | |
removeEventListener<K extends keyof WebSocketEventMap>( | |
type: K, | |
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, | |
options?: boolean | EventListenerOptions, | |
): void | |
removeEventListener( | |
type: string, | |
listener: EventListenerOrEventListenerObject, | |
options?: boolean | EventListenerOptions, | |
): void | |
} | |
declare var WebSocket: { | |
prototype: WebSocket | |
new (url: string, protocols?: string | string[]): WebSocket | |
readonly CLOSED: number | |
readonly CLOSING: number | |
readonly CONNECTING: number | |
readonly OPEN: number | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment