From 01ca498f3384e19556b17450b209ea5bc31dbe6d Mon Sep 17 00:00:00 2001 From: Sirui Li Date: Mon, 24 Dec 2018 12:03:39 +0000 Subject: [PATCH 1/2] [react-native] add Animated.subtract --- types/react-native/index.d.ts | 8 ++++++++ types/react-native/test/animated.tsx | 1 + 2 files changed, 9 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 2c8575b211..fd5631ffb9 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -8507,6 +8507,14 @@ export namespace Animated { class AnimatedAddition extends AnimatedInterpolation {} + /** + * Creates a new Animated value composed by subtracting the second Animated + * value from the first Animated value. + */ + export function subtract(a: Animated, b: Animated): AnimatedSubtraction; + + class AnimatedSubtraction extends AnimatedInterpolation {} + /** * Creates a new Animated value composed by dividing the first Animated * value by the second Animated value. diff --git a/types/react-native/test/animated.tsx b/types/react-native/test/animated.tsx index 40f8c37ee7..3a0c82f556 100644 --- a/types/react-native/test/animated.tsx +++ b/types/react-native/test/animated.tsx @@ -53,6 +53,7 @@ function TestAnimatedAPI() { }); Animated.add(v1, v2); + Animated.subtract(v1, v2); Animated.divide(v1, v2); Animated.multiply(v1, v2); Animated.modulo(v1, 2); From 43cdfef0155373ba53a9e5b7ac4285e0f557a38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Mon, 24 Dec 2018 13:48:59 +0100 Subject: [PATCH 2/2] [react-native] Reformat all files using prettier. prettier --parser typescript --tab-width 4 --semi --trailing-comma es5 \ --write --print-width 120 \ types/react-native{,/test}/*.ts* --- types/react-native/Devtools.d.ts | 10 +- types/react-native/globals.d.ts | 257 +++++++++-------- types/react-native/index.d.ts | 196 ++++++++----- types/react-native/legacy-properties.d.ts | 2 +- types/react-native/test/ART.tsx | 31 +- types/react-native/test/animated.tsx | 5 +- types/react-native/test/globals.tsx | 38 +-- types/react-native/test/index.tsx | 268 +++++++----------- types/react-native/test/legacy-properties.tsx | 3 +- 9 files changed, 408 insertions(+), 402 deletions(-) diff --git a/types/react-native/Devtools.d.ts b/types/react-native/Devtools.d.ts index 18f17540b9..fab175c806 100644 --- a/types/react-native/Devtools.d.ts +++ b/types/react-native/Devtools.d.ts @@ -1,4 +1,4 @@ -declare module 'react-native/Libraries/Core/Devtools/parseErrorStack' { +declare module "react-native/Libraries/Core/Devtools/parseErrorStack" { export type StackFrame = { file: string; methodName: string; @@ -13,10 +13,8 @@ declare module 'react-native/Libraries/Core/Devtools/parseErrorStack' { export default function parseErrorStack(error: ExtendedError): StackFrame[]; } -declare module 'react-native/Libraries/Core/Devtools/symbolicateStackTrace' { - import { StackFrame } from 'react-native/Libraries/Core/Devtools/parseErrorStack'; +declare module "react-native/Libraries/Core/Devtools/symbolicateStackTrace" { + import { StackFrame } from "react-native/Libraries/Core/Devtools/parseErrorStack"; - export default function symbolicateStackTrace( - stack: ReadonlyArray - ): Promise; + export default function symbolicateStackTrace(stack: ReadonlyArray): Promise; } diff --git a/types/react-native/globals.d.ts b/types/react-native/globals.d.ts index 39723fcde1..fc9c2ea5e0 100644 --- a/types/react-native/globals.d.ts +++ b/types/react-native/globals.d.ts @@ -26,7 +26,7 @@ declare function fetchBundle(bundleId: number, callback: (error?: Error | null) // declare interface GlobalFetch { - fetch(input: RequestInfo, init?: RequestInit): Promise; + fetch(input: RequestInfo, init?: RequestInit): Promise; } declare function fetch(input: RequestInfo, init?: RequestInit): Promise; @@ -34,85 +34,100 @@ declare function fetch(input: RequestInfo, init?: RequestInit): Promise; - blob(): Promise; - json(): Promise; - text(): Promise; - formData(): Promise; + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; + formData(): Promise; } declare interface Headers { - append(name: string, value: string): void; - delete(name: string): void; - forEach(callback: Function, thisArg?: any): void; - get(name: string): string | null; - has(name: string): boolean; - set(name: string, value: string): void; + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: Function, thisArg?: any): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; } declare var Headers: { - prototype: Headers; - new(init?: HeadersInit_): Headers; + prototype: Headers; + new (init?: HeadersInit_): Headers; }; -type BodyInit_ = Blob | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | FormData | string | null; +type BodyInit_ = + | Blob + | Int8Array + | Int16Array + | Int32Array + | Uint8Array + | Uint16Array + | Uint32Array + | Uint8ClampedArray + | Float32Array + | Float64Array + | DataView + | ArrayBuffer + | FormData + | string + | null; declare interface RequestInit { - body?: BodyInit_; - credentials?: RequestCredentials_; - headers?: HeadersInit_; - integrity?: string; - keepalive?: boolean; - method?: string; - mode?: RequestMode_; - referrer?: string; - window?: any; + body?: BodyInit_; + credentials?: RequestCredentials_; + headers?: HeadersInit_; + integrity?: string; + keepalive?: boolean; + method?: string; + mode?: RequestMode_; + referrer?: string; + window?: any; } declare interface Request extends Object, Body { - readonly credentials: RequestCredentials_; - readonly headers: Headers; - readonly method: string; - readonly mode: RequestMode_; - readonly referrer: string; - readonly url: string; - clone(): Request; + readonly credentials: RequestCredentials_; + readonly headers: Headers; + readonly method: string; + readonly mode: RequestMode_; + readonly referrer: string; + readonly url: string; + clone(): Request; } declare var Request: { - prototype: Request; - new(input: Request | string, init?: RequestInit): Request; + prototype: Request; + new (input: Request | string, init?: RequestInit): Request; }; declare type RequestInfo = Request | string; declare interface ResponseInit { - headers?: HeadersInit_; - status?: number; - statusText?: string; + headers?: HeadersInit_; + status?: number; + statusText?: string; } declare interface Response extends Object, Body { - readonly headers: Headers; - readonly ok: boolean; - readonly status: number; - readonly statusText: string; - readonly type: ResponseType_; - readonly url: string; - readonly redirected: boolean; - clone(): Response; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: ResponseType_; + readonly url: string; + readonly redirected: boolean; + clone(): Response; } declare var Response: { - prototype: Response; - new(body?: BodyInit_, init?: ResponseInit): Response; - error: () => Response; - redirect: (url: string, status?: number) => Response; + prototype: Response; + new (body?: BodyInit_, init?: ResponseInit): Response; + error: () => Response; + redirect: (url: string, status?: number) => Response; }; type HeadersInit_ = Headers | string[][] | { [key: string]: string }; @@ -125,86 +140,104 @@ type ResponseType_ = "basic" | "cors" | "default" | "error" | "opaque" | "opaque // interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap { - "readystatechange": Event; + readystatechange: Event; } interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { -// msCaching: string; - onreadystatechange: ((this: XMLHttpRequest, ev: Event) => any) | null; - readonly readyState: number; - readonly response: any; - readonly responseText: string; - responseType: XMLHttpRequestResponseType; - readonly responseURL: string; - readonly responseXML: Document | null; - readonly status: number; - readonly statusText: string; - timeout: number; - readonly upload: XMLHttpRequestUpload; - withCredentials: boolean; - abort(): void; - getAllResponseHeaders(): string; - getResponseHeader(header: string): string | null; -// msCachingEnabled(): boolean; - open(method: string, url: string, async?: boolean, user?: string | null, password?: string | null): void; - overrideMimeType(mime: string): void; - send(data?: any): void; - setRequestHeader(header: string, value: string): void; - readonly DONE: number; - readonly HEADERS_RECEIVED: number; - readonly LOADING: number; - readonly OPENED: number; - readonly UNSENT: number; - addEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any): void; -// addEventListener(type: string, listener: EventListenerOrEventListenerObject): void; - removeEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any): void; -// removeEventListener(type: string, listener: EventListenerOrEventListenerObject): void; + // msCaching: string; + onreadystatechange: ((this: XMLHttpRequest, ev: Event) => any) | null; + readonly readyState: number; + readonly response: any; + readonly responseText: string; + responseType: XMLHttpRequestResponseType; + readonly responseURL: string; + readonly responseXML: Document | null; + readonly status: number; + readonly statusText: string; + timeout: number; + readonly upload: XMLHttpRequestUpload; + withCredentials: boolean; + abort(): void; + getAllResponseHeaders(): string; + getResponseHeader(header: string): string | null; + // msCachingEnabled(): boolean; + open(method: string, url: string, async?: boolean, user?: string | null, password?: string | null): void; + overrideMimeType(mime: string): void; + send(data?: any): void; + setRequestHeader(header: string, value: string): void; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; + addEventListener( + type: K, + listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any + ): void; + // addEventListener(type: string, listener: EventListenerOrEventListenerObject): void; + removeEventListener( + type: K, + listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any + ): void; + // removeEventListener(type: string, listener: EventListenerOrEventListenerObject): void; } declare var XMLHttpRequest: { - prototype: XMLHttpRequest; - new(): XMLHttpRequest; - readonly DONE: number; - readonly HEADERS_RECEIVED: number; - readonly LOADING: number; - readonly OPENED: number; - readonly UNSENT: number; + prototype: XMLHttpRequest; + new (): XMLHttpRequest; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; }; interface XMLHttpRequestEventTargetEventMap { - "abort": Event; - "error": Event; - "load": Event; - "loadend": Event; - "loadstart": Event; - "progress": Event; - "timeout": Event; + abort: Event; + error: Event; + load: Event; + loadend: Event; + loadstart: Event; + progress: Event; + timeout: Event; } interface XMLHttpRequestEventTarget { - onabort: ((this: XMLHttpRequest, ev: Event) => any) | null; - onerror: ((this: XMLHttpRequest, ev: Event) => any) | null; - onload: ((this: XMLHttpRequest, ev: Event) => any) | null; - onloadend: ((this: XMLHttpRequest, ev: Event) => any) | null; - onloadstart: ((this: XMLHttpRequest, ev: Event) => any) | null; - onprogress: ((this: XMLHttpRequest, ev: Event) => any) | null; - ontimeout: ((this: XMLHttpRequest, ev: Event) => any) | null; - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any): void; -// addEventListener(type: string, listener: EventListenerOrEventListenerObject): void; - removeEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any): void; -// removeEventListener(type: string, listener: EventListenerOrEventListenerObject): void; + onabort: ((this: XMLHttpRequest, ev: Event) => any) | null; + onerror: ((this: XMLHttpRequest, ev: Event) => any) | null; + onload: ((this: XMLHttpRequest, ev: Event) => any) | null; + onloadend: ((this: XMLHttpRequest, ev: Event) => any) | null; + onloadstart: ((this: XMLHttpRequest, ev: Event) => any) | null; + onprogress: ((this: XMLHttpRequest, ev: Event) => any) | null; + ontimeout: ((this: XMLHttpRequest, ev: Event) => any) | null; + addEventListener( + type: K, + listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any + ): void; + // addEventListener(type: string, listener: EventListenerOrEventListenerObject): void; + removeEventListener( + type: K, + listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any + ): void; + // removeEventListener(type: string, listener: EventListenerOrEventListenerObject): void; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any): void; -// addEventListener(type: string, listener: EventListenerOrEventListenerObject): void; - removeEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any): void; -// removeEventListener(type: string, listener: EventListenerOrEventListenerObject): void; + addEventListener( + type: K, + listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any + ): void; + // addEventListener(type: string, listener: EventListenerOrEventListenerObject): void; + removeEventListener( + type: K, + listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any + ): void; + // removeEventListener(type: string, listener: EventListenerOrEventListenerObject): void; } declare var XMLHttpRequestUpload: { - prototype: XMLHttpRequestUpload; - new(): XMLHttpRequestUpload; + prototype: XMLHttpRequestUpload; + new (): XMLHttpRequestUpload; }; type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index fd5631ffb9..f639afce60 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -35,10 +35,10 @@ /// /// -import * as PropTypes from 'prop-types'; -import * as React from 'react'; +import * as PropTypes from "prop-types"; +import * as React from "react"; -type Constructor = new(...args: any[]) => T; +type Constructor = new (...args: any[]) => T; export type MeasureOnSuccessCallback = ( x: number, @@ -1022,7 +1022,6 @@ export interface TextInputIOSProps { */ spellCheck?: boolean; - /** * Give the keyboard and the system information about the expected * semantic meaning for the content that users enter. @@ -1062,18 +1061,38 @@ export interface TextInputIOSProps { * - `'password'` * */ - textContentType?: "none" | "URL" | "addressCity" | "addressCityAndState" | - "addressState" | "countryName" | "creditCardNumber" | "emailAddress" | - "familyName" | "fullStreetAddress" | "givenName" | "jobTitle" | - "location" | "middleName" | "name" | "namePrefix" | "nameSuffix" | - "nickname" | "organizationName" | "postalCode" | "streetAddressLine1" | - "streetAddressLine2" | "sublocality" | "telephoneNumber" | "username" | - "password"; + textContentType?: + | "none" + | "URL" + | "addressCity" + | "addressCityAndState" + | "addressState" + | "countryName" + | "creditCardNumber" + | "emailAddress" + | "familyName" + | "fullStreetAddress" + | "givenName" + | "jobTitle" + | "location" + | "middleName" + | "name" + | "namePrefix" + | "nameSuffix" + | "nickname" + | "organizationName" + | "postalCode" + | "streetAddressLine1" + | "streetAddressLine2" + | "sublocality" + | "telephoneNumber" + | "username" + | "password"; /** * If false, scrolling of the text view will be disabled. The default value is true. Only works with multiline={true} */ - scrollEnabled?: boolean + scrollEnabled?: boolean; } /** @@ -1154,7 +1173,7 @@ export interface TextInputFocusEventData { * @see TextInputProps.onScroll */ export interface TextInputScrollEventData { - contentOffset: { x: number; y: number; } + contentOffset: { x: number; y: number }; } /** @@ -1208,8 +1227,7 @@ export interface TextInputSubmitEditingEventData { /** * @see https://facebook.github.io/react-native/docs/textinput.html#props */ -export interface TextInputProps - extends ViewProps, TextInputIOSProps, TextInputAndroidProps, AccessibilityProps { +export interface TextInputProps extends ViewProps, TextInputIOSProps, TextInputAndroidProps, AccessibilityProps { /** * Specifies whether fonts should scale to respect Text Size accessibility settings. * The default is `true`. @@ -1248,12 +1266,12 @@ export interface TextInputProps /** * If true, caret is hidden. The default value is false. */ - caretHidden?: boolean + caretHidden?: boolean; /** * If true, context menu is hidden. The default value is false. */ - contextMenuHidden?: boolean + contextMenuHidden?: boolean; /** * Provides an initial value that will change when the user starts typing. @@ -1757,13 +1775,13 @@ export interface ViewStyle extends FlexStyle, ShadowStyleIOS, TransformsStyle { opacity?: number; testID?: string; /** - * Sets the elevation of a view, using Android's underlying - * [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation). - * This adds a drop shadow to the item and affects z-order for overlapping views. - * Only supported on Android 5.0+, has no effect on earlier versions. - * - * @platform android - */ + * Sets the elevation of a view, using Android's underlying + * [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation). + * This adds a drop shadow to the item and affects z-order for overlapping views. + * Only supported on Android 5.0+, has no effect on earlier versions. + * + * @platform android + */ elevation?: number; } @@ -1834,7 +1852,6 @@ export interface ViewPropsAndroid { renderToHardwareTextureAndroid?: boolean; } - type Falsy = undefined | null | false; interface RecursiveArray extends Array> {} /** Keep a brand of 'T' so that calls to `StyleSheet.flatten` can take `RegisteredStyle` and return `T`. */ @@ -1887,7 +1904,6 @@ export type AccessibilityRole = | "summary" | "imagebutton"; - export interface AccessibilityPropsAndroid { /** * In some cases, we also want to alert the end user of the type of selected component (i.e., that it is a “button”). @@ -1977,7 +1993,11 @@ type AccessibilityTrait = * @see https://facebook.github.io/react-native/docs/view.html#props */ export interface ViewProps - extends ViewPropsAndroid, ViewPropsIOS, GestureResponderHandlers, Touchable, AccessibilityProps { + extends ViewPropsAndroid, + ViewPropsIOS, + GestureResponderHandlers, + Touchable, + AccessibilityProps { /** * This defines how far a touch event can start away from the view. * Typical interface guidelines recommend touch targets that are at least @@ -2570,7 +2590,6 @@ declare class SafeAreaViewComponent extends React.Component {} declare const SafeAreaViewBase: Constructor & typeof SafeAreaViewComponent; export class SafeAreaView extends SafeAreaViewBase {} - /** * A component which enables customization of the keyboard input accessory view on iOS. The input accessory view is * displayed above the keyboard whenever a TextInput has focus. This component can be used to create custom toolbars. @@ -3274,7 +3293,8 @@ export interface RecyclerViewBackedScrollViewProps extends ScrollViewProps {} * now only horizontal scrolling is supported. */ declare class RecyclerViewBackedScrollViewComponent extends React.Component {} -declare const RecyclerViewBackedScrollViewBase: Constructor & typeof RecyclerViewBackedScrollViewComponent; +declare const RecyclerViewBackedScrollViewBase: Constructor & + typeof RecyclerViewBackedScrollViewComponent; export class RecyclerViewBackedScrollView extends RecyclerViewBackedScrollViewBase { /** * A helper function to scroll to a specific point in the scrollview. @@ -3670,7 +3690,7 @@ export interface ImageLoadEventData extends ImageLoadEventDataAndroid { height: number; width: number; url: string; - } + }; } export interface ImageErrorEventData { @@ -4121,7 +4141,7 @@ export interface SectionListData extends SectionBase { */ export interface SectionListRenderItemInfo extends ListRenderItemInfo { - section: SectionListData; + section: SectionListData; } export type SectionListRenderItem = (info: SectionListRenderItemInfo) => React.ReactElement | null; @@ -4179,7 +4199,7 @@ export interface SectionListProps extends VirtualizedListWithoutRenderIte */ initialNumToRender?: number; - /** + /** * Reverses the direction of scroll. Uses scale transforms of -1. */ inverted?: boolean; @@ -4215,11 +4235,13 @@ export interface SectionListProps extends VirtualizedListWithoutRenderIte * Recommended action is to either compute your own offset and `scrollTo` it, or scroll as far * as possible and then try again after more items have been rendered. */ - onScrollToIndexFailed?: (info: { - index: number, - highestMeasuredFrameIndex: number, - averageItemLength: number - }) => void; + onScrollToIndexFailed?: ( + info: { + index: number; + highestMeasuredFrameIndex: number; + averageItemLength: number; + } + ) => void; /** * Set this true while waiting for new data from a refresh. @@ -4285,11 +4307,11 @@ export interface SectionListStatic extends React.ComponentClass extends VirtualizedListWithoutRenderItemProps { - renderItem: ListRenderItem; - } +export interface VirtualizedListProps extends VirtualizedListWithoutRenderItemProps { + renderItem: ListRenderItem; +} - export interface VirtualizedListWithoutRenderItemProps extends ScrollViewProps { +export interface VirtualizedListWithoutRenderItemProps extends ScrollViewProps { /** * Rendered when the list is empty. Can be a React Component Class, a render function, or * a rendered element. @@ -4403,11 +4425,13 @@ export interface SectionListStatic extends React.ComponentClass void; + onScrollToIndexFailed?: ( + info: { + index: number; + highestMeasuredFrameIndex: number; + averageItemLength: number; + } + ) => void; /** * Called when the viewability of rows changes, as defined by the @@ -4875,7 +4899,9 @@ export interface ModalPropsIOS { * The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations. * On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field. */ - supportedOrientations?: Array<"portrait" | "portrait-upside-down" | "landscape" | "landscape-left" | "landscape-right">; + supportedOrientations?: Array< + "portrait" | "portrait-upside-down" | "landscape" | "landscape-left" | "landscape-right" + >; /** * The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed. @@ -4896,7 +4922,6 @@ export interface ModalPropsAndroid { hardwareAccelerated?: boolean; } - export type ModalProps = ModalBaseProps & ModalPropsIOS & ModalPropsAndroid; export class Modal extends React.Component {} @@ -5039,7 +5064,9 @@ export interface TouchableWithoutFeedbackProps extends AccessibilityProps { * @see https://facebook.github.io/react-native/docs/touchablewithoutfeedback.html */ declare class TouchableWithoutFeedbackComponent extends React.Component {} -declare const TouchableWithoutFeedbackBase: Constructor & Constructor & typeof TouchableWithoutFeedbackComponent; +declare const TouchableWithoutFeedbackBase: Constructor & + Constructor & + typeof TouchableWithoutFeedbackComponent; export class TouchableWithoutFeedback extends TouchableWithoutFeedbackBase {} /** @@ -5087,7 +5114,10 @@ export interface TouchableHighlightProps extends TouchableWithoutFeedbackProps { * @see https://facebook.github.io/react-native/docs/touchablehighlight.html */ declare class TouchableHighlightComponent extends React.Component {} -declare const TouchableHighlightBase: Constructor & Constructor & Constructor & typeof TouchableHighlightComponent; +declare const TouchableHighlightBase: Constructor & + Constructor & + Constructor & + typeof TouchableHighlightComponent; export class TouchableHighlight extends TouchableHighlightBase {} /** @@ -5110,7 +5140,10 @@ export interface TouchableOpacityProps extends TouchableWithoutFeedbackProps { * @see https://facebook.github.io/react-native/docs/touchableopacity.html */ declare class TouchableOpacityComponent extends React.Component {} -declare const TouchableOpacityBase: Constructor & Constructor & Constructor & typeof TouchableOpacityComponent; +declare const TouchableOpacityBase: Constructor & + Constructor & + Constructor & + typeof TouchableOpacityComponent; export class TouchableOpacity extends TouchableOpacityBase { /** * Animate the touchable to a new opacity. @@ -5250,7 +5283,9 @@ export namespace StyleSheet { /** * Creates a StyleSheet style reference from the given object. */ - export function create | NamedStyles>(styles: T): { [P in keyof T]: RegisteredStyle }; + export function create | NamedStyles>( + styles: T + ): { [P in keyof T]: RegisteredStyle }; /** * Flattens an array of style objects, into one aggregated style object. @@ -5305,10 +5340,7 @@ export namespace StyleSheet { * internally to process color and transform values. You should not use this * unless you really know what you are doing and have exhausted other options. */ - export function setStyleAttributePreprocessor( - property: string, - process: (nextProp: any) => any - ): void; + export function setStyleAttributePreprocessor(property: string, process: (nextProp: any) => any): void; /** * This is defined as the width of a thin line on the platform. It can be @@ -5730,7 +5762,7 @@ interface PlatformStatic { /** * @see https://facebook.github.io/react-native/docs/platform-specific-code.html#content */ - select(specifics: { [platform in PlatformOSType | 'default']?: T }): T; + select(specifics: { [platform in PlatformOSType | "default"]?: T }): T; } interface PlatformIOSStatic extends PlatformStatic { @@ -5801,7 +5833,10 @@ export interface Dimensions { * @param type the type of event to listen to * @param handler the event handler */ - addEventListener(type: "change", handler: ({ window, screen }: { window: ScaledSize, screen: ScaledSize }) => void): void; + addEventListener( + type: "change", + handler: ({ window, screen }: { window: ScaledSize; screen: ScaledSize }) => void + ): void; /** * Remove an event listener @@ -5809,7 +5844,10 @@ export interface Dimensions { * @param type the type of event * @param handler the event handler */ - removeEventListener(type: "change", handler: ({ window, screen }: { window: ScaledSize, screen: ScaledSize }) => void): void; + removeEventListener( + type: "change", + handler: ({ window, screen }: { window: ScaledSize; screen: ScaledSize }) => void + ): void; } export type SimpleTask = { @@ -6319,11 +6357,7 @@ export interface ScrollViewPropsAndroid { nestedScrollEnabled?: boolean; } -export interface ScrollViewProps - extends ViewProps, - ScrollViewPropsIOS, - ScrollViewPropsAndroid, - Touchable { +export interface ScrollViewProps extends ViewProps, ScrollViewPropsIOS, ScrollViewPropsAndroid, Touchable { /** * These styles will be applied to the scroll view content container which * wraps all of the child views. Example: @@ -6729,7 +6763,7 @@ type AccessibilityChangeEvent = boolean; type AccessibilityAnnoucementFinishedEvent = { announcement: string; - success: boolean + success: boolean; }; type AccessibilityEvent = AccessibilityChangeEvent | AccessibilityAnnoucementFinishedEvent; @@ -6913,7 +6947,7 @@ export interface AlertIOSStatic { callbackOrButtons?: ((value: string) => void) | Array, type?: AlertType, defaultValue?: string, - keyboardType?: KeyboardType | KeyboardTypeIOS, + keyboardType?: KeyboardType | KeyboardTypeIOS ) => void; } @@ -7715,9 +7749,9 @@ type ScheduleLocalNotificationDetails = { export type PushNotificationEventName = "notification" | "localNotification" | "register" | "registrationError"; type FetchResult = { - NewData: "UIBackgroundFetchResultNewData", - NoData: "UIBackgroundFetchResultNoData", - ResultFailed: "UIBackgroundFetchResultFailed" + NewData: "UIBackgroundFetchResultNewData"; + NoData: "UIBackgroundFetchResultNoData"; + ResultFailed: "UIBackgroundFetchResultFailed"; }; /** @@ -7786,7 +7820,10 @@ export interface PushNotificationIOSStatic { * * The type MUST be 'notification' */ - addEventListener(type: "notification" | "localNotification", handler: (notification: PushNotification) => void): void; + addEventListener( + type: "notification" | "localNotification", + handler: (notification: PushNotification) => void + ): void; /** * Fired when the user registers for remote notifications. @@ -7805,16 +7842,21 @@ export interface PushNotificationIOSStatic { * * The type MUST be 'registrationError' */ - addEventListener(type: "registrationError", handler: (error: { message: string, code: number, details: any }) => void): void; + addEventListener( + type: "registrationError", + handler: (error: { message: string; code: number; details: any }) => void + ): void; /** * Removes the event listener. Do this in `componentWillUnmount` to prevent * memory leaks */ - removeEventListener(type: PushNotificationEventName, - handler: ((notification: PushNotification) => void) + removeEventListener( + type: PushNotificationEventName, + handler: + | ((notification: PushNotification) => void) | ((deviceToken: string) => void) - | ((error: { message: string, code: number, details: any }) => void) + | ((error: { message: string; code: number; details: any }) => void) ): void; /** @@ -7972,7 +8014,7 @@ type TimePickerAndroidOpenOptions = { hour?: number; minute?: number; is24Hour?: boolean; - mode?: 'clock' | 'spinner' | 'default'; + mode?: "clock" | "spinner" | "default"; }; /** @@ -8182,7 +8224,7 @@ export interface SwitchProps extends SwitchPropsIOS { * * Color when false and color when true */ - trackColor?: { false: string, true: string }; + trackColor?: { false: string; true: string }; /** * If true the user won't be able to toggle the switch. @@ -8206,7 +8248,7 @@ export interface SwitchProps extends SwitchPropsIOS { */ value?: boolean; - /** + /** * On iOS, custom color for the background. * Can be seen when the switch value is false or when the switch is disabled. */ diff --git a/types/react-native/legacy-properties.d.ts b/types/react-native/legacy-properties.d.ts index ab87361485..1968baabee 100644 --- a/types/react-native/legacy-properties.d.ts +++ b/types/react-native/legacy-properties.d.ts @@ -66,7 +66,7 @@ import { StatusBarPropsIOS, StatusBarPropsAndroid, SwitchProps, - SwitchPropsIOS + SwitchPropsIOS, } from "react-native"; declare module "react-native" { diff --git a/types/react-native/test/ART.tsx b/types/react-native/test/ART.tsx index 86fa48ca88..a3d152d8dd 100644 --- a/types/react-native/test/ART.tsx +++ b/types/react-native/test/ART.tsx @@ -3,27 +3,16 @@ import * as ReactNative from "react-native"; // See https://github.com/react-native-china/react-native-ART-doc/blob/6ba9c0f7c7e495a12045f3d7061834d2c74413c5/doc.md -const { - Surface, - Shape, - Group, - Text, - ClippingRectangle -} = ReactNative.ART +const { Surface, Shape, Group, Text, ClippingRectangle } = ReactNative.ART; class Test extends React.Component { - render() { - return ( - - - - - - ) - } + render() { + return ( + + + + + + ); + } } diff --git a/types/react-native/test/animated.tsx b/types/react-native/test/animated.tsx index 3a0c82f556..cd0a9a2127 100644 --- a/types/react-native/test/animated.tsx +++ b/types/react-native/test/animated.tsx @@ -70,10 +70,7 @@ function TestAnimatedAPI() { } }; - Animated.event( - [{ nativeEvent: { contentOffset: { y: v1 } } }], - { useNativeDriver: true, listener }, - ); + Animated.event([{ nativeEvent: { contentOffset: { y: v1 } } }], { useNativeDriver: true, listener }); return ( diff --git a/types/react-native/test/globals.tsx b/types/react-native/test/globals.tsx index b5eae800b1..cdbc5268a5 100644 --- a/types/react-native/test/globals.tsx +++ b/types/react-native/test/globals.tsx @@ -1,26 +1,28 @@ -const fetchCopy: GlobalFetch['fetch'] = fetch; +const fetchCopy: GlobalFetch["fetch"] = fetch; const myHeaders = new Headers(); -myHeaders.append('Content-Type', 'image/jpeg'); +myHeaders.append("Content-Type", "image/jpeg"); const myInit: RequestInit = { - method: 'GET', - headers: myHeaders, - mode: 'cors', + method: "GET", + headers: myHeaders, + mode: "cors", }; -const myRequest = new Request('flowers.jpg'); +const myRequest = new Request("flowers.jpg"); -fetch(myRequest, myInit).then((response) => { - console.log(response.type); - console.log(response.url); - console.log(response.status); - console.log(response.ok); - console.log(response.statusText); - console.log(response.headers); +fetch(myRequest, myInit) + .then(response => { + console.log(response.type); + console.log(response.url); + console.log(response.status); + console.log(response.ok); + console.log(response.statusText); + console.log(response.headers); - return response.blob(); -}).then((blob) => { - const init = { status: 200, statusText: 'SuperSmashingGreat!' } - const myResponse = new Response(blob, init); -}) + return response.blob(); + }) + .then(blob => { + const init = { status: 200, statusText: "SuperSmashingGreat!" }; + const myResponse = new Response(blob, init); + }); diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index f3dfb45b51..5e46bf96e9 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -97,7 +97,7 @@ NativeModules.NativeUntypedModule; NativeModules.NativeTypedModule.someFunction(); NativeModules.NativeTypedModule.someProperty = ""; -function dimensionsListener(dimensions: { window: ScaledSize, screen: ScaledSize }) { +function dimensionsListener(dimensions: { window: ScaledSize; screen: ScaledSize }) { console.log("window dimensions: ", dimensions.window); console.log("screen dimensions: ", dimensions.screen); } @@ -105,8 +105,8 @@ function dimensionsListener(dimensions: { window: ScaledSize, screen: ScaledSize function testDimensions() { const { width, height, scale, fontScale } = Dimensions.get(1 === 1 ? "window" : "screen"); - Dimensions.addEventListener('change', dimensionsListener); - Dimensions.removeEventListener('change', dimensionsListener); + Dimensions.addEventListener("change", dimensionsListener); + Dimensions.removeEventListener("change", dimensionsListener); } BackHandler.addEventListener("hardwareBackPress", () => {}).remove(); @@ -158,31 +158,31 @@ const stylesAlt = StyleSheet.create({ }, }); -StyleSheet.setStyleAttributePreprocessor('fontFamily', (family: string) => family); +StyleSheet.setStyleAttributePreprocessor("fontFamily", (family: string) => family); const welcomeFontSize = StyleSheet.flatten(styles.welcome).fontSize; const viewStyle: StyleProp = { - backgroundColor: "#F5FCFF", -} + backgroundColor: "#F5FCFF", +}; const textStyle: StyleProp = { - fontSize: 20, -} + fontSize: 20, +}; const imageStyle: StyleProp = { - resizeMode: 'contain', -} + resizeMode: "contain", +}; const viewProperty = StyleSheet.flatten(viewStyle).backgroundColor; const textProperty = StyleSheet.flatten(textStyle).fontSize; const imageProperty = StyleSheet.flatten(imageStyle).resizeMode; const s = StyleSheet.create({ - shouldWork: { - fontWeight: '900', // if we comment this line, errors gone - marginTop: 5, // if this line commented, errors also gone - }, -}) -const f1: RegisteredStyle = s.shouldWork + shouldWork: { + fontWeight: "900", // if we comment this line, errors gone + marginTop: 5, // if this line commented, errors also gone + }, +}); +const f1: RegisteredStyle = s.shouldWork; const testNativeSyntheticEvent = (e: NativeSyntheticEvent): void => { e.isDefaultPrevented(); @@ -201,7 +201,7 @@ const testNativeSyntheticEvent = (e: NativeSyntheticEvent): voi e.timeStamp; e.type; e.nativeEvent; -} +}; type ElementProps = C extends React.Component ? P : never; @@ -265,18 +265,16 @@ export class TouchableNativeFeedbackTest extends React.Component { e.persist(); e.isPropagationStopped(); e.isDefaultPrevented(); - } + }; render() { return ( - - - Button + + + Button - ) + ); } } @@ -347,11 +345,11 @@ export class FlatListTest extends React.Component, {}> { } export class SectionListTest extends React.Component, {}> { - myList: SectionList + myList: SectionList; scrollMe = () => { - this.myList.scrollToLocation({itemIndex: 0, sectionIndex: 1}); - } + this.myList.scrollToLocation({ itemIndex: 0, sectionIndex: 1 }); + }; render() { const sections = [ @@ -375,7 +373,7 @@ export class SectionListTest extends React.Component, {