Removed custom react.d.ts and react-dom.d.ts and switched to public versions.

This commit is contained in:
Eric Traut 2017-09-21 17:14:15 -07:00
Родитель 5bb43510bc
Коммит b278701fe3
31 изменённых файлов: 170 добавлений и 1184 удалений

Просмотреть файл

@ -10,6 +10,8 @@
},
"dependencies": {
"@types/lodash": "^4.14.66",
"@types/react": "^15.4.1",
"@types/react-dom": "^15.4.1",
"assert": "^1.3.0",
"ifvisible.js": "^1.0.6",
"lodash": "^4.17.1",

Просмотреть файл

@ -364,7 +364,7 @@ export enum ImportantForAccessibility {
NoHideDescendants
}
export interface AccessibilityHtmlAttributes extends React.HTMLAttributes {
export interface AccessibilityHtmlAttributes extends React.HTMLAttributes<any> {
'aria-label'?: string;
'aria-live'?: string;
'aria-hidden'?: boolean;
@ -610,19 +610,19 @@ export interface ViewPropsShared extends CommonProps, CommonAccessibilityProps {
export interface ViewProps extends ViewPropsShared {
style?: StyleRuleSetRecursive<ViewStyleRuleSet>;
onContextMenu?: (e: React.SyntheticEvent) => void;
onStartShouldSetResponder?: (e: React.SyntheticEvent) => boolean;
onMoveShouldSetResponder?: (e: React.SyntheticEvent) => boolean;
onStartShouldSetResponderCapture?: (e: React.SyntheticEvent) => boolean;
onMoveShouldSetResponderCapture?: (e: React.SyntheticEvent) => boolean;
onResponderGrant?: (e: React.SyntheticEvent) => void;
onResponderReject?: (e: React.SyntheticEvent) => void;
onResponderRelease?: (e: React.SyntheticEvent) => void;
onResponderStart?: (e: React.TouchEvent) => void;
onResponderMove?: (e: React.TouchEvent) => void;
onResponderEnd?: (e: React.TouchEvent) => void;
onResponderTerminate?: (e: React.SyntheticEvent) => void;
onResponderTerminationRequest?: (e: React.SyntheticEvent) => boolean;
onContextMenu?: (e: React.SyntheticEvent<any>) => void;
onStartShouldSetResponder?: (e: React.SyntheticEvent<any>) => boolean;
onMoveShouldSetResponder?: (e: React.SyntheticEvent<any>) => boolean;
onStartShouldSetResponderCapture?: (e: React.SyntheticEvent<any>) => boolean;
onMoveShouldSetResponderCapture?: (e: React.SyntheticEvent<any>) => boolean;
onResponderGrant?: (e: React.SyntheticEvent<any>) => void;
onResponderReject?: (e: React.SyntheticEvent<any>) => void;
onResponderRelease?: (e: React.SyntheticEvent<any>) => void;
onResponderStart?: (e: React.TouchEvent<any>) => void;
onResponderMove?: (e: React.TouchEvent<any>) => void;
onResponderEnd?: (e: React.TouchEvent<any>) => void;
onResponderTerminate?: (e: React.SyntheticEvent<any>) => void;
onResponderTerminationRequest?: (e: React.SyntheticEvent<any>) => boolean;
}
export interface AnimatedViewProps extends ViewPropsShared {
@ -631,7 +631,7 @@ export interface AnimatedViewProps extends ViewPropsShared {
// GestureView
export interface GestureState {
timeStamp: Date;
timeStamp: number;
}
export interface MultiTouchGestureState extends GestureState {
@ -1080,16 +1080,52 @@ export module Animated {
//
// Events
// ----------------------------------------------------------------------
export type SyntheticEvent = React.SyntheticEvent;
export type SyntheticEvent = React.SyntheticEvent<any>;
export type DragEvent = React.DragEvent;
export type ClipboardEvent = React.ClipboardEvent;
export type FocusEvent = React.FocusEvent;
export type FormEvent = React.FormEvent;
export type MouseEvent = React.MouseEvent;
export type TouchEvent = React.TouchEvent;
export type UIEvent = React.UIEvent;
export type WheelEvent = React.WheelEvent;
export type DragEvent = React.DragEvent<any>;
export type ClipboardEvent = React.ClipboardEvent<any>;
export type FocusEvent = React.FocusEvent<any>;
export type FormEvent = React.FormEvent<any>;
export type MouseEvent = React.MouseEvent<any>;
export interface Touch {
identifier: number;
target: EventTarget;
locationX: number;
locationY: number;
screenX: number;
screenY: number;
clientX: number;
clientY: number;
pageX: number;
pageY: number;
}
export interface TouchList {
[index: number]: Touch;
length: number;
item(index: number): Touch;
identifiedTouch(identifier: number): Touch;
}
export interface TouchEvent extends React.SyntheticEvent<any> {
// We override this definition because the public
// type excludes location and page fields.
altKey: boolean;
changedTouches: TouchList;
ctrlKey: boolean;
getModifierState(key: string): boolean;
metaKey: boolean;
shiftKey: boolean;
targetTouches: TouchList;
locationX?: number;
locationY?: number;
pageX?: number;
pageY?: number;
touches: TouchList;
}
export type UIEvent = React.UIEvent<any>;
export type WheelEvent = React.WheelEvent<any>;
export interface WebViewShouldStartLoadEvent extends SyntheticEvent {
url: string;

Просмотреть файл

@ -59,10 +59,10 @@ export class Button extends React.Component<Types.ButtonProps, {}> {
touchableGetInitialState: () => RN.Touchable.State;
touchableHandleStartShouldSetResponder: () => boolean;
touchableHandleResponderTerminationRequest: () => boolean;
touchableHandleResponderGrant: (e: React.SyntheticEvent) => void;
touchableHandleResponderMove: (e: React.SyntheticEvent) => void;
touchableHandleResponderRelease: (e: React.SyntheticEvent) => void;
touchableHandleResponderTerminate: (e: React.SyntheticEvent) => void;
touchableHandleResponderGrant: (e: React.SyntheticEvent<any>) => void;
touchableHandleResponderMove: (e: React.SyntheticEvent<any>) => void;
touchableHandleResponderRelease: (e: React.SyntheticEvent<any>) => void;
touchableHandleResponderTerminate: (e: React.SyntheticEvent<any>) => void;
private _isMounted = false;
private _hideTimeout: number|undefined;

Просмотреть файл

@ -164,7 +164,7 @@ export class FrontLayerViewManager {
RN.NativeModules.UIManager.measureInWindow(
activePopupContext.anchorHandle,
(x: number, y: number, width: number, height: number, pageX: number, pageY: number) => {
const touchEvent = (e.nativeEvent as any) as Types.TouchEvent;
const touchEvent = e.nativeEvent as any;
let anchorRect: ClientRect = { left: x, top: y, right: x + width,
bottom: y + height, width: width, height: height };

Просмотреть файл

@ -72,8 +72,8 @@ export abstract class GestureView extends ViewBase<Types.GestureViewProps, {}> {
private _setUpPanResponder(): void {
this._panResponder = RN.PanResponder.create({
onStartShouldSetPanResponder: (e, gestureState) => {
const event = (e.nativeEvent as any) as Types.TouchEvent;
UserInterface.evaluateTouchLatency(e);
const event = (e as any).nativeEvent as Types.TouchEvent;
UserInterface.evaluateTouchLatency(e as any);
this._lastGestureStartEvent = event;
// If we're trying to detect a tap, set this as the responder immediately.
@ -84,8 +84,8 @@ export abstract class GestureView extends ViewBase<Types.GestureViewProps, {}> {
},
onMoveShouldSetPanResponder: (e, gestureState) => {
const event = (e.nativeEvent as any) as Types.TouchEvent;
UserInterface.evaluateTouchLatency(e);
const event = (e as any).nativeEvent as Types.TouchEvent;
UserInterface.evaluateTouchLatency(e as any);
this._lastGestureStartEvent = event;
this._pendingGestureType = this._detectMoveGesture(event, gestureState);
@ -115,8 +115,8 @@ export abstract class GestureView extends ViewBase<Types.GestureViewProps, {}> {
},
onPanResponderMove: (e, gestureState) => {
const event = (e.nativeEvent as any) as Types.TouchEvent;
UserInterface.evaluateTouchLatency(e);
const event = (e as any).nativeEvent as Types.TouchEvent;
UserInterface.evaluateTouchLatency(e as any);
let initializeFromEvent = false;
@ -145,7 +145,7 @@ export abstract class GestureView extends ViewBase<Types.GestureViewProps, {}> {
}
private _onPanResponderEnd(e: RN.ResponderSyntheticEvent, gestureState: RN.PanResponderGestureState) {
const event = (e.nativeEvent as any) as Types.TouchEvent;
const event = (e as any).nativeEvent as Types.TouchEvent;
// Close out any of the pending move gestures.
if (this._pendingGestureType === GestureType.MultiTouch) {

Просмотреть файл

@ -104,7 +104,7 @@ export class Image extends React.Component<Types.ImageProps, {}> {
return [_styles.defaultImage, this.props.style];
}
private _onLoad = (e: React.SyntheticEvent) => {
private _onLoad = (e: React.SyntheticEvent<Image>) => {
if (!this._isMounted) {
return;
}
@ -118,7 +118,7 @@ export class Image extends React.Component<Types.ImageProps, {}> {
}
}
private _onError = (e: React.SyntheticEvent) => {
private _onError = (e: React.SyntheticEvent<Image>) => {
if (!this._isMounted) {
return;
}

Просмотреть файл

@ -32,7 +32,7 @@ const _styles = {
export interface ModalContainerProps extends Types.CommonProps {
}
export class ModalContainer extends React.Component<ModalContainerProps, null> {
export class ModalContainer extends React.Component<ModalContainerProps, {}> {
constructor(props: ModalContainerProps) {
super(props);
}

Просмотреть файл

@ -58,7 +58,7 @@ export class ScrollView extends ViewBase<Types.ScrollViewProps, {}> implements R
// we use are virtualized anyway.
return (
<RN.ScrollView
ref={this._setNativeView}
ref={ this._setNativeView }
style={ this.props.style }
onScroll={ scrollCallback }
automaticallyAdjustContentInsets={ false }
@ -87,7 +87,7 @@ export class ScrollView extends ViewBase<Types.ScrollViewProps, {}> implements R
);
}
private _onScroll = (event: React.SyntheticEvent) => {
private _onScroll = (event: React.SyntheticEvent<ScrollView>) => {
const nativeEvent = event.nativeEvent as any;
this._scrollTop = nativeEvent.contentOffset.y;
this._scrollLeft = nativeEvent.contentOffset.x;

Просмотреть файл

@ -43,7 +43,7 @@ export class TextInput extends React.Component<Types.TextInputProps, TextInputSt
componentWillReceiveProps(nextProps: Types.TextInputProps) {
if (nextProps.value !== this.state.inputValue) {
this.setState({
inputValue: nextProps.value
inputValue: nextProps.value || ''
});
}
}
@ -53,7 +53,7 @@ export class TextInput extends React.Component<Types.TextInputProps, TextInputSt
const blurOnSubmit = this.props.blurOnSubmit || !this.props.multiline;
return (
<RN.TextInput
ref='nativeTextInput'
ref={ 'nativeTextInput' }
multiline={ this.props.multiline }
style={ Styles.combine([_styles.defaultTextInput, this.props.style]) }
value={ this.state.inputValue }
@ -70,9 +70,9 @@ export class TextInput extends React.Component<Types.TextInputProps, TextInputSt
defaultValue={ this.props.value }
placeholderTextColor={ this.props.placeholderTextColor }
onSubmitEditing={this.props.onSubmitEditing }
onKeyPress={ this._onKeyPress }
onKeyPress={ this._onKeyPress as any }
onChangeText={ this._onChangeText }
onSelectionChange={ this._onSelectionChange }
onSelectionChange={ this._onSelectionChange as any }
onFocus={ this._onFocus }
onBlur={ this._onBlur }
onScroll={ this._onScroll }
@ -117,7 +117,7 @@ export class TextInput extends React.Component<Types.TextInputProps, TextInputSt
}
}
private _onSelectionChange = (selEvent: React.SyntheticEvent) => {
private _onSelectionChange = (selEvent: React.SyntheticEvent<TextInput>) => {
let selection: { start: number, end: number } =
(selEvent.nativeEvent as any).selection;
@ -135,7 +135,7 @@ export class TextInput extends React.Component<Types.TextInputProps, TextInputSt
this.forceUpdate();
}
private _onKeyPress = (e: React.KeyboardEvent) => {
private _onKeyPress = (e: React.KeyboardEvent<TextInput>) => {
if (this.props.onKeyPress) {
let keyName: string = (e.nativeEvent as any).key;
let keyCode: number = 0;
@ -178,7 +178,7 @@ export class TextInput extends React.Component<Types.TextInputProps, TextInputSt
}
}
private _onScroll = (e: React.UIEvent) => {
private _onScroll = (e: React.UIEvent<TextInput>) => {
if (this.props.onScroll) {
const { contentOffset } = (e.nativeEvent as any);
this.props.onScroll(contentOffset.x, contentOffset.y);

Просмотреть файл

@ -31,7 +31,7 @@ export abstract class ViewBase<P extends Types.ViewProps, S> extends RX.ViewBase
}
}
protected _setNativeView = (view: RN.View) => {
protected _setNativeView = (view: any | undefined) => {
this._nativeView = view;
}

Просмотреть файл

@ -33,7 +33,9 @@ function extractChildrenKeys(children: React.ReactNode): ChildKey[] {
childReactElement.key !== undefined && childReactElement.key !== null,
'Children passed to a `View` with child animations enabled must have a `key`'
);
keys.push(childReactElement.key);
if (childReactElement.key !== null) {
keys.push(childReactElement.key);
}
}
});
return keys;
@ -43,7 +45,7 @@ function findInvalidRefs(children: React.ReactNode) {
let invalidRefs: string[] = [];
React.Children.forEach(children, function (child) {
if (child) {
let childElement = child as React.ReactElement<any>;
let childElement = child as any;
if (typeof childElement.ref !== 'function' && childElement.ref !== undefined && childElement.ref !== null) {
invalidRefs.push(childElement.ref as string);
}

71
src/typings/react-dom.d.ts поставляемый
Просмотреть файл

@ -1,71 +0,0 @@
// Type definitions for React v0.14 (react-dom)
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="react.d.ts" />
declare namespace __React {
module __DOM {
function findDOMNode<TElement extends Element>(
componentOrElement: __React.Component<any, any> | Element): TElement;
function findDOMNode(
componentOrElement: __React.Component<any, any> | Element): Element;
function render<P>(
element: DOMElement<P>,
container: Element,
callback?: () => any): DOMComponent<P>;
function render<P, S>(
element: ClassicElement<P>,
container: Element,
callback?: () => any): ClassicComponent<P, S>;
function render<P, S>(
element: ReactElement<P>,
container: Element,
callback?: () => any): Component<P, S>;
function unmountComponentAtNode(container: Element): boolean;
var version: string;
function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
function unstable_batchedUpdates(callback: () => any): void;
function unstable_renderSubtreeIntoContainer<P>(
parentComponent: Component<any, any>,
nextElement: DOMElement<P>,
container: Element,
callback?: (component: DOMComponent<P>) => any): DOMComponent<P>;
function unstable_renderSubtreeIntoContainer<P, S>(
parentComponent: Component<any, any>,
nextElement: ClassicElement<P>,
container: Element,
callback?: (component: ClassicComponent<P, S>) => any): ClassicComponent<P, S>;
function unstable_renderSubtreeIntoContainer<P, S>(
parentComponent: Component<any, any>,
nextElement: ReactElement<P>,
container: Element,
callback?: (component: Component<P, S>) => any): Component<P, S>;
}
namespace __DOMServer {
function renderToString(element: ReactElement<any>): string;
function renderToStaticMarkup(element: ReactElement<any>): string;
var version: string;
}
}
declare module "react-dom" {
import DOM = __React.__DOM;
export = DOM;
}
declare module "react-dom/server" {
import DOMServer = __React.__DOMServer;
export = DOMServer;
}

34
src/typings/react-native.d.ts поставляемый
Просмотреть файл

@ -31,7 +31,7 @@ declare module 'react-native' {
props ?: any
): React.ReactElement<P>;
interface SyntheticEvent extends React.SyntheticEvent {}
interface SyntheticEvent<T> extends React.SyntheticEvent<T> {}
function isValidElement(object: {}): boolean;
function findNodeHandle(componentOrHandle: any): number;
@ -98,7 +98,7 @@ declare module 'react-native' {
defaultSource?: Object;
onError?: Function;
onLoad?: Function;
onLoadEnd?: (e: SyntheticEvent) => void;
onLoadEnd?: (e: SyntheticEvent<Image>) => void;
onLoadStart?: Function;
onProgress?: Function;
@ -301,7 +301,7 @@ declare module 'react-native' {
renderSeparator?: Function;
renderRow: Function;
initialListSize?: number;
onEndReached?: (e: React.SyntheticEvent) => void;
onEndReached?: (e: React.SyntheticEvent<ListView>) => void;
onEndReachedThreshold?: number;
pageSize?: number;
renderFooter?: Function;
@ -329,13 +329,13 @@ declare module 'react-native' {
editable?: boolean;
keyboardType?: string; // enum("default", 'numeric', 'email-address', "ascii-capable", 'numbers-and-punctuation', 'url', 'number-pad', 'phone-pad', 'name-phone-pad', 'decimal-pad', 'twitter', 'web-search')
multiline?: boolean;
onBlur?: ((e: React.FocusEvent) => void);
onKeyPress?: (e: SyntheticEvent) => void;
onBlur?: ((e: React.FocusEvent<TextInput>) => void);
onKeyPress?: (e: SyntheticEvent<TextInput>) => void;
onChange?: Function;
onChangeText?: ((changedText: string) => void);
onSelectionChange?: ((selection: SyntheticEvent) => void);
onSelectionChange?: ((selection: SyntheticEvent<TextInput>) => void);
onEndEditing?: Function;
onFocus?: ((e: React.FocusEvent) => void);
onFocus?: ((e: React.FocusEvent<TextInput>) => void);
onLayout?: ((props: { x: number, y: number, width: number, height: number }) => void);
onSubmitEditing?: Function;
onScroll?: Function;
@ -387,7 +387,7 @@ declare module 'react-native' {
domStorageEnabled?: boolean;
onShouldStartLoadWithRequest?: Function;
onNavigationStateChange?: Function;
onLoad?: (e: SyntheticEvent) => void;
onLoad?: (e: SyntheticEvent<WebView>) => void;
onLoadStart?: Function;
renderError?: Function;
onError?: Function;
@ -723,7 +723,7 @@ declare module 'react-native' {
numberActiveTouches: number;
}
interface ResponderSyntheticEvent extends React.SyntheticEvent {
interface ResponderSyntheticEvent extends React.SyntheticEvent<any> {
touchHistory: Function;
}
@ -964,14 +964,14 @@ declare module 'react-native' {
touchableGetInitialState: () => State
touchableHandleStartShouldSetResponder: () => {}
touchableHandleResponderTerminationRequest: () => {}
touchableHandleResponderGrant: (e: React.SyntheticEvent, dispatchID: string) => {}
touchableHandleResponderMove: (e: React.SyntheticEvent) => {}
touchableHandleResponderRelease: (e: React.SyntheticEvent) => {}
touchableHandleResponderTerminate: (e: React.SyntheticEvent) => {}
touchableHandleActivePressIn?: (e: React.SyntheticEvent) => {}
touchableHandleActivePressOut?: (e: React.SyntheticEvent) => {}
touchableHandlePress?: (e: React.SyntheticEvent) => {}
touchableHandleLongPress?: (e: React.SyntheticEvent) => {}
touchableHandleResponderGrant: (e: React.SyntheticEvent<any>, dispatchID: string) => {}
touchableHandleResponderMove: (e: React.SyntheticEvent<any>) => {}
touchableHandleResponderRelease: (e: React.SyntheticEvent<any>) => {}
touchableHandleResponderTerminate: (e: React.SyntheticEvent<any>) => {}
touchableHandleActivePressIn?: (e: React.SyntheticEvent<any>) => {}
touchableHandleActivePressOut?: (e: React.SyntheticEvent<any>) => {}
touchableHandlePress?: (e: React.SyntheticEvent<any>) => {}
touchableHandleLongPress?: (e: React.SyntheticEvent<any>) => {}
touchableGetHighlightDelayMS?: () => number
touchableGetPressRectOffset?: () => RectOffset
}

993
src/typings/react.d.ts поставляемый
Просмотреть файл

@ -1,993 +0,0 @@
// Type definitions for React v0.14
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare namespace __React {
//
// React Elements
// ----------------------------------------------------------------------
type ReactType = ComponentClass<any> | string;
interface ReactElement<P> {
type: string | ComponentClass<P>;
props: P;
key: string | number;
ref: string | ((component: Component<P, any>) => any);
}
interface ClassicElement<P> extends ReactElement<P> {
type: string | ClassicComponentClass<P>;
ref: string | ((component: ClassicComponent<P, any>) => any);
}
interface DOMElement<P> extends ClassicElement<P> {
type: string;
ref: string | ((component: DOMComponent<P>) => any);
}
type HTMLElement = DOMElement<HTMLAttributes>;
type SVGElement = DOMElement<SVGAttributes>;
//
// Factories
// ----------------------------------------------------------------------
interface Factory<P> {
(props?: P, ...children: ReactNode[]): ReactElement<P>;
}
interface ClassicFactory<P> extends Factory<P> {
(props?: P, ...children: ReactNode[]): ClassicElement<P>;
}
interface DOMFactory<P> extends ClassicFactory<P> {
(props?: P, ...children: ReactNode[]): DOMElement<P>;
}
type HTMLFactory = DOMFactory<HTMLAttributes>;
type SVGFactory = DOMFactory<SVGAttributes>;
type SVGElementFactory = DOMFactory<SVGElementAttributes>;
//
// React Nodes
// http://facebook.github.io/react/docs/glossary.html
// ----------------------------------------------------------------------
type ReactText = string | number;
type ReactChild = ReactElement<any> | ReactText;
// Should be Array<ReactNode> but type aliases cannot be recursive
type ReactFragment = {} | Array<ReactChild | any[] | boolean>;
type ReactNode = ReactChild | ReactFragment | boolean;
//
// Top Level API
// ----------------------------------------------------------------------
function createClass<P, S>(spec: ComponentSpec<P, S>): ClassicComponentClass<P>;
function createFactory<P>(type: string): DOMFactory<P>;
function createFactory<P>(type: ClassicComponentClass<P> | string): ClassicFactory<P>;
function createFactory<P>(type: ComponentClass<P>): Factory<P>;
function createElement<P>(
type: string,
props?: P,
...children: ReactNode[]): DOMElement<P>;
function createElement<P>(
type: ClassicComponentClass<P> | string,
props?: P,
...children: ReactNode[]): ClassicElement<P>;
function createElement<P>(
type: ComponentClass<P>,
props?: P,
...children: ReactNode[]): ReactElement<P>;
function cloneElement<P>(
element: DOMElement<P>,
props?: P,
...children: ReactNode[]): DOMElement<P>;
function cloneElement<P>(
element: ClassicElement<P>,
props?: P,
...children: ReactNode[]): ClassicElement<P>;
function cloneElement<P>(
element: ReactElement<P>,
props?: P,
...children: ReactNode[]): ReactElement<P>;
function isValidElement(object: {}): boolean;
var DOM: ReactDOM;
var PropTypes: ReactPropTypes;
var Children: ReactChildren;
//
// Component API
// ----------------------------------------------------------------------
// Base component for plain JS classes
interface Component<P = {}, S = {}> extends ComponentLifecycle<P, S> { }
class Component<P = {}, S = {}> implements ComponentLifecycle<P, S> {
static propTypes: ValidationMap<any>;
static contextTypes: ValidationMap<any>;
static childContextTypes: ValidationMap<any>;
static defaultProps: Props<any>;
constructor(props?: P, context?: any);
setState(f: (prevState: S, props: P) => Partial<S>|undefined, callback?: () => any): void;
setState(state: Partial<S>, callback?: () => any): void;
forceUpdate(callBack?: () => any): void;
render(): JSX.Element|null;
props: P;
state: S;
context: {};
refs: {
[key: string]: Component<any, any>
};
}
interface ClassicComponent<P, S> extends Component<P, S> {
replaceState(nextState: S, callback?: () => any): void;
isMounted(): boolean;
getInitialState?(): S;
}
interface DOMComponent<P> extends ClassicComponent<P, any> {
tagName: string;
}
type HTMLComponent = DOMComponent<HTMLAttributes>;
type SVGComponent = DOMComponent<SVGAttributes>;
interface ChildContextProvider<CC> {
getChildContext(): CC;
}
//
// Class Interfaces
// ----------------------------------------------------------------------
interface ComponentClass<P> {
new(props?: P, context?: any): Component<P, any>;
propTypes?: ValidationMap<P>;
contextTypes?: ValidationMap<any>;
childContextTypes?: ValidationMap<any>;
defaultProps?: P;
}
interface ClassicComponentClass<P> extends ComponentClass<P> {
new(props?: P, context?: any): ClassicComponent<P, any>;
getDefaultProps?(): P;
displayName?: string;
}
//
// Component Specs and Lifecycle
// ----------------------------------------------------------------------
interface ComponentLifecycle<P, S> {
componentWillMount?(): void;
componentDidMount?(): void;
componentWillReceiveProps?(nextProps: P, nextContext: any): void;
shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean;
componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void;
componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void;
componentWillUnmount?(): void;
}
interface Mixin<P, S> extends ComponentLifecycle<P, S> {
mixins?: Mixin<P, S>;
statics?: {
[key: string]: any;
};
displayName?: string;
propTypes?: ValidationMap<any>;
contextTypes?: ValidationMap<any>;
childContextTypes?: ValidationMap<any>
getDefaultProps?(): P;
getInitialState?(): S;
}
interface ComponentSpec<P, S> extends Mixin<P, S> {
render(): ReactElement<any>;
[propertyName: string]: any;
}
//
// Event System
// ----------------------------------------------------------------------
interface SyntheticEvent {
bubbles: boolean;
cancelable: boolean;
currentTarget: EventTarget;
defaultPrevented: boolean;
eventPhase: number;
isTrusted: boolean;
nativeEvent: Event;
preventDefault(): void;
stopPropagation(): void;
persist(): void;
target: EventTarget;
timeStamp: Date;
type: string;
}
interface DragEvent extends SyntheticEvent {
dataTransfer: DataTransfer;
}
interface ClipboardEvent extends SyntheticEvent {
clipboardData: DataTransfer;
}
interface KeyboardEvent extends SyntheticEvent {
altKey: boolean;
charCode: number;
ctrlKey: boolean;
getModifierState(key: string): boolean;
key: string;
keyCode: number;
locale: string;
location: number;
metaKey: boolean;
repeat: boolean;
shiftKey: boolean;
which: number;
}
interface FocusEvent extends SyntheticEvent {
relatedTarget: EventTarget;
}
interface FormEvent extends SyntheticEvent {
}
interface MouseEvent extends SyntheticEvent {
altKey: boolean;
button: number;
buttons: number;
clientX: number;
clientY: number;
ctrlKey: boolean;
getModifierState(key: string): boolean;
metaKey: boolean;
pageX: number;
pageY: number;
relatedTarget: EventTarget;
screenX: number;
screenY: number;
shiftKey: boolean;
}
interface TouchEvent extends SyntheticEvent {
altKey: boolean;
changedTouches: TouchList;
ctrlKey: boolean;
getModifierState(key: string): boolean;
metaKey: boolean;
shiftKey: boolean;
targetTouches: TouchList;
locationX?: number;
locationY?: number;
pageX?: number;
pageY?: number;
touches: TouchList;
}
interface UIEvent extends SyntheticEvent {
detail: number;
view: AbstractView;
}
interface WheelEvent extends MouseEvent {
deltaMode: number;
deltaX: number;
deltaY: number;
deltaZ: number;
}
//
// Event Handler Types
// ----------------------------------------------------------------------
interface EventHandler<E extends SyntheticEvent> {
(event: E): void;
}
interface DragEventHandler extends EventHandler<DragEvent> {}
interface ClipboardEventHandler extends EventHandler<ClipboardEvent> {}
interface KeyboardEventHandler extends EventHandler<KeyboardEvent> {}
interface FocusEventHandler extends EventHandler<FocusEvent> {}
interface FormEventHandler extends EventHandler<FormEvent> {}
interface MouseEventHandler extends EventHandler<MouseEvent> {}
interface TouchEventHandler extends EventHandler<TouchEvent> {}
interface UIEventHandler extends EventHandler<UIEvent> {}
interface WheelEventHandler extends EventHandler<WheelEvent> {}
//
// Props / DOM Attributes
// ----------------------------------------------------------------------
interface Props<T> {
children?: ReactNode;
key?: string | number;
ref?: string | ((component: T) => any);
}
interface DOMAttributesBase<T> extends Props<T> {
onCopy?: ClipboardEventHandler;
onCut?: ClipboardEventHandler;
onPaste?: ClipboardEventHandler;
onKeyDown?: KeyboardEventHandler;
onKeyPress?: KeyboardEventHandler;
onKeyUp?: KeyboardEventHandler;
onFocus?: FocusEventHandler;
onBlur?: FocusEventHandler;
onChange?: FormEventHandler;
onInput?: FormEventHandler;
onSubmit?: FormEventHandler;
onClick?: MouseEventHandler;
onContextMenu?: MouseEventHandler;
onDoubleClick?: MouseEventHandler;
onDrag?: DragEventHandler;
onDragEnd?: DragEventHandler;
onDragEnter?: DragEventHandler;
onDragExit?: DragEventHandler;
onDragLeave?: DragEventHandler;
onDragOver?: DragEventHandler;
onDragStart?: DragEventHandler;
onDrop?: DragEventHandler;
onMouseDown?: MouseEventHandler;
onMouseEnter?: MouseEventHandler;
onMouseLeave?: MouseEventHandler;
onMouseMove?: MouseEventHandler;
onMouseOut?: MouseEventHandler;
onMouseOver?: MouseEventHandler;
onMouseUp?: MouseEventHandler;
onTouchCancel?: TouchEventHandler;
onTouchEnd?: TouchEventHandler;
onTouchMove?: TouchEventHandler;
onTouchStart?: TouchEventHandler;
onScroll?: UIEventHandler;
onWheel?: WheelEventHandler;
className?: string;
id?: string;
dangerouslySetInnerHTML?: {
__html: string;
};
}
interface DOMAttributes extends DOMAttributesBase<DOMComponent<any>> {
}
// This interface is not complete. Only properties accepting
// unitless numbers are listed here (see CSSProperty.js in React)
interface CSSProperties {
boxFlex?: number;
boxFlexGroup?: number;
columnCount?: number;
flex?: number | string;
flexGrow?: number;
flexShrink?: number;
fontWeight?: number | string;
lineClamp?: number;
lineHeight?: number | string;
opacity?: number;
order?: number;
orphans?: number;
widows?: number;
zIndex?: number;
zoom?: number;
fontSize?: number | string;
// SVG-related properties
fillOpacity?: number;
strokeOpacity?: number;
strokeWidth?: number;
[propertyName: string]: any;
}
interface HTMLAttributesBase<T> extends DOMAttributesBase<T> {
accept?: string;
acceptCharset?: string;
accessKey?: string;
action?: string;
allowFullScreen?: boolean;
allowTransparency?: boolean;
alt?: string;
async?: boolean;
autoComplete?: boolean;
autoFocus?: boolean;
autoPlay?: boolean;
cellPadding?: number | string;
cellSpacing?: number | string;
charSet?: string;
checked?: boolean;
classID?: string;
cols?: number;
colSpan?: number;
content?: string;
contentEditable?: boolean;
contextMenu?: string;
controls?: any;
coords?: string;
crossOrigin?: string;
data?: string;
dateTime?: string;
defaultChecked?: boolean;
defaultValue?: string;
defer?: boolean;
dir?: string;
disabled?: boolean;
download?: any;
draggable?: boolean;
encType?: string;
form?: string;
formAction?: string;
formEncType?: string;
formMethod?: string;
formNoValidate?: boolean;
formTarget?: string;
frameBorder?: number | string;
headers?: string;
height?: number | string;
hidden?: boolean;
high?: number;
href?: string;
hrefLang?: string;
htmlFor?: string;
httpEquiv?: string;
icon?: string;
label?: string;
lang?: string;
list?: string;
loop?: boolean;
low?: number;
manifest?: string;
marginHeight?: number;
marginWidth?: number;
max?: number | string;
maxLength?: number;
media?: string;
mediaGroup?: string;
method?: string;
min?: number | string;
multiple?: boolean;
muted?: boolean;
name?: string;
noValidate?: boolean;
open?: boolean;
optimum?: number;
pattern?: string;
placeholder?: string;
poster?: string;
preload?: string;
radioGroup?: string;
readOnly?: boolean;
rel?: string;
required?: boolean;
role?: string;
rows?: number;
rowSpan?: number;
sandbox?: string;
scope?: string;
scoped?: boolean;
scrolling?: string;
seamless?: boolean;
selected?: boolean;
shape?: string;
size?: number;
sizes?: string;
span?: number;
spellCheck?: boolean;
src?: string;
srcDoc?: string;
srcSet?: string;
start?: number;
step?: number | string;
style?: any;
tabIndex?: number;
target?: string;
title?: string;
type?: string;
useMap?: string;
value?: string;
width?: number | string;
wmode?: string;
// Non-standard Attributes
autoCapitalize?: boolean;
autoCorrect?: boolean;
property?: string;
itemProp?: string;
itemScope?: boolean;
itemType?: string;
unselectable?: boolean;
}
interface HTMLAttributes extends HTMLAttributesBase<HTMLComponent> {
}
interface MediaHTMLAttributes extends HTMLAttributes {
onLoad?: EventHandler<SyntheticEvent>;
onError?: EventHandler<SyntheticEvent>;
}
interface VideoHTMLAttributes extends HTMLAttributes {
onLoadedData?: EventHandler<SyntheticEvent>;
onError?: EventHandler<SyntheticEvent>;
onCanPlay?: () => void;
onCanPlayThrough?: () => void;
onEnded?: () => void;
}
interface IframeHTMLAttributes extends HTMLAttributes {
onLoad?: EventHandler<SyntheticEvent>;
}
interface InputHTMLAttributes extends HTMLAttributes {
editable?: boolean;
}
interface SVGElementAttributes extends HTMLAttributes {
viewBox?: string;
preserveAspectRatio?: string;
}
interface SVGAttributes extends DOMAttributes {
ref?: string | ((component: SVGComponent) => void);
cx?: number | string;
cy?: number | string;
d?: string;
dx?: number | string;
dy?: number | string;
fill?: string;
fillOpacity?: number | string;
fontFamily?: string;
fontSize?: number | string;
fx?: number | string;
fy?: number | string;
gradientTransform?: string;
gradientUnits?: string;
height?: number | string;
markerEnd?: string;
markerMid?: string;
markerStart?: string;
offset?: number | string;
opacity?: number | string;
patternContentUnits?: string;
patternUnits?: string;
points?: string;
preserveAspectRatio?: string;
r?: number | string;
rx?: number | string;
ry?: number | string;
spreadMethod?: string;
stopColor?: string;
stopOpacity?: number | string;
stroke?: string;
strokeDasharray?: string;
strokeLinecap?: string;
strokeMiterlimit?: string;
strokeOpacity?: number | string;
strokeWidth?: number | string;
textAnchor?: string;
transform?: string;
version?: string;
viewBox?: string;
width?: number | string;
x1?: number | string;
x2?: number | string;
x?: number | string;
y1?: number | string;
y2?: number | string
y?: number | string;
}
interface SVGAnimateAttributes extends DOMAttributes {
attributeName: string;
dur: string;
repeatCount: string;
from?: number;
to?: number;
values?: string;
}
interface WebViewHTMLAttributes extends HTMLAttributes {
is?: any
src?: string
autosize?: boolean
disablewebsecurity?: boolean
httpreferrer?: string
nodeintegration?: boolean
plugins?: boolean
preload?: string
useragent?: string
partition?: string
allowpopups?: boolean
webpreferences?: string
blinkfeatures?: string
disableblinkfeatures?: string
guestinstance?: string
}
//
// React.DOM
// ----------------------------------------------------------------------
interface ReactDOM {
// HTML
a: HTMLFactory;
abbr: HTMLFactory;
address: HTMLFactory;
area: HTMLFactory;
article: HTMLFactory;
aside: HTMLFactory;
audio: HTMLFactory;
b: HTMLFactory;
base: HTMLFactory;
bdi: HTMLFactory;
bdo: HTMLFactory;
big: HTMLFactory;
blockquote: HTMLFactory;
body: HTMLFactory;
br: HTMLFactory;
button: HTMLFactory;
canvas: HTMLFactory;
caption: HTMLFactory;
cite: HTMLFactory;
code: HTMLFactory;
col: HTMLFactory;
colgroup: HTMLFactory;
data: HTMLFactory;
datalist: HTMLFactory;
dd: HTMLFactory;
del: HTMLFactory;
details: HTMLFactory;
dfn: HTMLFactory;
dialog: HTMLFactory;
div: HTMLFactory;
dl: HTMLFactory;
dt: HTMLFactory;
em: HTMLFactory;
embed: HTMLFactory;
fieldset: HTMLFactory;
figcaption: HTMLFactory;
figure: HTMLFactory;
footer: HTMLFactory;
form: HTMLFactory;
h1: HTMLFactory;
h2: HTMLFactory;
h3: HTMLFactory;
h4: HTMLFactory;
h5: HTMLFactory;
h6: HTMLFactory;
head: HTMLFactory;
header: HTMLFactory;
hr: HTMLFactory;
html: HTMLFactory;
i: HTMLFactory;
iframe: HTMLFactory;
img: HTMLFactory;
input: HTMLFactory;
ins: HTMLFactory;
kbd: HTMLFactory;
keygen: HTMLFactory;
label: HTMLFactory;
legend: HTMLFactory;
li: HTMLFactory;
link: HTMLFactory;
main: HTMLFactory;
map: HTMLFactory;
mark: HTMLFactory;
menu: HTMLFactory;
menuitem: HTMLFactory;
meta: HTMLFactory;
meter: HTMLFactory;
nav: HTMLFactory;
noscript: HTMLFactory;
object: HTMLFactory;
ol: HTMLFactory;
optgroup: HTMLFactory;
option: HTMLFactory;
output: HTMLFactory;
p: HTMLFactory;
param: HTMLFactory;
picture: HTMLFactory;
pre: HTMLFactory;
progress: HTMLFactory;
q: HTMLFactory;
rp: HTMLFactory;
rt: HTMLFactory;
ruby: HTMLFactory;
s: HTMLFactory;
samp: HTMLFactory;
script: HTMLFactory;
section: HTMLFactory;
select: HTMLFactory;
small: HTMLFactory;
source: HTMLFactory;
span: HTMLFactory;
strong: HTMLFactory;
style: HTMLFactory;
sub: HTMLFactory;
summary: HTMLFactory;
sup: HTMLFactory;
table: HTMLFactory;
tbody: HTMLFactory;
td: HTMLFactory;
textarea: HTMLFactory;
tfoot: HTMLFactory;
th: HTMLFactory;
thead: HTMLFactory;
time: HTMLFactory;
title: HTMLFactory;
tr: HTMLFactory;
track: HTMLFactory;
u: HTMLFactory;
ul: HTMLFactory;
"var": HTMLFactory;
video: HTMLFactory;
wbr: HTMLFactory;
// SVG
svg: SVGElementFactory;
circle: SVGFactory;
defs: SVGFactory;
ellipse: SVGFactory;
g: SVGFactory;
line: SVGFactory;
linearGradient: SVGFactory;
mask: SVGFactory;
path: SVGFactory;
pattern: SVGFactory;
polygon: SVGFactory;
polyline: SVGFactory;
radialGradient: SVGFactory;
rect: SVGFactory;
stop: SVGFactory;
text: SVGFactory;
tspan: SVGFactory;
}
//
// React.PropTypes
// ----------------------------------------------------------------------
interface Validator<T> {
(object: T, key: string, componentName: string): Error | null;
}
interface Requireable<T> extends Validator<T> {
isRequired: Validator<T>;
}
interface ValidationMap<T> {
[key: string]: Validator<T>;
}
interface ReactPropTypes {
any: Requireable<any>;
array: Requireable<any>;
bool: Requireable<any>;
func: Requireable<any>;
number: Requireable<any>;
object: Requireable<any>;
string: Requireable<any>;
node: Requireable<any>;
element: Requireable<any>;
instanceOf(expectedClass: {}): Requireable<any>;
oneOf(types: any[]): Requireable<any>;
oneOfType(types: Validator<any>[]): Requireable<any>;
arrayOf(type: Validator<any>): Requireable<any>;
objectOf(type: Validator<any>): Requireable<any>;
shape(type: ValidationMap<any>): Requireable<any>;
}
//
// React.Children
// ----------------------------------------------------------------------
interface ReactChildren {
map<T>(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T };
forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void;
count(children: ReactNode): number;
only(children: ReactNode): ReactElement<any>;
toArray(children: ReactNode): ReactChild[];
}
//
// Browser Interfaces
// https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts
// ----------------------------------------------------------------------
interface AbstractView {
styleMedia: StyleMedia;
document: Document;
}
interface Touch {
identifier: number;
target: EventTarget;
locationX: number;
locationY: number;
screenX: number;
screenY: number;
clientX: number;
clientY: number;
pageX: number;
pageY: number;
}
interface TouchList {
[index: number]: Touch;
length: number;
item(index: number): Touch;
identifiedTouch(identifier: number): Touch;
}
}
declare module "react" {
export = __React;
}
declare namespace JSX {
import React = __React;
interface Element extends React.ReactElement<any> { }
interface ElementClass extends React.Component<any, any> {
render(): JSX.Element|null;
}
interface ElementAttributesProperty { props: {}; }
interface IntrinsicElements {
// HTML
a: React.HTMLAttributes;
abbr: React.HTMLAttributes;
address: React.HTMLAttributes;
area: React.HTMLAttributes;
article: React.HTMLAttributes;
aside: React.HTMLAttributes;
audio: React.HTMLAttributes;
b: React.HTMLAttributes;
base: React.HTMLAttributes;
bdi: React.HTMLAttributes;
bdo: React.HTMLAttributes;
big: React.HTMLAttributes;
blockquote: React.HTMLAttributes;
body: React.HTMLAttributes;
br: React.HTMLAttributes;
button: React.HTMLAttributes;
canvas: React.HTMLAttributes;
caption: React.HTMLAttributes;
cite: React.HTMLAttributes;
code: React.HTMLAttributes;
col: React.HTMLAttributes;
colgroup: React.HTMLAttributes;
data: React.HTMLAttributes;
datalist: React.HTMLAttributes;
dd: React.HTMLAttributes;
del: React.HTMLAttributes;
details: React.HTMLAttributes;
dfn: React.HTMLAttributes;
dialog: React.HTMLAttributes;
div: React.HTMLAttributes;
dl: React.HTMLAttributes;
dt: React.HTMLAttributes;
em: React.HTMLAttributes;
embed: React.HTMLAttributes;
fieldset: React.HTMLAttributes;
figcaption: React.HTMLAttributes;
figure: React.HTMLAttributes;
footer: React.HTMLAttributes;
form: React.HTMLAttributes;
h1: React.HTMLAttributes;
h2: React.HTMLAttributes;
h3: React.HTMLAttributes;
h4: React.HTMLAttributes;
h5: React.HTMLAttributes;
h6: React.HTMLAttributes;
head: React.HTMLAttributes;
header: React.HTMLAttributes;
hr: React.HTMLAttributes;
html: React.HTMLAttributes;
i: React.HTMLAttributes;
iframe: React.IframeHTMLAttributes;
img: React.MediaHTMLAttributes;
input: React.InputHTMLAttributes;
ins: React.HTMLAttributes;
kbd: React.HTMLAttributes;
keygen: React.HTMLAttributes;
label: React.HTMLAttributes;
legend: React.HTMLAttributes;
li: React.HTMLAttributes;
link: React.HTMLAttributes;
main: React.HTMLAttributes;
map: React.HTMLAttributes;
mark: React.HTMLAttributes;
menu: React.HTMLAttributes;
menuitem: React.HTMLAttributes;
meta: React.HTMLAttributes;
meter: React.HTMLAttributes;
nav: React.HTMLAttributes;
noscript: React.HTMLAttributes;
object: React.HTMLAttributes;
ol: React.HTMLAttributes;
optgroup: React.HTMLAttributes;
option: React.HTMLAttributes;
output: React.HTMLAttributes;
p: React.HTMLAttributes;
param: React.HTMLAttributes;
picture: React.HTMLAttributes;
pre: React.HTMLAttributes;
progress: React.HTMLAttributes;
q: React.HTMLAttributes;
rp: React.HTMLAttributes;
rt: React.HTMLAttributes;
ruby: React.HTMLAttributes;
s: React.HTMLAttributes;
samp: React.HTMLAttributes;
script: React.HTMLAttributes;
section: React.HTMLAttributes;
select: React.HTMLAttributes;
small: React.HTMLAttributes;
source: React.HTMLAttributes;
span: React.HTMLAttributes;
strong: React.HTMLAttributes;
style: React.HTMLAttributes;
sub: React.HTMLAttributes;
summary: React.HTMLAttributes;
sup: React.HTMLAttributes;
table: React.HTMLAttributes;
tbody: React.HTMLAttributes;
td: React.HTMLAttributes;
textarea: React.InputHTMLAttributes;
tfoot: React.HTMLAttributes;
th: React.HTMLAttributes;
thead: React.HTMLAttributes;
time: React.HTMLAttributes;
title: React.HTMLAttributes;
tr: React.HTMLAttributes;
track: React.HTMLAttributes;
u: React.HTMLAttributes;
ul: React.HTMLAttributes;
"var": React.HTMLAttributes;
video: React.VideoHTMLAttributes;
wbr: React.HTMLAttributes;
webview: React.WebViewHTMLAttributes;
// SVG
svg: React.SVGElementAttributes;
animate: React.SVGAnimateAttributes;
circle: React.SVGAttributes;
defs: React.SVGAttributes;
ellipse: React.SVGAttributes;
g: React.SVGAttributes;
line: React.SVGAttributes;
linearGradient: React.SVGAttributes;
mask: React.SVGAttributes;
path: React.SVGAttributes;
pattern: React.SVGAttributes;
polygon: React.SVGAttributes;
polyline: React.SVGAttributes;
radialGradient: React.SVGAttributes;
rect: React.SVGAttributes;
stop: React.SVGAttributes;
text: React.SVGAttributes;
tspan: React.SVGAttributes;
}
}

Просмотреть файл

@ -58,7 +58,7 @@ export class Button extends React.Component<Types.ButtonProps, {}> {
// NOTE: We use tabIndex=0 to support focus.
return (
<button
style={ this._getStyles() }
style={ this._getStyles() as any }
role={ ariaRole }
title={ this.props.title }
tabIndex={ this.props.tabIndex }

Просмотреть файл

@ -265,7 +265,7 @@ export class Scrollbar {
this._container.removeChild(rtlbox);
}
private _prevent(e: React.SyntheticEvent) {
private _prevent(e: React.SyntheticEvent<any>) {
e.preventDefault();
}
@ -287,7 +287,7 @@ export class Scrollbar {
}
}
private _handleDrag(e: React.MouseEvent) {
private _handleDrag(e: React.MouseEvent<any>) {
if (this._dragIsVertical) {
this._viewport.scrollTop = (e.pageY - this._verticalBar.dragOffset!!!) * this._verticalBar.slider2Scroll!!!;
} else {
@ -295,7 +295,7 @@ export class Scrollbar {
}
}
private _startDrag(dragIsVertical: boolean, e: React.MouseEvent) {
private _startDrag(dragIsVertical: boolean, e: React.MouseEvent<any>) {
if (!this._dragging) {
window.addEventListener('mouseup', this._stopDragCallback);
window.addEventListener('mousemove', this._handleDragCallback);
@ -319,7 +319,7 @@ export class Scrollbar {
this._dragging = false;
}
private _handleWheel(e: React.WheelEvent) {
private _handleWheel(e: React.WheelEvent<any>) {
// Always prefer the vertical axis if present. User can override with the control key.
if (this._hasVertical) {
this._viewport.scrollTop = this._normalizeDelta(e) + this._viewport.scrollTop;
@ -328,11 +328,11 @@ export class Scrollbar {
}
}
private _handleMouseDown(e: React.MouseEvent) {
private _handleMouseDown(e: React.MouseEvent<any>) {
this._prevent(e);
}
private _normalizeDelta(e: React.WheelEvent) {
private _normalizeDelta(e: React.WheelEvent<any>) {
if (e.deltaY) {
return e.deltaY > 0 ? 100 : -100;
}

Просмотреть файл

@ -120,9 +120,9 @@ export class GestureView extends RX.ViewBase<Types.GestureViewProps, {}> {
);
}
private _setContainerRef = (container: React.DOMComponent<React.HTMLAttributes>) => {
private _setContainerRef = (container: any) => {
// safe since div refs resolve into HTMLElement and not react element.
this._container = container as any as HTMLElement;
this._container = container as HTMLElement;
}
private _getStyles(): any {
@ -246,7 +246,7 @@ export class GestureView extends RX.ViewBase<Types.GestureViewProps, {}> {
return isPan;
}
private _onWheel = (e: React.WheelEvent) => {
private _onWheel = (e: React.WheelEvent<any>) => {
if (this.props.onScrollWheel) {
const clientRect = this._getGestureViewClientRect();
const scrollWheelEvent: Types.ScrollWheelGestureState = {

Просмотреть файл

@ -305,7 +305,7 @@ export class Image extends React.Component<Types.ImageProps, ImageState> {
if (this.state.showImgTag) {
optionalImg = (
<img
style={ _styles.image }
style={ _styles.image as any }
src={ this.state.displayUrl }
alt={ this.props.accessibilityLabel }
onLoad={ this._onLoad }

Просмотреть файл

@ -52,7 +52,7 @@ export class Link extends React.Component<Types.LinkProps, {}> {
// See: https://mathiasbynens.github.io/rel-noopener/
return (
<a
style={ this._getStyles() }
style={ this._getStyles() as any }
title={ this.props.title }
href={ this.props.url }
target='_blank'
@ -89,7 +89,7 @@ export class Link extends React.Component<Types.LinkProps, {}> {
return combinedStyles;
}
private _onClick = (e: React.MouseEvent) => {
private _onClick = (e: React.MouseEvent<any>) => {
e.stopPropagation();
if (this.props.onPress) {

Просмотреть файл

@ -36,7 +36,7 @@ export class ModalContainer extends React.Component<Types.CommonProps, {}> {
render() {
return (
<div style={ _styles.modalContainerStyle }>
<div style={ _styles.modalContainerStyle as any }>
{ this.props.children }
</div>
);

Просмотреть файл

@ -16,13 +16,17 @@ import Types = require('../common/Types');
export class Picker extends RX.Picker {
render() {
return (
<select value={ this.props.selectedValue } onChange={ this.onValueChange } style={ this.props.style }>
<select
style={ this.props.style as any }
value={ this.props.selectedValue }
onChange={ this._onValueChange }
>
{ _.map(this.props.items, (i, idx) => <option value={ i.value } key={ idx }>{ i.label }</option> ) }
</select>
);
}
onValueChange = (e: Types.SyntheticEvent) => {
private _onValueChange = (e: Types.SyntheticEvent) => {
const selectEl = e.target as HTMLSelectElement;
const selectedValue = selectEl.value;
const selectedItemPosition = _.findIndex(this.props.items, i => i.value === selectedValue);

Просмотреть файл

@ -307,7 +307,7 @@ export class RootView extends React.Component<RootViewProps, RootViewState> {
{ optionalModal }
{ optionalPopup }
<div
style={ _styles.liveRegionContainer }
style={ _styles.liveRegionContainer as any }
aria-live={ AccessibilityUtil.accessibilityLiveRegionToString(Types.AccessibilityLiveRegion.Polite) }
aria-atomic={ 'true' }
>
@ -444,7 +444,7 @@ export class RootView extends React.Component<RootViewProps, RootViewState> {
Input.dispatchKeyUp(e as any);
}
private _onMouseEnter(e: React.MouseEvent) {
private _onMouseEnter(e: React.MouseEvent<any>) {
this.setState({
isMouseInPopup: true
});
@ -452,7 +452,7 @@ export class RootView extends React.Component<RootViewProps, RootViewState> {
this._stopHidePopupTimer();
}
private _onMouseLeave(e: React.MouseEvent) {
private _onMouseLeave(e: React.MouseEvent<any>) {
this.setState({
isMouseInPopup: false
});

Просмотреть файл

@ -168,12 +168,12 @@ export class ScrollView extends ViewBase<Types.ScrollViewProps, {}> implements R
}
}
protected _getContainerRef(): React.Component<any, any> {
protected _getContainerRef(): React.ReactInstance {
return this.refs['scrollView'];
}
// Throttled scroll handler
private _onScroll = _.throttle((e: React.SyntheticEvent) => {
private _onScroll = _.throttle((e: React.SyntheticEvent<any>) => {
if (this._customScrollbarEnabled) {
this._customScrollbar.update();
}
@ -227,7 +227,7 @@ export class ScrollView extends ViewBase<Types.ScrollViewProps, {}> implements R
onScroll={ this._onScroll }
onTouchStart={ this._onTouchStart }
onTouchEnd={ this._onTouchEnd }
style={ this._getContainerStyle() }
style={ this._getContainerStyle() as any }
>
{ this.props.children }
</div>
@ -258,7 +258,7 @@ export class ScrollView extends ViewBase<Types.ScrollViewProps, {}> implements R
ref='scrollView'
className={ scrollComponentClassNames.join(' ') }
onScroll={ this._onScroll }
style={ this._getContainerStyle() }
style={ this._getContainerStyle() as any }
onKeyDown={ this.props.onKeyPress }
onFocus={ this.props.onFocus }
onBlur={ this.props.onBlur }

Просмотреть файл

@ -72,7 +72,7 @@ export class Text extends React.Component<Types.TextProps, {}> {
if (this.props.selectable || typeof this.props.children !== 'string') {
return (
<div
style={ this._getStyles() }
style={ this._getStyles() as any }
aria-hidden={ isAriaHidden }
onClick={ this.props.onPress }
id={ this.props.id }
@ -87,7 +87,7 @@ export class Text extends React.Component<Types.TextProps, {}> {
// will be displayed as pseudo element.
return (
<div
style={ this._getStyles() }
style={ this._getStyles() as any }
aria-hidden={ isAriaHidden }
onClick={ this.props.onPress }
onContextMenu={ this.props.onContextMenu }

Просмотреть файл

@ -78,10 +78,10 @@ export class TextInput extends React.Component<Types.TextInputProps, TextInputSt
if (this.props.multiline) {
return (
<textarea
style={ combinedStyles }
style={ combinedStyles as any }
value={ this.state.inputValue }
autoCorrect={ this.props.autoCorrect }
autoCorrect={ this.props.autoCorrect === false ? 'off' : undefined }
spellCheck={ spellCheck }
disabled={ !editable }
maxLength={ this.props.maxLength }
@ -102,10 +102,10 @@ export class TextInput extends React.Component<Types.TextInputProps, TextInputSt
} else {
return (
<input
style={ combinedStyles }
style={ combinedStyles as any }
value={ this.state.inputValue }
autoCorrect={ this.props.autoCorrect }
autoCorrect={ this.props.autoCorrect === false ? 'off' : undefined }
spellCheck={ spellCheck }
disabled={ !editable }
maxLength={ this.props.maxLength }
@ -134,7 +134,7 @@ export class TextInput extends React.Component<Types.TextInputProps, TextInputSt
this._checkSelectionChanged();
}
private _onInput = (e: React.FormEvent) => {
private _onInput = (e: React.FormEvent<any>) => {
if (!e.defaultPrevented) {
let el = ReactDOM.findDOMNode<HTMLInputElement>(this);
if (el) {

Просмотреть файл

@ -124,7 +124,7 @@ export class View extends ViewBase<Types.ViewProps, {}> {
return null;
}
let initResizer = (key: 'grow' | 'shrink', ref: React.DOMComponent<React.HTMLAttributes>) => {
let initResizer = (key: 'grow' | 'shrink', ref: any) => {
const cur: HTMLElement|undefined = this._resizeDetectorNodes[key];
const element = ReactDOM.findDOMNode<HTMLElement>(ref);
@ -143,21 +143,21 @@ export class View extends ViewBase<Types.ViewProps, {}> {
(
<div
key={ 'grow' }
style={ _styles.resizeDetectorContainerStyles }
style={ _styles.resizeDetectorContainerStyles as any }
ref={ (ref) => initResizer('grow', ref) }
onScroll={ () => this._resizeDetectorOnScroll() }>
<div style={ _styles.resizeGrowDetectorStyles }></div>
<div style={ _styles.resizeGrowDetectorStyles as any } />
</div>
),
(
<div
key={ 'shrink' }
style={ _styles.resizeDetectorContainerStyles }
style={ _styles.resizeDetectorContainerStyles as any }
ref={ (ref) => initResizer('shrink', ref) }
onScroll={ () => this._resizeDetectorOnScroll() }>
<div style={ _styles.resizeShrinkDetectorStyles }></div>
<div style={ _styles.resizeShrinkDetectorStyles as any } />
</div>
)
];
@ -214,7 +214,7 @@ export class View extends ViewBase<Types.ViewProps, {}> {
return childContext;
}
protected _getContainerRef(): React.Component<any, any> {
protected _getContainerRef(): React.ReactInstance {
return this;
}

Просмотреть файл

@ -28,7 +28,7 @@ export abstract class ViewBase<P extends Types.ViewProps, S> extends RX.ViewBase
private static _appActivationState = Types.AppActivationState.Active;
abstract render(): JSX.Element;
protected abstract _getContainerRef(): React.Component<any, any>;
protected abstract _getContainerRef(): React.ReactInstance;
private _isMounted = false;
private _container: HTMLElement|undefined;

Просмотреть файл

@ -75,10 +75,10 @@ export class WebView extends RX.ViewBase<Types.WebViewProps, WebViewState> imple
return (
<View style={ _styles.webViewContainer }>
<iframe
ref='iframe'
ref={ 'iframe' }
name={ this.state.webFrameIdentifier }
id={ this.state.webFrameIdentifier }
style={ styles }
style={ styles as any }
src={ this.props.url }
onLoad={ this._onLoad }
sandbox={ this._sandboxToStringValue(sandbox) }

Просмотреть файл

@ -14,7 +14,7 @@ import ReactDOM = require('react-dom');
import MonitorListEdits = require('./MonitorListEdits');
import executeTransition from '../animated/executeTransition';
export interface AnimateListEditsProps extends React.HTMLAttributes {
export interface AnimateListEditsProps {
animateChildEnter?: boolean;
animateChildLeave?: boolean;
animateChildMove?: boolean;

Просмотреть файл

@ -32,7 +32,9 @@ function extractChildrenKeys(children: React.ReactNode|undefined): ChildKey[] {
childReactElement.key !== undefined && childReactElement.key !== null,
'Children passed to a `View` with child animations enabled must have a `key`'
);
keys.push(childReactElement.key);
if (childReactElement.key !== null) {
keys.push(childReactElement.key);
}
}
});
}
@ -57,7 +59,10 @@ function createChildrenMap(children: React.ReactNode|undefined): ChildrenMap {
'key' in childReactElement,
'Children passed to a `View` with child animations enabled must have a `key`'
);
map[childReactElement['key']] = childReactElement;
let index = childReactElement['key'];
if (index !== null) {
map[index] = childReactElement;
}
}
});
}
@ -121,7 +126,7 @@ interface MountedChildrenRef {
domElement: HTMLElement;
}
export interface MonitorListEditsProps extends React.HTMLAttributes {
export interface MonitorListEditsProps extends React.HTMLAttributes<any> {
// Called when list edits are detected. Gives you an opportunity to animate them.
// Call `done` when the animations are finished. Until `done` is called, the component
// will refuse to rerender.
@ -210,7 +215,7 @@ export class MonitorListEdits extends React.Component<MonitorListEditsProps, {}>
this._childrenToRender = [];
_.each(this.props.children, child => {
if (child) {
let childElement = child as React.ReactElement<any>;
let childElement = child as any;
let refData = this._refReplacementCache[childElement.key];
// Reuse the cached replacement ref function instead of recreating it every render, unless the child's ref changes.
@ -258,12 +263,12 @@ export class MonitorListEdits extends React.Component<MonitorListEditsProps, {}>
let added: IAddEdit[] = phaseInfo.added.map(child => {
return {
element: this._itemRefs[child.key].reactElement
element: this._itemRefs[(child as any).key].reactElement
};
});
let removed: IRemoveEdit[] = phaseInfo.removed.map(child => {
let key = child.key;
let key = child.key as any;
let prevPos = prevPositions[key];
let nextPos = nextPositions[key];
@ -276,7 +281,7 @@ export class MonitorListEdits extends React.Component<MonitorListEditsProps, {}>
let moved: IMoveEdit[] = [];
phaseInfo.other.map(child => {
let key = child.key;
let key = child.key as any;
let prevPos = prevPositions[key];
let nextPos = nextPositions[key];
if (prevPos.left !== nextPos.left || prevPos.top !== nextPos.top) {
@ -300,13 +305,14 @@ export class MonitorListEdits extends React.Component<MonitorListEditsProps, {}>
this.forceUpdate();
}
phaseInfo.removed.forEach(child => {
delete this._refReplacementCache[child.key];
let key = child.key as any;
delete this._refReplacementCache[key];
});
});
}
}
private _saveRef(reactElement: React.ReactElement<any>, refValue: React.Component<any, any>) {
private _saveRef(reactElement: any, refValue: React.Component<any, any>) {
if (refValue === null) {
delete this._itemRefs[reactElement.key];
} else {
@ -324,7 +330,7 @@ export class MonitorListEdits extends React.Component<MonitorListEditsProps, {}>
// If the creator of the reactElement also provided a ref, call it.
if (typeof reactElement.ref === 'function') {
(reactElement as any).ref(refValue);
reactElement.ref(refValue);
}
}
}

Просмотреть файл

@ -136,7 +136,7 @@ export default class MouseResponder {
pageY: event.pageY,
velocityX: 0,
velocityY: 0,
timeStamp: new Date(),
timeStamp: Date.now(),
isComplete: false
};
@ -209,7 +209,7 @@ export default class MouseResponder {
}
private static _calcVelocity = (e: MouseEvent, gestureState: Types.PanGestureState) => {
const time = Date.now() - gestureState.timeStamp.getTime();
const time = Date.now() - gestureState.timeStamp;
const velocityX = (e.clientX - gestureState.initialClientX) / time;
const velocityY = (e.clientY - gestureState.initialClientY) / time;