diff --git a/types/rax/README.md b/types/rax/README.md new file mode 100644 index 0000000000..e272a1a2c2 --- /dev/null +++ b/types/rax/README.md @@ -0,0 +1,130 @@ +# @types/rax [![npm](https://img.shields.io/npm/v/@types/rax.svg)](https://www.npmjs.com/package/@types/rax) + +# Installation +``` +npm install --save @types/rax +``` + +# Config + +Add `node_modules/@types/rax` to your tsconifg.json file, like so: +```json +{ + "compilerOptions": { + "typeRoots": [ + "types", + ], + "paths": { + "rax": ["node_modules/@types/rax"] + } + } +} +``` + +# Usage + +## Hooks + +```tsx +import * as Rax from 'rax'; + +const createElement = Rax.createElement; + +// FunctionComponent +interface PersonProps { + name: string; + age: number; +} +const Person: Rax.FunctionComponent = (props) => { + return ( + + hello! I'm {props.name} and I'm {props.age} years old! + + ); +}; + +// FunctionComponent With Ref +export interface FancyButtonProps { + onClick: () => void; + children?: Rax.RaxNode; +} +export interface FancyButton { + getClickCount(): number; +} +export const FancyButton = Rax.forwardRef((props: FancyButtonProps, ref: Rax.Ref) => { + const [count, setCount] = Rax.useState(0); + + Rax.useImperativeHandle(ref, () => ({ + getClickCount() { + return count; + } + })); + + return ( +
{ + setCount(count + 1); + props.onClick(); + }} + > + {props.children} +
+ ); +}); + +interface AppState { + name: string; + age: number; +} + +type AppActions = { type: 'getOlder' } | { type: 'resetAge' }; + +function reducer(s: AppState, action: AppActions): AppState { + switch (action.type) { + case 'getOlder': + return { ...s, age: s.age + 1 }; + case 'resetAge': + return { ...s, age: 0 }; + } +} + +const initialState = { + name: 'Rax', + age: 18 +}; + +export function App() { + const [state, dispatch] = Rax.useReducer(reducer, initialState); + const birthdayRef = Rax.useRef(null); + + Rax.useLayoutEffect(() => { + if (birthdayRef.current !== null) { + birthdayRef.current.getClickCount(); + } else { + // this looks redundant but it ensures the type actually has "null" in it instead of "never" + // $ExpectType null + console.log(birthdayRef.current); + } + }); + + return ( + + + { + if (birthdayRef.current !== null) { + console.log(birthdayRef.current.getClickCount()); + } + dispatch({ type: 'getOlder' }); + }} + ref={birthdayRef} + > + Birthday time! + + dispatch({ type: 'resetAge' })}>Let's start over. + + ); +} + +export default App; +``` diff --git a/types/rax/global.d.ts b/types/rax/global.d.ts new file mode 100644 index 0000000000..c9ddef6712 --- /dev/null +++ b/types/rax/global.d.ts @@ -0,0 +1,145 @@ +/* +Warning: all of these interfaces are empty. If you want type definitions for various properties +(such as HTMLInputElement.prototype.value), you need to add `--lib DOM` (via command line or tsconfig.json). +*/ + +interface Event { } +interface AnimationEvent extends Event { } +interface ClipboardEvent extends Event { } +interface CompositionEvent extends Event { } +interface DragEvent extends Event { } +interface FocusEvent extends Event { } +interface KeyboardEvent extends Event { } +interface MouseEvent extends Event { } +interface TouchEvent extends Event { } +interface PointerEvent extends Event { } +interface TransitionEvent extends Event { } +interface UIEvent extends Event { } +interface WheelEvent extends Event { } + +interface EventTarget { } +interface Document { } +interface DataTransfer { } +interface StyleMedia { } + +interface Element { } + +interface HTMLElement extends Element { } +interface HTMLAnchorElement extends HTMLElement { } +interface HTMLAreaElement extends HTMLElement { } +interface HTMLAudioElement extends HTMLElement { } +interface HTMLBaseElement extends HTMLElement { } +interface HTMLBodyElement extends HTMLElement { } +interface HTMLBRElement extends HTMLElement { } +interface HTMLButtonElement extends HTMLElement { } +interface HTMLCanvasElement extends HTMLElement { } +interface HTMLDataElement extends HTMLElement { } +interface HTMLDataListElement extends HTMLElement { } +interface HTMLDialogElement extends HTMLElement { } +interface HTMLDivElement extends HTMLElement { } +interface HTMLDListElement extends HTMLElement { } +interface HTMLEmbedElement extends HTMLElement { } +interface HTMLFieldSetElement extends HTMLElement { } +interface HTMLFormElement extends HTMLElement { } +interface HTMLHeadingElement extends HTMLElement { } +interface HTMLHeadElement extends HTMLElement { } +interface HTMLHRElement extends HTMLElement { } +interface HTMLHtmlElement extends HTMLElement { } +interface HTMLIFrameElement extends HTMLElement { } +interface HTMLImageElement extends HTMLElement { } +interface HTMLInputElement extends HTMLElement { } +interface HTMLModElement extends HTMLElement { } +interface HTMLLabelElement extends HTMLElement { } +interface HTMLLegendElement extends HTMLElement { } +interface HTMLLIElement extends HTMLElement { } +interface HTMLLinkElement extends HTMLElement { } +interface HTMLMapElement extends HTMLElement { } +interface HTMLMetaElement extends HTMLElement { } +interface HTMLObjectElement extends HTMLElement { } +interface HTMLOListElement extends HTMLElement { } +interface HTMLOptGroupElement extends HTMLElement { } +interface HTMLOptionElement extends HTMLElement { } +interface HTMLParagraphElement extends HTMLElement { } +interface HTMLParamElement extends HTMLElement { } +interface HTMLPreElement extends HTMLElement { } +interface HTMLProgressElement extends HTMLElement { } +interface HTMLQuoteElement extends HTMLElement { } +interface HTMLScriptElement extends HTMLElement { } +interface HTMLSelectElement extends HTMLElement { } +interface HTMLSourceElement extends HTMLElement { } +interface HTMLSpanElement extends HTMLElement { } +interface HTMLStyleElement extends HTMLElement { } +interface HTMLTableElement extends HTMLElement { } +interface HTMLTableColElement extends HTMLElement { } +interface HTMLTableDataCellElement extends HTMLElement { } +interface HTMLTableHeaderCellElement extends HTMLElement { } +interface HTMLTableRowElement extends HTMLElement { } +interface HTMLTableSectionElement extends HTMLElement { } +interface HTMLTemplateElement extends HTMLElement { } +interface HTMLTextAreaElement extends HTMLElement { } +interface HTMLTitleElement extends HTMLElement { } +interface HTMLTrackElement extends HTMLElement { } +interface HTMLUListElement extends HTMLElement { } +interface HTMLVideoElement extends HTMLElement { } +interface HTMLWebViewElement extends HTMLElement { } + +interface SVGElement extends Element { } +interface SVGSVGElement extends SVGElement { } +interface SVGCircleElement extends SVGElement { } +interface SVGClipPathElement extends SVGElement { } +interface SVGDefsElement extends SVGElement { } +interface SVGDescElement extends SVGElement { } +interface SVGEllipseElement extends SVGElement { } +interface SVGFEBlendElement extends SVGElement { } +interface SVGFEColorMatrixElement extends SVGElement { } +interface SVGFEComponentTransferElement extends SVGElement { } +interface SVGFECompositeElement extends SVGElement { } +interface SVGFEConvolveMatrixElement extends SVGElement { } +interface SVGFEDiffuseLightingElement extends SVGElement { } +interface SVGFEDisplacementMapElement extends SVGElement { } +interface SVGFEDistantLightElement extends SVGElement { } +interface SVGFEDropShadowElement extends SVGElement { } +interface SVGFEFloodElement extends SVGElement { } +interface SVGFEFuncAElement extends SVGElement { } +interface SVGFEFuncBElement extends SVGElement { } +interface SVGFEFuncGElement extends SVGElement { } +interface SVGFEFuncRElement extends SVGElement { } +interface SVGFEGaussianBlurElement extends SVGElement { } +interface SVGFEImageElement extends SVGElement { } +interface SVGFEMergeElement extends SVGElement { } +interface SVGFEMergeNodeElement extends SVGElement { } +interface SVGFEMorphologyElement extends SVGElement { } +interface SVGFEOffsetElement extends SVGElement { } +interface SVGFEPointLightElement extends SVGElement { } +interface SVGFESpecularLightingElement extends SVGElement { } +interface SVGFESpotLightElement extends SVGElement { } +interface SVGFETileElement extends SVGElement { } +interface SVGFETurbulenceElement extends SVGElement { } +interface SVGFilterElement extends SVGElement { } +interface SVGForeignObjectElement extends SVGElement { } +interface SVGGElement extends SVGElement { } +interface SVGImageElement extends SVGElement { } +interface SVGLineElement extends SVGElement { } +interface SVGLinearGradientElement extends SVGElement { } +interface SVGMarkerElement extends SVGElement { } +interface SVGMaskElement extends SVGElement { } +interface SVGMetadataElement extends SVGElement { } +interface SVGPathElement extends SVGElement { } +interface SVGPatternElement extends SVGElement { } +interface SVGPolygonElement extends SVGElement { } +interface SVGPolylineElement extends SVGElement { } +interface SVGRadialGradientElement extends SVGElement { } +interface SVGRectElement extends SVGElement { } +interface SVGStopElement extends SVGElement { } +interface SVGSwitchElement extends SVGElement { } +interface SVGSymbolElement extends SVGElement { } +interface SVGTextElement extends SVGElement { } +interface SVGTextPathElement extends SVGElement { } +interface SVGTSpanElement extends SVGElement { } +interface SVGUseElement extends SVGElement { } +interface SVGViewElement extends SVGElement { } + +interface Text { } +interface TouchList { } +interface WebGLRenderingContext { } +interface WebGL2RenderingContext { } diff --git a/types/rax/index.d.ts b/types/rax/index.d.ts new file mode 100644 index 0000000000..8026e96743 --- /dev/null +++ b/types/rax/index.d.ts @@ -0,0 +1,2942 @@ +// Type definitions for Rax 1.0.0 +// Project: https://rax.js.org +// Definitions by: Solo Jiang +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +// for reference and documentation on how exactly to do it. + +/// + +import * as CSS from 'csstype'; +import * as PropTypes from 'prop-types'; +interface AnimationEvent extends Event {} +interface ClipboardEvent extends Event {} +interface CompositionEvent extends Event {} +interface DragEvent extends Event {} +interface FocusEvent extends Event {} +interface KeyboardEvent extends Event {} +interface MouseEvent extends Event {} +interface TouchEvent extends Event {} +interface PointerEvent extends Event {} +interface TransitionEvent extends Event {} +interface UIEvent extends Event {} +interface WheelEvent extends Event {} + +interface EventTarget {} +interface Document {} +interface DataTransfer {} +interface StyleMedia {} + +interface Element {} + +interface HTMLElement extends Element {} +interface HTMLAnchorElement extends HTMLElement {} +interface HTMLAreaElement extends HTMLElement {} +interface HTMLAudioElement extends HTMLElement {} +interface HTMLBaseElement extends HTMLElement {} +interface HTMLBodyElement extends HTMLElement {} +interface HTMLBRElement extends HTMLElement {} +interface HTMLButtonElement extends HTMLElement {} +interface HTMLCanvasElement extends HTMLElement {} +interface HTMLDataListElement extends HTMLElement {} +interface HTMLDialogElement extends HTMLElement {} +interface HTMLDivElement extends HTMLElement {} +interface HTMLDListElement extends HTMLElement {} +interface HTMLEmbedElement extends HTMLElement {} +interface HTMLFieldSetElement extends HTMLElement {} +interface HTMLFormElement extends HTMLElement {} +interface HTMLHeadingElement extends HTMLElement {} +interface HTMLHeadElement extends HTMLElement {} +interface HTMLHRElement extends HTMLElement {} +interface HTMLHtmlElement extends HTMLElement {} +interface HTMLIFrameElement extends HTMLElement {} +interface HTMLImageElement extends HTMLElement {} +interface HTMLInputElement extends HTMLElement {} +interface HTMLModElement extends HTMLElement {} +interface HTMLLabelElement extends HTMLElement {} +interface HTMLLegendElement extends HTMLElement {} +interface HTMLLIElement extends HTMLElement {} +interface HTMLLinkElement extends HTMLElement {} +interface HTMLMapElement extends HTMLElement {} +interface HTMLMetaElement extends HTMLElement {} +interface HTMLObjectElement extends HTMLElement {} +interface HTMLOListElement extends HTMLElement {} +interface HTMLOptGroupElement extends HTMLElement {} +interface HTMLOptionElement extends HTMLElement {} +interface HTMLParagraphElement extends HTMLElement {} +interface HTMLParamElement extends HTMLElement {} +interface HTMLPreElement extends HTMLElement {} +interface HTMLProgressElement extends HTMLElement {} +interface HTMLQuoteElement extends HTMLElement {} +interface HTMLScriptElement extends HTMLElement {} +interface HTMLSelectElement extends HTMLElement {} +interface HTMLSourceElement extends HTMLElement {} +interface HTMLSpanElement extends HTMLElement {} +interface HTMLStyleElement extends HTMLElement {} +interface HTMLTableElement extends HTMLElement {} +interface HTMLTableColElement extends HTMLElement {} +interface HTMLTableDataCellElement extends HTMLElement {} +interface HTMLTableHeaderCellElement extends HTMLElement {} +interface HTMLTableRowElement extends HTMLElement {} +interface HTMLTableSectionElement extends HTMLElement {} +interface HTMLTextAreaElement extends HTMLElement {} +interface HTMLTitleElement extends HTMLElement {} +interface HTMLTrackElement extends HTMLElement {} +interface HTMLUListElement extends HTMLElement {} +interface HTMLVideoElement extends HTMLElement {} +interface HTMLWebViewElement extends HTMLElement {} + +interface SVGElement extends Element {} +interface SVGSVGElement extends SVGElement {} +interface SVGCircleElement extends SVGElement {} +interface SVGClipPathElement extends SVGElement {} +interface SVGDefsElement extends SVGElement {} +interface SVGDescElement extends SVGElement {} +interface SVGEllipseElement extends SVGElement {} +interface SVGFEBlendElement extends SVGElement {} +interface SVGFEColorMatrixElement extends SVGElement {} +interface SVGFEComponentTransferElement extends SVGElement {} +interface SVGFECompositeElement extends SVGElement {} +interface SVGFEConvolveMatrixElement extends SVGElement {} +interface SVGFEDiffuseLightingElement extends SVGElement {} +interface SVGFEDisplacementMapElement extends SVGElement {} +interface SVGFEDistantLightElement extends SVGElement {} +interface SVGFEDropShadowElement extends SVGElement {} +interface SVGFEFloodElement extends SVGElement {} +interface SVGFEFuncAElement extends SVGElement {} +interface SVGFEFuncBElement extends SVGElement {} +interface SVGFEFuncGElement extends SVGElement {} +interface SVGFEFuncRElement extends SVGElement {} +interface SVGFEGaussianBlurElement extends SVGElement {} +interface SVGFEImageElement extends SVGElement {} +interface SVGFEMergeElement extends SVGElement {} +interface SVGFEMergeNodeElement extends SVGElement {} +interface SVGFEMorphologyElement extends SVGElement {} +interface SVGFEOffsetElement extends SVGElement {} +interface SVGFEPointLightElement extends SVGElement {} +interface SVGFESpecularLightingElement extends SVGElement {} +interface SVGFESpotLightElement extends SVGElement {} +interface SVGFETileElement extends SVGElement {} +interface SVGFETurbulenceElement extends SVGElement {} +interface SVGFilterElement extends SVGElement {} +interface SVGForeignObjectElement extends SVGElement {} +interface SVGGElement extends SVGElement {} +interface SVGImageElement extends SVGElement {} +interface SVGLineElement extends SVGElement {} +interface SVGLinearGradientElement extends SVGElement {} +interface SVGMarkerElement extends SVGElement {} +interface SVGMaskElement extends SVGElement {} +interface SVGMetadataElement extends SVGElement {} +interface SVGPathElement extends SVGElement {} +interface SVGPatternElement extends SVGElement {} +interface SVGPolygonElement extends SVGElement {} +interface SVGPolylineElement extends SVGElement {} +interface SVGRadialGradientElement extends SVGElement {} +interface SVGRectElement extends SVGElement {} +interface SVGStopElement extends SVGElement {} +interface SVGSwitchElement extends SVGElement {} +interface SVGSymbolElement extends SVGElement {} +interface SVGTextElement extends SVGElement {} +interface SVGTextPathElement extends SVGElement {} +interface SVGTSpanElement extends SVGElement {} +interface SVGUseElement extends SVGElement {} +interface SVGViewElement extends SVGElement {} + +interface Text {} +interface TouchList {} +interface WebGLRenderingContext {} + +type NativeAnimationEvent = AnimationEvent; +type NativeClipboardEvent = ClipboardEvent; +type NativeCompositionEvent = CompositionEvent; +type NativeDragEvent = DragEvent; +type NativeFocusEvent = FocusEvent; +type NativeKeyboardEvent = KeyboardEvent; +type NativeMouseEvent = MouseEvent; +type NativeTouchEvent = TouchEvent; +type NativePointerEvent = PointerEvent; +type NativeTransitionEvent = TransitionEvent; +type NativeUIEvent = UIEvent; +type NativeWheelEvent = WheelEvent; + +/** + * defined in scheduler/tracing + */ +interface SchedulerInteraction { + id: number; + name: string; + timestamp: number; +} + +// tslint:disable-next-line:export-just-namespace +export = Rax; +export as namespace Rax; + +declare namespace Rax { + /** + * ====================================================================== + * Rax Elements + * ====================================================================== + */ + type ElementType

= + | { + [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never + }[keyof JSX.IntrinsicElements] + | ComponentType

; + + type ComponentType

= ComponentClass

| FunctionComponent

; + + type JSXElementConstructor

= + | ((props: P) => RaxElement | null) + | (new (props: P) => Component); + + type Key = string | number; + + interface RefObject { + readonly current: T | null; + } + + type Ref = + | { bivarianceHack(instance: T | null): void }['bivarianceHack'] + | RefObject + | null; + type LegacyRef = string | Ref; + + type ComponentState = any; + + interface Attributes { + key?: Key; + } + + interface RefAttributes extends Attributes { + ref?: Ref; + } + + interface ClassAttributes extends Attributes { + ref?: LegacyRef; + } + + interface RaxElement< + P = any, + T extends string | JSXElementConstructor = string | JSXElementConstructor + > { + type: T; + props: P; + key: Key | null; + } + + interface RaxComponentElement< + T extends keyof JSX.IntrinsicElements | JSXElementConstructor, + P = Pick, Exclude, 'key' | 'ref'>> + > extends RaxElement {} + + interface FunctionComponentElement

extends RaxElement> { + ref?: 'ref' extends keyof P ? (P extends { ref?: infer R } ? R : never) : never; + } + + type CElement> = ComponentElement; + interface ComponentElement> + extends RaxElement> { + ref?: LegacyRef; + } + + type ClassicElement

= CElement>; + + // string fallback for custom web-components + interface DOMElement

| SVGAttributes, T extends Element> + extends RaxElement { + ref: LegacyRef; + } + + // RaxHTML for RaxHTMLElement + interface RaxHTMLElement + extends DetailedRaxHTMLElement, T> {} + + interface DetailedRaxHTMLElement

, T extends HTMLElement> + extends DOMElement { + type: keyof RaxHTML; + } + + // RaxSVG for RaxSVGElement + interface RaxSVGElement extends DOMElement, SVGElement> { + type: keyof RaxSVG; + } + + interface RaxPortal extends RaxElement { + key: Key | null; + children: RaxNode; + } + + /** + * ====================================================================== + * Rax Factories + * ====================================================================== + */ + + type Factory

= (props?: Attributes & P, ...children: RaxNode[]) => RaxElement

; + + type FunctionComponentFactory

= ( + props?: Attributes & P, + ...children: RaxNode[] + ) => FunctionComponentElement

; + + type ComponentFactory> = ( + props?: ClassAttributes & P, + ...children: RaxNode[] + ) => CElement; + + type CFactory> = ComponentFactory; + type ClassicFactory

= CFactory>; + + type DOMFactory

, T extends Element> = ( + props?: ClassAttributes & P | null, + ...children: RaxNode[] + ) => DOMElement; + + // tslint:disable-next-line:no-empty-interface + interface HTMLFactory + extends DetailedHTMLFactory, T> {} + + interface DetailedHTMLFactory

, T extends HTMLElement> + extends DOMFactory { + (props?: ClassAttributes & P | null, ...children: RaxNode[]): DetailedRaxHTMLElement; + } + + interface SVGFactory extends DOMFactory, SVGElement> { + ( + props?: ClassAttributes & SVGAttributes | null, + ...children: RaxNode[] + ): RaxSVGElement; + } + + /** + * ====================================================================== + * Rax Nodes + * ====================================================================== + */ + + type RaxText = string | number; + type RaxChild = RaxElement | RaxText; + + interface RaxNodeArray extends Array {} + type RaxFragment = {} | RaxNodeArray; + type RaxNode = RaxChild | RaxFragment | RaxPortal | boolean | null | undefined; + + /** + * ====================================================================== + * Rax Top Level API + * ====================================================================== + */ + + // DOM Elements + // TODO: generalize this to everything in `keyof RaxHTML`, not just "input" + function createElement( + type: 'input', + props?: InputHTMLAttributes & ClassAttributes | null, + ...children: RaxNode[] + ): DetailedRaxHTMLElement, HTMLInputElement>; + function createElement

, T extends HTMLElement>( + type: keyof RaxHTML, + props?: ClassAttributes & P | null, + ...children: RaxNode[] + ): DetailedRaxHTMLElement; + function createElement

, T extends SVGElement>( + type: keyof RaxSVG, + props?: ClassAttributes & P | null, + ...children: RaxNode[] + ): RaxSVGElement; + function createElement

, T extends Element>( + type: string, + props?: ClassAttributes & P | null, + ...children: RaxNode[] + ): DOMElement; + + // Custom components + + function createElement

( + type: FunctionComponent

, + props?: Attributes & P | null, + ...children: RaxNode[] + ): FunctionComponentElement

; + function createElement

( + type: ClassType, ClassicComponentClass

>, + props?: ClassAttributes> & P | null, + ...children: RaxNode[] + ): CElement>; + function createElement< + P extends {}, + T extends Component, + C extends ComponentClass

+ >( + type: ClassType, + props?: ClassAttributes & P | null, + ...children: RaxNode[] + ): CElement; + function createElement

( + type: FunctionComponent

| ComponentClass

| string, + props?: Attributes & P | null, + ...children: RaxNode[] + ): RaxElement

; + + // Context via RenderProps + interface ProviderProps { + value: T; + children?: RaxNode; + } + + interface ConsumerProps { + children: (value: T) => RaxNode; + unstable_observedBits?: number; + } + + interface ExoticComponent

{ + /** + * **NOTE**: Exotic components are not callable. + */ + (props: P): RaxElement | null; + readonly $$typeof: symbol; + } + + interface NamedExoticComponent

extends ExoticComponent

{ + displayName?: string; + } + + interface ProviderExoticComponent

extends ExoticComponent

{ + propTypes?: WeakValidationMap

; + } + + type ContextType> = C extends Context ? T : never; + + type Provider = ProviderExoticComponent>; + type Consumer = ExoticComponent>; + interface Context { + Provider: Provider; + Consumer: Consumer; + displayName?: string; + } + function createContext( + defaultValue: T, + calculateChangedBits?: (prev: T, next: T) => number + ): Context; + + const Children: RaxChildren; + const Fragment: ExoticComponent<{ children?: RaxNode }>; + + const version: string; + + interface RenderOption { + driver: any; + } + function render( + element: Element, + parent: Element | Document, + options?: RenderOption, + callback?: () => void + ): void; + + /** + * ====================================================================== + * Rax Component API + * ====================================================================== + */ + type RaxInstance = Component | Element; + + // Base component for plain JS classes + // tslint:disable-next-line:no-empty-interface + interface Component

extends ComponentLifecycle {} + class Component { + readonly props: Readonly

& Readonly<{ children?: RaxNode }>; + state: Readonly; + + constructor(props: Readonly

); + + setState( + state: + | ((prevState: Readonly, props: Readonly

) => Pick | S | null) + | (Pick | S | null), + callback?: () => void + ): void; + + forceUpdate(callBack?: () => void): void; + + render(): RaxNode; + } + + class PureComponent

extends Component {} + + interface ClassicComponent

extends Component { + replaceState(nextState: S, callback?: () => void): void; + isMounted(): boolean; + getInitialState?(): S; + } + + interface ChildContextProvider { + getChildContext(): CC; + } + + type FC

= FunctionComponent

; + + interface FunctionComponent

{ + (props: PropsWithChildren

, context?: any): RaxElement | null; + propTypes?: WeakValidationMap

; + contextTypes?: ValidationMap; + defaultProps?: Partial

; + displayName?: string; + } + + interface RefForwardingComponent { + (props: PropsWithChildren

, ref: Ref): RaxElement | null; + propTypes?: WeakValidationMap

; + contextTypes?: ValidationMap; + defaultProps?: Partial

; + displayName?: string; + } + + interface ComponentClass

extends StaticLifecycle { + new (props: P, context?: any): Component; + propTypes?: WeakValidationMap

; + contextType?: Context; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + defaultProps?: Partial

; + displayName?: string; + } + + interface ClassicComponentClass

extends ComponentClass

{ + new (props: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + } + + /** + * We use an intersection type to infer multiple type parameters from + * a single argument, which is useful for many top-level API defs. + * See https://github.com/Microsoft/TypeScript/issues/7234 for more info. + */ + type ClassType, C extends ComponentClass

> = C & + (new (props: P, context?: any) => T); + + /** + * ====================================================================== + * Rax Component Specs and Lifecycle + * ====================================================================== + */ + + // This should actually be something like `Lifecycle | DeprecatedLifecycle`, + // as Rax will _not_ call the deprecated lifecycle methods if any of the new lifecycle + // methods are present. + interface ComponentLifecycle { + /** + * Called immediately after a component is mounted. Setting state here will trigger re-rendering. + */ + componentDidMount?(): void; + /** + * Called to determine whether the change in props and state should trigger a re-render. + * + * `Component` always returns true. + * `PureComponent` implements a shallow comparison on props and state and returns true if any + * props or states have changed. + * + * If false is returned, `Component#render`, `componentWillUpdate` + * and `componentDidUpdate` will not be called. + */ + shouldComponentUpdate?( + nextProps: Readonly

, + nextState: Readonly, + nextContext: any + ): boolean; + /** + * Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as + * cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`. + */ + componentWillUnmount?(): void; + /** + * Catches exceptions generated in descendant components. Unhandled exceptions will cause + * the entire component tree to unmount. + */ + componentDidCatch?(error: Error, errorInfo: ErrorInfo): void; + + /** + * Runs before Rax applies the result of `render` to the document, and + * returns an object to be given to componentDidUpdate. Useful for saving + * things such as scroll position before `render` causes changes to it. + * + * Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated + * lifecycle events from running. + */ + getSnapshotBeforeUpdate?(prevProps: Readonly

, prevState: Readonly): SS | null; + /** + * Called immediately after updating occurs. Not called for the initial render. + * + * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null. + */ + componentDidUpdate?(prevProps: Readonly

, prevState: Readonly, snapshot?: SS): void; + componentWillMount?(): void; + componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; + componentWillUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): void; + } + + // Unfortunately, we have no way of declaring that the component constructor must implement this + interface StaticLifecycle { + getDerivedStateFromProps?: GetDerivedStateFromProps; + getDerivedStateFromError?: GetDerivedStateFromError; + } + + type GetDerivedStateFromProps = + /** + * Returns an update to a component's state based on its new props and old state. + * + * Note: its presence prevents any of the deprecated lifecycle methods from being invoked + */ + (nextProps: Readonly

, prevState: S) => Partial | null; + + type GetDerivedStateFromError = + /** + * This lifecycle is invoked after an error has been thrown by a descendant component. + * It receives the error that was thrown as a parameter and should return a value to update state. + * + * Note: its presence prevents any of the deprecated lifecycle methods from being invoked + */ + (error: any) => Partial | null; + + interface Mixin extends ComponentLifecycle { + mixins?: Array>; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + + getDefaultProps?(): P; + getInitialState?(): S; + } + + interface ComponentSpec extends Mixin { + render(): RaxNode; + + [propertyName: string]: any; + } + + function createRef(): RefObject; + + // will show `ForwardRef(${Component.displayName || Component.name})` in devtools by default, + // but can be given its own specific name + interface ForwardRefExoticComponent

extends NamedExoticComponent

{ + defaultProps?: Partial

; + } + + function forwardRef( + Component: RefForwardingComponent + ): ForwardRefExoticComponent & RefAttributes>; + + /** Ensures that the props do not include ref at all */ + type PropsWithoutRef

= + // Just Pick would be sufficient for this, but I'm trying to avoid unnecessary mapping over union types + // https://github.com/Microsoft/TypeScript/issues/28339 + 'ref' extends keyof P ? Pick> : P; + /** Ensures that the props do not include string ref, which cannot be forwarded */ + type PropsWithRef

= + // Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}. + 'ref' extends keyof P + ? P extends { ref?: infer R } + ? string extends R + ? PropsWithoutRef

& { ref?: Exclude } + : P + : P + : P; + + type PropsWithChildren

= P & { children?: RaxNode }; + + /** + * NOTE: prefer ComponentPropsWithRef, if the ref is forwarded, + * or ComponentPropsWithoutRef when refs are not supported. + */ + type ComponentProps< + T extends keyof JSX.IntrinsicElements | JSXElementConstructor + > = T extends JSXElementConstructor + ? P + : T extends keyof JSX.IntrinsicElements + ? JSX.IntrinsicElements[T] + : {}; + type ComponentPropsWithRef = T extends ComponentClass + ? PropsWithoutRef

& RefAttributes> + : PropsWithRef>; + type ComponentPropsWithoutRef = PropsWithoutRef>; + + // will show `Memo(${Component.displayName || Component.name})` in devtools by default, + // but can be given its own specific name + type MemoExoticComponent> = NamedExoticComponent< + ComponentPropsWithRef + > & { + readonly type: T; + }; + + function memo

( + Component: FC

, + propsAreEqual?: ( + prevProps: Readonly>, + nextProps: Readonly> + ) => boolean + ): NamedExoticComponent

; + function memo>( + Component: T, + propsAreEqual?: ( + prevProps: Readonly>, + nextProps: Readonly> + ) => boolean + ): MemoExoticComponent; + + /** + * ====================================================================== + * Rax Hooks + * ====================================================================== + */ + + // Unlike the class component setState, the updates are not allowed to be partial + type SetStateAction = S | ((prevState: S) => S); + // this technically does accept a second argument, but it's already under a deprecation warning + // and it's not even released so probably better to not define it. + type Dispatch = (value: A) => void; + // Unlike redux, the actions _can_ be anything + type Reducer = (prevState: S, action: A) => S; + // types used to try and prevent the compiler from reducing S + // to a supertype common with the second argument to useReducer() + type ReducerState> = R extends Reducer ? S : never; + type ReducerAction> = R extends Reducer ? A : never; + // The identity check is done with the SameValue algorithm (Object.is), which is stricter than === + // TODO (TypeScript 3.0): ReadonlyArray + type DependencyList = ReadonlyArray; + + // NOTE: callbacks are _only_ allowed to return either void, or a destructor. + // The destructor is itself only allowed to return void. + type EffectCallback = () => void | (() => void | undefined); + + interface MutableRefObject { + current: T; + } + + // This will technically work if you give a Consumer or Provider but it's deprecated and warns + /** + * Accepts a context object (the value returned from `Rax.createContext`) and returns the current + * context value, as given by the nearest context provider for the given context. + */ + function useContext( + context: Context /* , (not public API) observedBits?: number|boolean */ + ): T; + /** + * Returns a stateful value, and a function to update it. + */ + function useState(initialState: S | (() => S)): [S, Dispatch>]; + // convenience overload when first argument is ommitted + /** + * Returns a stateful value, and a function to update it. + */ + function useState(): [S | undefined, Dispatch>]; + /** + * An alternative to `useState`. + * + * `useReducer` is usually preferable to `useState` when you have complex state logic that involves + * multiple sub-values. It also lets you optimize performance for components that trigger deep + * updates because you can pass `dispatch` down instead of callbacks. + */ + // overload where "I" may be a subset of ReducerState; used to provide autocompletion. + // If "I" matches ReducerState exactly then the last overload will allow initializer to be ommitted. + // the last overload effectively behaves as if the identity function (x => x) is the initializer. + function useReducer, I>( + reducer: R, + initializerArg: I & ReducerState, + initializer: (arg: I & ReducerState) => ReducerState + ): [ReducerState, Dispatch>]; + /** + * An alternative to `useState`. + * + * `useReducer` is usually preferable to `useState` when you have complex state logic that involves + * multiple sub-values. It also lets you optimize performance for components that trigger deep + * updates because you can pass `dispatch` down instead of callbacks. + */ + // overload for free "I"; all goes as long as initializer converts it into "ReducerState". + function useReducer, I>( + reducer: R, + initializerArg: I, + initializer: (arg: I) => ReducerState + ): [ReducerState, Dispatch>]; + /** + * An alternative to `useState`. + * + * `useReducer` is usually preferable to `useState` when you have complex state logic that involves + * multiple sub-values. It also lets you optimize performance for components that trigger deep + * updates because you can pass `dispatch` down instead of callbacks. + */ + + // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary. + // The Flow types do have an overload for 3-ary invocation with undefined initializer. + + // NOTE: without the ReducerState indirection, TypeScript would reduce S to be the most common + // supertype between the reducer's return type and the initialState (or the initializer's return type), + // which would prevent autocompletion from ever working. + + // TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug + // in older versions, or a regression in newer versions of the typescript completion service. + function useReducer>( + reducer: R, + initialState: ReducerState, + initializer?: undefined + ): [ReducerState, Dispatch>]; + /** + * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument + * (`initialValue`). The returned object will persist for the full lifetime of the component. + * + * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable + * value around similar to how you’d use instance fields in classes. + */ + // TODO (TypeScript 3.0): + function useRef(initialValue: T): MutableRefObject; + // convenience overload for refs given as a ref prop as they typically start with a null value + /** + * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument + * (`initialValue`). The returned object will persist for the full lifetime of the component. + * + * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable + * value around similar to how you’d use instance fields in classes. + * + * Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type + * of the generic argument. + */ + // TODO (TypeScript 3.0): + function useRef(initialValue: T | null): RefObject; + // convenience overload for potentially undefined initialValue / call with 0 arguments + // has a default to stop it from defaulting to {} instead + /** + * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument + * (`initialValue`). The returned object will persist for the full lifetime of the component. + * + * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable + * value around similar to how you’d use instance fields in classes. + */ + // TODO (TypeScript 3.0): + function useRef(): MutableRefObject; + /** + * The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations. + * Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside + * `useLayoutEffect` will be flushed synchronously, before the browser has a chance to paint. + * + * Prefer the standard `useEffect` when possible to avoid blocking visual updates. + * + * If you’re migrating code from a class component, `useLayoutEffect` fires in the same phase as + * `componentDidMount` and `componentDidUpdate`. + */ + function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void; + /** + * Accepts a function that contains imperative, possibly effectful code. + * + * @param effect Imperative function that can return a cleanup function + * @param deps If present, effect will only activate if the values in the list change. + */ + function useEffect(effect: EffectCallback, deps?: DependencyList): void; + // NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref + /** + * `useImperativeHandle` customizes the instance value that is exposed to parent components when using + * `ref`. As always, imperative code using refs should be avoided in most cases. + * + * `useImperativeHandle` should be used with `Rax.forwardRef`. + */ + function useImperativeHandle( + ref: Ref | undefined, + init: () => R, + deps?: DependencyList + ): void; + // I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key + // useCallback(X) is identical to just using X, useMemo(() => Y) is identical to just using Y. + /** + * `useCallback` will return a memoized version of the callback that only changes if one of the `inputs` + * has changed. + */ + // TODO (TypeScript 3.0): unknown> + function useCallback any>(callback: T, deps: DependencyList): T; + /** + * `useMemo` will only recompute the memoized value when one of the `deps` has changed. + * + * Usage note: if calling `useMemo` with a referentially stable function, also give it as the input in + * the second argument. + * + * ```ts + * function expensive () { ... } + * + * function Component () { + * const expensiveResult = useMemo(expensive, [expensive]) + * return ... + * } + * ``` + */ + // allow undefined, but don't make it optional as that is very likely a mistake + function useMemo(factory: () => T, deps: DependencyList | undefined): T; + + /** + * ====================================================================== + * Rax Event System + * ====================================================================== + */ + + // TODO: change any to unknown when moving to TS v3 + interface BaseSyntheticEvent { + nativeEvent: E; + currentTarget: C; + target: T; + bubbles: boolean; + cancelable: boolean; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + preventDefault(): void; + isDefaultPrevented(): boolean; + stopPropagation(): void; + isPropagationStopped(): boolean; + persist(): void; + timeStamp: number; + type: string; + } + + /** + * currentTarget - a reference to the element on which the event listener is registered. + * + * target - a reference to the element from which the event was originally dispatched. + * This might be a child element to the element on which the event listener is registered. + * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12239 + */ + interface SyntheticEvent + extends BaseSyntheticEvent {} + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface CompositionEvent extends SyntheticEvent { + data: string; + } + + interface DragEvent extends MouseEvent { + dataTransfer: DataTransfer; + } + + interface PointerEvent extends MouseEvent { + pointerId: number; + pressure: number; + tiltX: number; + tiltY: number; + width: number; + height: number; + pointerType: 'mouse' | 'pen' | 'touch'; + isPrimary: boolean; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + target: EventTarget & T; + } + + // tslint:disable-next-line:no-empty-interface + interface FormEvent extends SyntheticEvent {} + + interface InvalidEvent extends SyntheticEvent { + target: EventTarget & T; + } + + interface ChangeEvent extends SyntheticEvent { + target: EventTarget & T; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + /** + * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. + */ + getModifierState(key: string): boolean; + /** + * See the [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values). for possible values + */ + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + /** + * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. + */ + getModifierState(key: string): boolean; + metaKey: boolean; + movementX: number; + movementY: number; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + /** + * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. + */ + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends MouseEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + interface AnimationEvent extends SyntheticEvent { + animationName: string; + elapsedTime: number; + pseudoElement: string; + } + + interface TransitionEvent extends SyntheticEvent { + elapsedTime: number; + propertyName: string; + pseudoElement: string; + } + + interface AppearEvent extends SyntheticEvent { + direction: 'up' | 'down'; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + type EventHandler> = { + bivarianceHack(event: E): void; + }['bivarianceHack']; + + type RaxEventHandler = EventHandler>; + + type ClipboardEventHandler = EventHandler>; + type CompositionEventHandler = EventHandler>; + type DragEventHandler = EventHandler>; + type FocusEventHandler = EventHandler>; + type FormEventHandler = EventHandler>; + type ChangeEventHandler = EventHandler>; + type KeyboardEventHandler = EventHandler>; + type MouseEventHandler = EventHandler>; + type TouchEventHandler = EventHandler>; + type PointerEventHandler = EventHandler>; + type UIEventHandler = EventHandler>; + type WheelEventHandler = EventHandler>; + type AnimationEventHandler = EventHandler>; + type TransitionEventHandler = EventHandler>; + type AppearEventHandler = EventHandler>; + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface HTMLProps extends AllHTMLAttributes, ClassAttributes {} + + type DetailedHTMLProps, T> = ClassAttributes & E; + + interface SVGProps extends SVGAttributes, ClassAttributes {} + + interface DOMAttributes { + children?: RaxNode; + dangerouslySetInnerHTML?: { + __html: string; + }; + + // weex + [key: string]: any; + + // Clipboard Events + onCopy?: ClipboardEventHandler; + onCopyCapture?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onCutCapture?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onPasteCapture?: ClipboardEventHandler; + + // Composition Events + onCompositionEnd?: CompositionEventHandler; + onCompositionEndCapture?: CompositionEventHandler; + onCompositionStart?: CompositionEventHandler; + onCompositionStartCapture?: CompositionEventHandler; + onCompositionUpdate?: CompositionEventHandler; + onCompositionUpdateCapture?: CompositionEventHandler; + + // Focus Events + onFocus?: FocusEventHandler; + onFocusCapture?: FocusEventHandler; + onBlur?: FocusEventHandler; + onBlurCapture?: FocusEventHandler; + + // Form Events + onChange?: FormEventHandler; + onChangeCapture?: FormEventHandler; + onBeforeInput?: FormEventHandler; + onBeforeInputCapture?: FormEventHandler; + onInput?: FormEventHandler; + onInputCapture?: FormEventHandler; + onReset?: FormEventHandler; + onResetCapture?: FormEventHandler; + onSubmit?: FormEventHandler; + onSubmitCapture?: FormEventHandler; + onInvalid?: FormEventHandler; + onInvalidCapture?: FormEventHandler; + + // Image Events + onLoad?: RaxEventHandler; + onLoadCapture?: RaxEventHandler; + onError?: RaxEventHandler; // also a Media Event + onErrorCapture?: RaxEventHandler; // also a Media Event + + // Keyboard Events + onKeyDown?: KeyboardEventHandler; + onKeyDownCapture?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyPressCapture?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onKeyUpCapture?: KeyboardEventHandler; + + // Media Events + onAbort?: RaxEventHandler; + onAbortCapture?: RaxEventHandler; + onCanPlay?: RaxEventHandler; + onCanPlayCapture?: RaxEventHandler; + onCanPlayThrough?: RaxEventHandler; + onCanPlayThroughCapture?: RaxEventHandler; + onDurationChange?: RaxEventHandler; + onDurationChangeCapture?: RaxEventHandler; + onEmptied?: RaxEventHandler; + onEmptiedCapture?: RaxEventHandler; + onEncrypted?: RaxEventHandler; + onEncryptedCapture?: RaxEventHandler; + onEnded?: RaxEventHandler; + onEndedCapture?: RaxEventHandler; + onLoadedData?: RaxEventHandler; + onLoadedDataCapture?: RaxEventHandler; + onLoadedMetadata?: RaxEventHandler; + onLoadedMetadataCapture?: RaxEventHandler; + onLoadStart?: RaxEventHandler; + onLoadStartCapture?: RaxEventHandler; + onPause?: RaxEventHandler; + onPauseCapture?: RaxEventHandler; + onPlay?: RaxEventHandler; + onPlayCapture?: RaxEventHandler; + onPlaying?: RaxEventHandler; + onPlayingCapture?: RaxEventHandler; + onProgress?: RaxEventHandler; + onProgressCapture?: RaxEventHandler; + onRateChange?: RaxEventHandler; + onRateChangeCapture?: RaxEventHandler; + onSeeked?: RaxEventHandler; + onSeekedCapture?: RaxEventHandler; + onSeeking?: RaxEventHandler; + onSeekingCapture?: RaxEventHandler; + onStalled?: RaxEventHandler; + onStalledCapture?: RaxEventHandler; + onSuspend?: RaxEventHandler; + onSuspendCapture?: RaxEventHandler; + onTimeUpdate?: RaxEventHandler; + onTimeUpdateCapture?: RaxEventHandler; + onVolumeChange?: RaxEventHandler; + onVolumeChangeCapture?: RaxEventHandler; + onWaiting?: RaxEventHandler; + onWaitingCapture?: RaxEventHandler; + + // MouseEvents + onAuxClick?: MouseEventHandler; + onAuxClickCapture?: MouseEventHandler; + onClick?: MouseEventHandler; + onClickCapture?: MouseEventHandler; + onContextMenu?: MouseEventHandler; + onContextMenuCapture?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDoubleClickCapture?: MouseEventHandler; + onDrag?: DragEventHandler; + onDragCapture?: DragEventHandler; + onDragEnd?: DragEventHandler; + onDragEndCapture?: DragEventHandler; + onDragEnter?: DragEventHandler; + onDragEnterCapture?: DragEventHandler; + onDragExit?: DragEventHandler; + onDragExitCapture?: DragEventHandler; + onDragLeave?: DragEventHandler; + onDragLeaveCapture?: DragEventHandler; + onDragOver?: DragEventHandler; + onDragOverCapture?: DragEventHandler; + onDragStart?: DragEventHandler; + onDragStartCapture?: DragEventHandler; + onDrop?: DragEventHandler; + onDropCapture?: DragEventHandler; + onMouseDown?: MouseEventHandler; + onMouseDownCapture?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseMoveCapture?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOutCapture?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseOverCapture?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onMouseUpCapture?: MouseEventHandler; + + // Selection Events + onSelect?: RaxEventHandler; + onSelectCapture?: RaxEventHandler; + + // Touch Events + onTouchCancel?: TouchEventHandler; + onTouchCancelCapture?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchEndCapture?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchMoveCapture?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onTouchStartCapture?: TouchEventHandler; + + // Pointer Events + onPointerDown?: PointerEventHandler; + onPointerDownCapture?: PointerEventHandler; + onPointerMove?: PointerEventHandler; + onPointerMoveCapture?: PointerEventHandler; + onPointerUp?: PointerEventHandler; + onPointerUpCapture?: PointerEventHandler; + onPointerCancel?: PointerEventHandler; + onPointerCancelCapture?: PointerEventHandler; + onPointerEnter?: PointerEventHandler; + onPointerEnterCapture?: PointerEventHandler; + onPointerLeave?: PointerEventHandler; + onPointerLeaveCapture?: PointerEventHandler; + onPointerOver?: PointerEventHandler; + onPointerOverCapture?: PointerEventHandler; + onPointerOut?: PointerEventHandler; + onPointerOutCapture?: PointerEventHandler; + onGotPointerCapture?: PointerEventHandler; + onGotPointerCaptureCapture?: PointerEventHandler; + onLostPointerCapture?: PointerEventHandler; + onLostPointerCaptureCapture?: PointerEventHandler; + + // UI Events + onScroll?: UIEventHandler; + onScrollCapture?: UIEventHandler; + + // Wheel Events + onWheel?: WheelEventHandler; + onWheelCapture?: WheelEventHandler; + + // Animation Events + onAnimationStart?: AnimationEventHandler; + onAnimationStartCapture?: AnimationEventHandler; + onAnimationEnd?: AnimationEventHandler; + onAnimationEndCapture?: AnimationEventHandler; + onAnimationIteration?: AnimationEventHandler; + onAnimationIterationCapture?: AnimationEventHandler; + + // Transition Events + onTransitionEnd?: TransitionEventHandler; + onTransitionEndCapture?: TransitionEventHandler; + + // Weex Common Events + onLongpress?: MouseEventHandler; + onAppear?: AppearEventHandler; + onDisappear?: AppearEventHandler; + } + + export interface CSSProperties extends CSS.Properties { + /** + * The index signature was removed to enable closed typing for style + * using CSSType. You're able to use type assertion or module augmentation + * to add properties or an index signature of your own. + * + * For examples and more information, visit: + * https://github.com/frenic/csstype#what-should-i-do-when-i-get-type-errors + */ + [key: string]: any; + } + + // All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/ + interface AriaAttributes { + /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */ + 'aria-activedescendant'?: string; + /** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */ + 'aria-atomic'?: boolean | 'false' | 'true'; + /** + * Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be + * presented if they are made. + */ + 'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both'; + /** Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. */ + 'aria-busy'?: boolean | 'false' | 'true'; + /** + * Indicates the current "checked" state of checkboxes, radio buttons, and other widgets. + * @see aria-pressed @see aria-selected. + */ + 'aria-checked'?: boolean | 'false' | 'mixed' | 'true'; + /** + * Defines the total number of columns in a table, grid, or treegrid. + * @see aria-colindex. + */ + 'aria-colcount'?: number; + /** + * Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid. + * @see aria-colcount @see aria-colspan. + */ + 'aria-colindex'?: number; + /** + * Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid. + * @see aria-colindex @see aria-rowspan. + */ + 'aria-colspan'?: number; + /** + * Identifies the element (or elements) whose contents or presence are controlled by the current element. + * @see aria-owns. + */ + 'aria-controls'?: string; + /** Indicates the element that represents the current item within a container or set of related elements. */ + 'aria-current'?: boolean | 'false' | 'true' | 'page' | 'step' | 'location' | 'date' | 'time'; + /** + * Identifies the element (or elements) that describes the object. + * @see aria-labelledby + */ + 'aria-describedby'?: string; + /** + * Identifies the element that provides a detailed, extended description for the object. + * @see aria-describedby. + */ + 'aria-details'?: string; + /** + * Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. + * @see aria-hidden @see aria-readonly. + */ + 'aria-disabled'?: boolean | 'false' | 'true'; + /** + * Indicates what functions can be performed when a dragged object is released on the drop target. + * @deprecated in ARIA 1.1 + */ + 'aria-dropeffect'?: 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup'; + /** + * Identifies the element that provides an error message for the object. + * @see aria-invalid @see aria-describedby. + */ + 'aria-errormessage'?: string; + /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */ + 'aria-expanded'?: boolean | 'false' | 'true'; + /** + * Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, + * allows assistive technology to override the general default of reading in document source order. + */ + 'aria-flowto'?: string; + /** + * Indicates an element's "grabbed" state in a drag-and-drop operation. + * @deprecated in ARIA 1.1 + */ + 'aria-grabbed'?: boolean | 'false' | 'true'; + /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */ + 'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'; + /** + * Indicates whether the element is exposed to an accessibility API. + * @see aria-disabled. + */ + 'aria-hidden'?: boolean | 'false' | 'true'; + /** + * Indicates the entered value does not conform to the format expected by the application. + * @see aria-errormessage. + */ + 'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling'; + /** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */ + 'aria-keyshortcuts'?: string; + /** + * Defines a string value that labels the current element. + * @see aria-labelledby. + */ + 'aria-label'?: string; + /** + * Identifies the element (or elements) that labels the current element. + * @see aria-describedby. + */ + 'aria-labelledby'?: string; + /** Defines the hierarchical level of an element within a structure. */ + 'aria-level'?: number; + /** Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */ + 'aria-live'?: 'off' | 'assertive' | 'polite'; + /** Indicates whether an element is modal when displayed. */ + 'aria-modal'?: boolean | 'false' | 'true'; + /** Indicates whether a text box accepts multiple lines of input or only a single line. */ + 'aria-multiline'?: boolean | 'false' | 'true'; + /** Indicates that the user may select more than one item from the current selectable descendants. */ + 'aria-multiselectable'?: boolean | 'false' | 'true'; + /** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */ + 'aria-orientation'?: 'horizontal' | 'vertical'; + /** + * Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship + * between DOM elements where the DOM hierarchy cannot be used to represent the relationship. + * @see aria-controls. + */ + 'aria-owns'?: string; + /** + * Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. + * A hint could be a sample value or a brief description of the expected format. + */ + 'aria-placeholder'?: string; + /** + * Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. + * @see aria-setsize. + */ + 'aria-posinset'?: number; + /** + * Indicates the current "pressed" state of toggle buttons. + * @see aria-checked @see aria-selected. + */ + 'aria-pressed'?: boolean | 'false' | 'mixed' | 'true'; + /** + * Indicates that the element is not editable, but is otherwise operable. + * @see aria-disabled. + */ + 'aria-readonly'?: boolean | 'false' | 'true'; + /** + * Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified. + * @see aria-atomic. + */ + 'aria-relevant'?: 'additions' | 'additions text' | 'all' | 'removals' | 'text'; + /** Indicates that user input is required on the element before a form may be submitted. */ + 'aria-required'?: boolean | 'false' | 'true'; + /** Defines a human-readable, author-localized description for the role of an element. */ + 'aria-roledescription'?: string; + /** + * Defines the total number of rows in a table, grid, or treegrid. + * @see aria-rowindex. + */ + 'aria-rowcount'?: number; + /** + * Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid. + * @see aria-rowcount @see aria-rowspan. + */ + 'aria-rowindex'?: number; + /** + * Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid. + * @see aria-rowindex @see aria-colspan. + */ + 'aria-rowspan'?: number; + /** + * Indicates the current "selected" state of various widgets. + * @see aria-checked @see aria-pressed. + */ + 'aria-selected'?: boolean | 'false' | 'true'; + /** + * Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. + * @see aria-posinset. + */ + 'aria-setsize'?: number; + /** Indicates if items in a table or grid are sorted in ascending or descending order. */ + 'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other'; + /** Defines the maximum allowed value for a range widget. */ + 'aria-valuemax'?: number; + /** Defines the minimum allowed value for a range widget. */ + 'aria-valuemin'?: number; + /** + * Defines the current value for a range widget. + * @see aria-valuetext. + */ + 'aria-valuenow'?: number; + /** Defines the human readable text alternative of aria-valuenow for a range widget. */ + 'aria-valuetext'?: string; + } + + interface HTMLAttributes extends AriaAttributes, DOMAttributes { + // Rax-specific Attributes + defaultChecked?: boolean; + defaultValue?: string | string[]; + suppressContentEditableWarning?: boolean; + suppressHydrationWarning?: boolean; + + // Standard HTML Attributes + accessKey?: string; + className?: string; + contentEditable?: boolean; + contextMenu?: string; + dir?: string; + draggable?: boolean; + hidden?: boolean; + id?: string; + lang?: string; + placeholder?: string; + slot?: string; + spellCheck?: boolean; + style?: CSSProperties; + tabIndex?: number; + title?: string; + + // Unknown + inputMode?: string; + is?: string; + radioGroup?: string; // , + + // WAI-ARIA + role?: string; + + // RDFa Attributes + about?: string; + datatype?: string; + inlist?: any; + prefix?: string; + property?: string; + resource?: string; + typeof?: string; + vocab?: string; + + // Non-standard Attributes + autoCapitalize?: string; + autoCorrect?: string; + autoSave?: string; + color?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + itemID?: string; + itemRef?: string; + results?: number; + security?: string; + unselectable?: 'on' | 'off'; + } + + interface AllHTMLAttributes extends HTMLAttributes { + // Standard HTML Attributes + accept?: string; + acceptCharset?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + as?: string; + async?: boolean; + autoComplete?: string; + autoFocus?: boolean; + autoPlay?: boolean; + capture?: boolean | string; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + challenge?: string; + checked?: boolean; + cite?: string; + classID?: string; + cols?: number; + colSpan?: number; + content?: string; + controls?: boolean; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + default?: boolean; + defer?: boolean; + disabled?: boolean; + download?: any; + encType?: string; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + frameBorder?: number | string; + headers?: string; + height?: number | string; + high?: number; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + integrity?: string; + keyParams?: string; + keyType?: string; + kind?: string; + label?: 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; + minLength?: number; + multiple?: boolean; + muted?: boolean; + name?: string; + nonce?: string; + noValidate?: boolean; + open?: boolean; + optimum?: number; + pattern?: string; + placeholder?: string; + playsInline?: boolean; + poster?: string; + preload?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + reversed?: boolean; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scoped?: boolean; + scrolling?: string; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + src?: string; + srcDoc?: string; + srcLang?: string; + srcSet?: string; + start?: number; + step?: number | string; + summary?: string; + target?: string; + type?: string; + useMap?: string; + value?: string | string[] | number; + width?: number | string; + wmode?: string; + wrap?: string; + } + + interface AnchorHTMLAttributes extends HTMLAttributes { + download?: any; + href?: string; + hrefLang?: string; + media?: string; + rel?: string; + target?: string; + type?: string; + referrerPolicy?: string; + } + + // tslint:disable-next-line:no-empty-interface + interface AudioHTMLAttributes extends MediaHTMLAttributes {} + + interface AreaHTMLAttributes extends HTMLAttributes { + alt?: string; + coords?: string; + download?: any; + href?: string; + hrefLang?: string; + media?: string; + rel?: string; + shape?: string; + target?: string; + } + + interface BaseHTMLAttributes extends HTMLAttributes { + href?: string; + target?: string; + } + + interface BlockquoteHTMLAttributes extends HTMLAttributes { + cite?: string; + } + + interface ButtonHTMLAttributes extends HTMLAttributes { + autoFocus?: boolean; + disabled?: boolean; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + name?: string; + type?: 'submit' | 'reset' | 'button'; + value?: string | string[] | number; + } + + interface CanvasHTMLAttributes extends HTMLAttributes { + height?: number | string; + width?: number | string; + } + + interface ColHTMLAttributes extends HTMLAttributes { + span?: number; + width?: number | string; + } + + interface ColgroupHTMLAttributes extends HTMLAttributes { + span?: number; + } + + interface DetailsHTMLAttributes extends HTMLAttributes { + open?: boolean; + } + + interface DelHTMLAttributes extends HTMLAttributes { + cite?: string; + dateTime?: string; + } + + interface DialogHTMLAttributes extends HTMLAttributes { + open?: boolean; + } + + interface EmbedHTMLAttributes extends HTMLAttributes { + height?: number | string; + src?: string; + type?: string; + width?: number | string; + } + + interface FieldsetHTMLAttributes extends HTMLAttributes { + disabled?: boolean; + form?: string; + name?: string; + } + + interface FormHTMLAttributes extends HTMLAttributes { + acceptCharset?: string; + action?: string; + autoComplete?: string; + encType?: string; + method?: string; + name?: string; + noValidate?: boolean; + target?: string; + } + + interface HtmlHTMLAttributes extends HTMLAttributes { + manifest?: string; + } + + interface IframeHTMLAttributes extends HTMLAttributes { + allow?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + frameBorder?: number | string; + height?: number | string; + marginHeight?: number; + marginWidth?: number; + name?: string; + referrerPolicy?: string; + sandbox?: string; + scrolling?: string; + seamless?: boolean; + src?: string; + srcDoc?: string; + width?: number | string; + } + + interface ImgHTMLAttributes extends HTMLAttributes { + alt?: string; + crossOrigin?: 'anonymous' | 'use-credentials' | ''; + decoding?: 'async' | 'auto' | 'sync'; + height?: number | string; + sizes?: string; + src?: string; + srcSet?: string; + useMap?: string; + width?: number | string; + } + + interface InsHTMLAttributes extends HTMLAttributes { + cite?: string; + dateTime?: string; + } + + interface InputHTMLAttributes extends HTMLAttributes { + accept?: string; + alt?: string; + autoComplete?: string; + autoFocus?: boolean; + capture?: boolean | string; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute + checked?: boolean; + crossOrigin?: string; + disabled?: boolean; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + height?: number | string; + list?: string; + max?: number | string; + maxLength?: number; + min?: number | string; + minLength?: number; + multiple?: boolean; + name?: string; + pattern?: string; + placeholder?: string; + readOnly?: boolean; + required?: boolean; + size?: number; + src?: string; + step?: number | string; + type?: string; + value?: string | string[] | number; + width?: number | string; + + onChange?: ChangeEventHandler; + } + + interface KeygenHTMLAttributes extends HTMLAttributes { + autoFocus?: boolean; + challenge?: string; + disabled?: boolean; + form?: string; + keyType?: string; + keyParams?: string; + name?: string; + } + + interface LabelHTMLAttributes extends HTMLAttributes { + form?: string; + htmlFor?: string; + } + + interface LiHTMLAttributes extends HTMLAttributes { + value?: string | string[] | number; + } + + interface LinkHTMLAttributes extends HTMLAttributes { + as?: string; + crossOrigin?: string; + href?: string; + hrefLang?: string; + integrity?: string; + media?: string; + rel?: string; + sizes?: string; + type?: string; + } + + interface MapHTMLAttributes extends HTMLAttributes { + name?: string; + } + + interface MenuHTMLAttributes extends HTMLAttributes { + type?: string; + } + + interface MediaHTMLAttributes extends HTMLAttributes { + autoPlay?: boolean; + controls?: boolean; + controlsList?: string; + crossOrigin?: string; + loop?: boolean; + mediaGroup?: string; + muted?: boolean; + playsinline?: boolean; + preload?: string; + src?: string; + } + + interface MetaHTMLAttributes extends HTMLAttributes { + charSet?: string; + content?: string; + httpEquiv?: string; + name?: string; + } + + interface MeterHTMLAttributes extends HTMLAttributes { + form?: string; + high?: number; + low?: number; + max?: number | string; + min?: number | string; + optimum?: number; + value?: string | string[] | number; + } + + interface QuoteHTMLAttributes extends HTMLAttributes { + cite?: string; + } + + interface ObjectHTMLAttributes extends HTMLAttributes { + classID?: string; + data?: string; + form?: string; + height?: number | string; + name?: string; + type?: string; + useMap?: string; + width?: number | string; + wmode?: string; + } + + interface OlHTMLAttributes extends HTMLAttributes { + reversed?: boolean; + start?: number; + type?: '1' | 'a' | 'A' | 'i' | 'I'; + } + + interface OptgroupHTMLAttributes extends HTMLAttributes { + disabled?: boolean; + label?: string; + } + + interface OptionHTMLAttributes extends HTMLAttributes { + disabled?: boolean; + label?: string; + selected?: boolean; + value?: string | string[] | number; + } + + interface OutputHTMLAttributes extends HTMLAttributes { + form?: string; + htmlFor?: string; + name?: string; + } + + interface ParamHTMLAttributes extends HTMLAttributes { + name?: string; + value?: string | string[] | number; + } + + interface ProgressHTMLAttributes extends HTMLAttributes { + max?: number | string; + value?: string | string[] | number; + } + + interface ScriptHTMLAttributes extends HTMLAttributes { + async?: boolean; + charSet?: string; + crossOrigin?: string; + defer?: boolean; + integrity?: string; + noModule?: boolean; + nonce?: string; + src?: string; + type?: string; + } + + interface SelectHTMLAttributes extends HTMLAttributes { + autoComplete?: string; + autoFocus?: boolean; + disabled?: boolean; + form?: string; + multiple?: boolean; + name?: string; + required?: boolean; + size?: number; + value?: string | string[] | number; + onChange?: ChangeEventHandler; + } + + interface SourceHTMLAttributes extends HTMLAttributes { + media?: string; + sizes?: string; + src?: string; + srcSet?: string; + type?: string; + } + + interface StyleHTMLAttributes extends HTMLAttributes { + media?: string; + nonce?: string; + scoped?: boolean; + type?: string; + } + + interface TableHTMLAttributes extends HTMLAttributes { + cellPadding?: number | string; + cellSpacing?: number | string; + summary?: string; + } + + interface TextareaHTMLAttributes extends HTMLAttributes { + autoComplete?: string; + autoFocus?: boolean; + cols?: number; + dirName?: string; + disabled?: boolean; + form?: string; + maxLength?: number; + minLength?: number; + name?: string; + placeholder?: string; + readOnly?: boolean; + required?: boolean; + rows?: number; + value?: string | string[] | number; + wrap?: string; + + onChange?: ChangeEventHandler; + } + + interface TdHTMLAttributes extends HTMLAttributes { + align?: 'left' | 'center' | 'right' | 'justify' | 'char'; + colSpan?: number; + headers?: string; + rowSpan?: number; + scope?: string; + } + + interface ThHTMLAttributes extends HTMLAttributes { + align?: 'left' | 'center' | 'right' | 'justify' | 'char'; + colSpan?: number; + headers?: string; + rowSpan?: number; + scope?: string; + } + + interface TimeHTMLAttributes extends HTMLAttributes { + dateTime?: string; + } + + interface TrackHTMLAttributes extends HTMLAttributes { + default?: boolean; + kind?: string; + label?: string; + src?: string; + srcLang?: string; + } + + interface VideoHTMLAttributes extends MediaHTMLAttributes { + height?: number | string; + playsInline?: boolean; + poster?: string; + width?: number | string; + } + + // this list is "complete" in that it contains every SVG attribute + // that Rax supports, but the types can be improved. + // Full list here: https://facebook.github.io/rax/docs/dom-elements.html + // + // The three broad type categories are (in order of restrictiveness): + // - "number | string" + // - "string" + // - union of string literals + interface SVGAttributes extends AriaAttributes, DOMAttributes { + // Attributes which also defined in HTMLAttributes + // See comment in SVGDOMPropertyConfig.js + className?: string; + color?: string; + height?: number | string; + id?: string; + lang?: string; + max?: number | string; + media?: string; + method?: string; + min?: number | string; + name?: string; + style?: CSSProperties; + target?: string; + type?: string; + width?: number | string; + + // Other HTML properties supported by SVG elements in browsers + role?: string; + tabIndex?: number; + + // SVG Specific attributes + accentHeight?: number | string; + accumulate?: 'none' | 'sum'; + additive?: 'replace' | 'sum'; + alignmentBaseline?: + | 'auto' + | 'baseline' + | 'before-edge' + | 'text-before-edge' + | 'middle' + | 'central' + | 'after-edge' + | 'text-after-edge' + | 'ideographic' + | 'alphabetic' + | 'hanging' + | 'mathematical' + | 'inherit'; + allowReorder?: 'no' | 'yes'; + alphabetic?: number | string; + amplitude?: number | string; + arabicForm?: 'initial' | 'medial' | 'terminal' | 'isolated'; + ascent?: number | string; + attributeName?: string; + attributeType?: string; + autoReverse?: number | string; + azimuth?: number | string; + baseFrequency?: number | string; + baselineShift?: number | string; + baseProfile?: number | string; + bbox?: number | string; + begin?: number | string; + bias?: number | string; + by?: number | string; + calcMode?: number | string; + capHeight?: number | string; + clip?: number | string; + clipPath?: string; + clipPathUnits?: number | string; + clipRule?: number | string; + colorInterpolation?: number | string; + colorInterpolationFilters?: 'auto' | 'sRGB' | 'linearRGB' | 'inherit'; + colorProfile?: number | string; + colorRendering?: number | string; + contentScriptType?: number | string; + contentStyleType?: number | string; + cursor?: number | string; + cx?: number | string; + cy?: number | string; + d?: string; + decelerate?: number | string; + descent?: number | string; + diffuseConstant?: number | string; + direction?: number | string; + display?: number | string; + divisor?: number | string; + dominantBaseline?: number | string; + dur?: number | string; + dx?: number | string; + dy?: number | string; + edgeMode?: number | string; + elevation?: number | string; + enableBackground?: number | string; + end?: number | string; + exponent?: number | string; + externalResourcesRequired?: number | string; + fill?: string; + fillOpacity?: number | string; + fillRule?: 'nonzero' | 'evenodd' | 'inherit'; + filter?: string; + filterRes?: number | string; + filterUnits?: number | string; + floodColor?: number | string; + floodOpacity?: number | string; + focusable?: number | string; + fontFamily?: string; + fontSize?: number | string; + fontSizeAdjust?: number | string; + fontStretch?: number | string; + fontStyle?: number | string; + fontVariant?: number | string; + fontWeight?: number | string; + format?: number | string; + from?: number | string; + fx?: number | string; + fy?: number | string; + g1?: number | string; + g2?: number | string; + glyphName?: number | string; + glyphOrientationHorizontal?: number | string; + glyphOrientationVertical?: number | string; + glyphRef?: number | string; + gradientTransform?: string; + gradientUnits?: string; + hanging?: number | string; + horizAdvX?: number | string; + horizOriginX?: number | string; + href?: string; + ideographic?: number | string; + imageRendering?: number | string; + in2?: number | string; + in?: string; + intercept?: number | string; + k1?: number | string; + k2?: number | string; + k3?: number | string; + k4?: number | string; + k?: number | string; + kernelMatrix?: number | string; + kernelUnitLength?: number | string; + kerning?: number | string; + keyPoints?: number | string; + keySplines?: number | string; + keyTimes?: number | string; + lengthAdjust?: number | string; + letterSpacing?: number | string; + lightingColor?: number | string; + limitingConeAngle?: number | string; + local?: number | string; + markerEnd?: string; + markerHeight?: number | string; + markerMid?: string; + markerStart?: string; + markerUnits?: number | string; + markerWidth?: number | string; + mask?: string; + maskContentUnits?: number | string; + maskUnits?: number | string; + mathematical?: number | string; + mode?: number | string; + numOctaves?: number | string; + offset?: number | string; + opacity?: number | string; + operator?: number | string; + order?: number | string; + orient?: number | string; + orientation?: number | string; + origin?: number | string; + overflow?: number | string; + overlinePosition?: number | string; + overlineThickness?: number | string; + paintOrder?: number | string; + panose1?: number | string; + pathLength?: number | string; + patternContentUnits?: string; + patternTransform?: number | string; + patternUnits?: string; + pointerEvents?: number | string; + points?: string; + pointsAtX?: number | string; + pointsAtY?: number | string; + pointsAtZ?: number | string; + preserveAlpha?: number | string; + preserveAspectRatio?: string; + primitiveUnits?: number | string; + r?: number | string; + radius?: number | string; + refX?: number | string; + refY?: number | string; + renderingIntent?: number | string; + repeatCount?: number | string; + repeatDur?: number | string; + requiredExtensions?: number | string; + requiredFeatures?: number | string; + restart?: number | string; + result?: string; + rotate?: number | string; + rx?: number | string; + ry?: number | string; + scale?: number | string; + seed?: number | string; + shapeRendering?: number | string; + slope?: number | string; + spacing?: number | string; + specularConstant?: number | string; + specularExponent?: number | string; + speed?: number | string; + spreadMethod?: string; + startOffset?: number | string; + stdDeviation?: number | string; + stemh?: number | string; + stemv?: number | string; + stitchTiles?: number | string; + stopColor?: string; + stopOpacity?: number | string; + strikethroughPosition?: number | string; + strikethroughThickness?: number | string; + string?: number | string; + stroke?: string; + strokeDasharray?: string | number; + strokeDashoffset?: string | number; + strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit'; + strokeLinejoin?: 'miter' | 'round' | 'bevel' | 'inherit'; + strokeMiterlimit?: number | string; + strokeOpacity?: number | string; + strokeWidth?: number | string; + surfaceScale?: number | string; + systemLanguage?: number | string; + tableValues?: number | string; + targetX?: number | string; + targetY?: number | string; + textAnchor?: string; + textDecoration?: number | string; + textLength?: number | string; + textRendering?: number | string; + to?: number | string; + transform?: string; + u1?: number | string; + u2?: number | string; + underlinePosition?: number | string; + underlineThickness?: number | string; + unicode?: number | string; + unicodeBidi?: number | string; + unicodeRange?: number | string; + unitsPerEm?: number | string; + vAlphabetic?: number | string; + values?: string; + vectorEffect?: number | string; + version?: string; + vertAdvY?: number | string; + vertOriginX?: number | string; + vertOriginY?: number | string; + vHanging?: number | string; + vIdeographic?: number | string; + viewBox?: string; + viewTarget?: number | string; + visibility?: number | string; + vMathematical?: number | string; + widths?: number | string; + wordSpacing?: number | string; + writingMode?: number | string; + x1?: number | string; + x2?: number | string; + x?: number | string; + xChannelSelector?: string; + xHeight?: number | string; + xlinkActuate?: string; + xlinkArcrole?: string; + xlinkHref?: string; + xlinkRole?: string; + xlinkShow?: string; + xlinkTitle?: string; + xlinkType?: string; + xmlBase?: string; + xmlLang?: string; + xmlns?: string; + xmlnsXlink?: string; + xmlSpace?: string; + y1?: number | string; + y2?: number | string; + y?: number | string; + yChannelSelector?: string; + z?: number | string; + zoomAndPan?: string; + } + + interface WebViewHTMLAttributes extends HTMLAttributes { + allowFullScreen?: boolean; + allowpopups?: boolean; + autoFocus?: boolean; + autosize?: boolean; + blinkfeatures?: string; + disableblinkfeatures?: string; + disableguestresize?: boolean; + disablewebsecurity?: boolean; + guestinstance?: string; + httpreferrer?: string; + nodeintegration?: boolean; + partition?: string; + plugins?: boolean; + preload?: string; + src?: string; + useragent?: string; + webpreferences?: string; + } + + // + // Rax.DOM + // ---------------------------------------------------------------------- + + interface RaxHTML { + a: DetailedHTMLFactory, HTMLAnchorElement>; + abbr: DetailedHTMLFactory, HTMLElement>; + address: DetailedHTMLFactory, HTMLElement>; + area: DetailedHTMLFactory, HTMLAreaElement>; + article: DetailedHTMLFactory, HTMLElement>; + aside: DetailedHTMLFactory, HTMLElement>; + audio: DetailedHTMLFactory, HTMLAudioElement>; + b: DetailedHTMLFactory, HTMLElement>; + base: DetailedHTMLFactory, HTMLBaseElement>; + bdi: DetailedHTMLFactory, HTMLElement>; + bdo: DetailedHTMLFactory, HTMLElement>; + big: DetailedHTMLFactory, HTMLElement>; + blockquote: DetailedHTMLFactory, HTMLElement>; + body: DetailedHTMLFactory, HTMLBodyElement>; + br: DetailedHTMLFactory, HTMLBRElement>; + button: DetailedHTMLFactory, HTMLButtonElement>; + canvas: DetailedHTMLFactory, HTMLCanvasElement>; + caption: DetailedHTMLFactory, HTMLElement>; + cite: DetailedHTMLFactory, HTMLElement>; + code: DetailedHTMLFactory, HTMLElement>; + col: DetailedHTMLFactory, HTMLTableColElement>; + colgroup: DetailedHTMLFactory, HTMLTableColElement>; + data: DetailedHTMLFactory, HTMLElement>; + datalist: DetailedHTMLFactory, HTMLDataListElement>; + dd: DetailedHTMLFactory, HTMLElement>; + del: DetailedHTMLFactory, HTMLElement>; + details: DetailedHTMLFactory, HTMLElement>; + dfn: DetailedHTMLFactory, HTMLElement>; + dialog: DetailedHTMLFactory, HTMLDialogElement>; + div: DetailedHTMLFactory, HTMLDivElement>; + dl: DetailedHTMLFactory, HTMLDListElement>; + dt: DetailedHTMLFactory, HTMLElement>; + em: DetailedHTMLFactory, HTMLElement>; + embed: DetailedHTMLFactory, HTMLEmbedElement>; + fieldset: DetailedHTMLFactory, HTMLFieldSetElement>; + figcaption: DetailedHTMLFactory, HTMLElement>; + figure: DetailedHTMLFactory, HTMLElement>; + footer: DetailedHTMLFactory, HTMLElement>; + form: DetailedHTMLFactory, HTMLFormElement>; + h1: DetailedHTMLFactory, HTMLHeadingElement>; + h2: DetailedHTMLFactory, HTMLHeadingElement>; + h3: DetailedHTMLFactory, HTMLHeadingElement>; + h4: DetailedHTMLFactory, HTMLHeadingElement>; + h5: DetailedHTMLFactory, HTMLHeadingElement>; + h6: DetailedHTMLFactory, HTMLHeadingElement>; + head: DetailedHTMLFactory, HTMLHeadElement>; + header: DetailedHTMLFactory, HTMLElement>; + hgroup: DetailedHTMLFactory, HTMLElement>; + hr: DetailedHTMLFactory, HTMLHRElement>; + html: DetailedHTMLFactory, HTMLHtmlElement>; + i: DetailedHTMLFactory, HTMLElement>; + iframe: DetailedHTMLFactory, HTMLIFrameElement>; + img: DetailedHTMLFactory, HTMLImageElement>; + input: DetailedHTMLFactory, HTMLInputElement>; + ins: DetailedHTMLFactory, HTMLModElement>; + kbd: DetailedHTMLFactory, HTMLElement>; + keygen: DetailedHTMLFactory, HTMLElement>; + label: DetailedHTMLFactory, HTMLLabelElement>; + legend: DetailedHTMLFactory, HTMLLegendElement>; + li: DetailedHTMLFactory, HTMLLIElement>; + link: DetailedHTMLFactory, HTMLLinkElement>; + main: DetailedHTMLFactory, HTMLElement>; + map: DetailedHTMLFactory, HTMLMapElement>; + mark: DetailedHTMLFactory, HTMLElement>; + menu: DetailedHTMLFactory, HTMLElement>; + menuitem: DetailedHTMLFactory, HTMLElement>; + meta: DetailedHTMLFactory, HTMLMetaElement>; + meter: DetailedHTMLFactory, HTMLElement>; + nav: DetailedHTMLFactory, HTMLElement>; + noscript: DetailedHTMLFactory, HTMLElement>; + object: DetailedHTMLFactory, HTMLObjectElement>; + ol: DetailedHTMLFactory, HTMLOListElement>; + optgroup: DetailedHTMLFactory, HTMLOptGroupElement>; + option: DetailedHTMLFactory, HTMLOptionElement>; + output: DetailedHTMLFactory, HTMLElement>; + p: DetailedHTMLFactory, HTMLParagraphElement>; + param: DetailedHTMLFactory, HTMLParamElement>; + picture: DetailedHTMLFactory, HTMLElement>; + pre: DetailedHTMLFactory, HTMLPreElement>; + progress: DetailedHTMLFactory, HTMLProgressElement>; + q: DetailedHTMLFactory, HTMLQuoteElement>; + rp: DetailedHTMLFactory, HTMLElement>; + rt: DetailedHTMLFactory, HTMLElement>; + ruby: DetailedHTMLFactory, HTMLElement>; + s: DetailedHTMLFactory, HTMLElement>; + samp: DetailedHTMLFactory, HTMLElement>; + script: DetailedHTMLFactory, HTMLScriptElement>; + section: DetailedHTMLFactory, HTMLElement>; + select: DetailedHTMLFactory, HTMLSelectElement>; + small: DetailedHTMLFactory, HTMLElement>; + source: DetailedHTMLFactory, HTMLSourceElement>; + span: DetailedHTMLFactory, HTMLSpanElement>; + strong: DetailedHTMLFactory, HTMLElement>; + style: DetailedHTMLFactory, HTMLStyleElement>; + sub: DetailedHTMLFactory, HTMLElement>; + summary: DetailedHTMLFactory, HTMLElement>; + sup: DetailedHTMLFactory, HTMLElement>; + table: DetailedHTMLFactory, HTMLTableElement>; + tbody: DetailedHTMLFactory, HTMLTableSectionElement>; + td: DetailedHTMLFactory, HTMLTableDataCellElement>; + textarea: DetailedHTMLFactory, HTMLTextAreaElement>; + tfoot: DetailedHTMLFactory, HTMLTableSectionElement>; + th: DetailedHTMLFactory< + ThHTMLAttributes, + HTMLTableHeaderCellElement + >; + thead: DetailedHTMLFactory, HTMLTableSectionElement>; + time: DetailedHTMLFactory, HTMLElement>; + title: DetailedHTMLFactory, HTMLTitleElement>; + tr: DetailedHTMLFactory, HTMLTableRowElement>; + track: DetailedHTMLFactory, HTMLTrackElement>; + u: DetailedHTMLFactory, HTMLElement>; + ul: DetailedHTMLFactory, HTMLUListElement>; + var: DetailedHTMLFactory, HTMLElement>; + video: DetailedHTMLFactory, HTMLVideoElement>; + wbr: DetailedHTMLFactory, HTMLElement>; + webview: DetailedHTMLFactory, HTMLWebViewElement>; + } + + interface RaxSVG { + animate: SVGFactory; + circle: SVGFactory; + clipPath: SVGFactory; + defs: SVGFactory; + desc: SVGFactory; + ellipse: SVGFactory; + feBlend: SVGFactory; + feColorMatrix: SVGFactory; + feComponentTransfer: SVGFactory; + feComposite: SVGFactory; + feConvolveMatrix: SVGFactory; + feDiffuseLighting: SVGFactory; + feDisplacementMap: SVGFactory; + feDistantLight: SVGFactory; + feDropShadow: SVGFactory; + feFlood: SVGFactory; + feFuncA: SVGFactory; + feFuncB: SVGFactory; + feFuncG: SVGFactory; + feFuncR: SVGFactory; + feGaussianBlur: SVGFactory; + feImage: SVGFactory; + feMerge: SVGFactory; + feMergeNode: SVGFactory; + feMorphology: SVGFactory; + feOffset: SVGFactory; + fePointLight: SVGFactory; + feSpecularLighting: SVGFactory; + feSpotLight: SVGFactory; + feTile: SVGFactory; + feTurbulence: SVGFactory; + filter: SVGFactory; + foreignObject: SVGFactory; + g: SVGFactory; + image: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + marker: SVGFactory; + mask: SVGFactory; + metadata: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + svg: SVGFactory; + switch: SVGFactory; + symbol: SVGFactory; + text: SVGFactory; + textPath: SVGFactory; + tspan: SVGFactory; + use: SVGFactory; + view: SVGFactory; + } + + interface RaxDOM extends RaxHTML, RaxSVG {} + + // + // Rax.PropTypes + // ---------------------------------------------------------------------- + + type Validator = PropTypes.Validator; + + type Requireable = PropTypes.Requireable; + + type ValidationMap = PropTypes.ValidationMap; + + type WeakValidationMap = { + [K in keyof T]?: null extends T[K] + ? Validator + : undefined extends T[K] + ? Validator + : Validator + }; + + interface RaxPropTypes { + any: typeof PropTypes.any; + array: typeof PropTypes.array; + bool: typeof PropTypes.bool; + func: typeof PropTypes.func; + number: typeof PropTypes.number; + object: typeof PropTypes.object; + string: typeof PropTypes.string; + node: typeof PropTypes.node; + element: typeof PropTypes.element; + instanceOf: typeof PropTypes.instanceOf; + oneOf: typeof PropTypes.oneOf; + oneOfType: typeof PropTypes.oneOfType; + arrayOf: typeof PropTypes.arrayOf; + objectOf: typeof PropTypes.objectOf; + shape: typeof PropTypes.shape; + exact: typeof PropTypes.exact; + } + + // + // Rax.Children + // ---------------------------------------------------------------------- + + interface RaxChildren { + map(children: C | C[], fn: (child: C, index: number) => T): + C extends null | undefined ? C : Array>; + forEach(children: C | C[], fn: (child: C, index: number) => void): void; + count(children: any): number; + only(children: C): C extends any[] ? never : C; + toArray(children: C | C[]): C[]; + } + + // + // 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; + 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; + } + + // + // Error Interfaces + // ---------------------------------------------------------------------- + interface ErrorInfo { + /** + * Captures which component contained the exception, and its ancestors. + */ + componentStack: string; + } +} + +// naked 'any' type in a conditional type will short circuit and union both the then/else branches +// so boolean is only resolved for T = any +type IsExactlyAny = boolean extends (T extends never ? true : false) ? true : false; + +type ExactlyAnyPropertyKeys = { + [K in keyof T]: IsExactlyAny extends true ? K : never +}[keyof T]; +type NotExactlyAnyPropertyKeys = Exclude>; + +// Try to resolve ill-defined props like for JS users: props can be any, or sometimes objects with properties of type any +type MergePropTypes = + // Distribute over P in case it is a union type + P extends any // If props is type any, use propTypes definitions + ? IsExactlyAny

extends true + ? T // If declared props have indexed properties, ignore inferred props entirely as keyof gets widened + : string extends keyof P + ? P // Prefer declared types which are not exactly any + : Pick> & + // For props which are exactly any, use the type inferred from propTypes if present + Pick>> & + // Keep leftover props not specified in propTypes + Pick> + : never; + +// Any prop that has a default prop becomes optional, but its type is unchanged +// Undeclared default props are augmented into the resulting allowable attributes +// If declared props have indexed properties, ignore default props entirely as keyof gets widened +// Wrap in an outer-level conditional type to allow distribution over props that are unions +type Defaultize = P extends any + ? string extends keyof P + ? P + : Pick> & + Partial>> & + Partial>> + : never; + +type RaxManagedAttributes = C extends { propTypes: infer T; defaultProps: infer D } + ? Defaultize>, D> + : C extends { propTypes: infer T } + ? MergePropTypes> + : C extends { defaultProps: infer D } + ? Defaultize + : P; + +declare global { + namespace JSX { + // tslint:disable-next-line:no-empty-interface + interface Element extends Rax.RaxElement {} + interface ElementClass extends Rax.Component { + render(): Rax.RaxNode; + } + interface ElementAttributesProperty { + props: {}; + } + interface ElementChildrenAttribute { + children: {}; + } + + // We can't recurse forever because `type` can't be self-referential; + // let's assume it's reasonable to do a single Rax.lazy() around a single Rax.memo() / vice-versa + type LibraryManagedAttributes = C extends Rax.MemoExoticComponent + ? T extends Rax.MemoExoticComponent + ? RaxManagedAttributes + : RaxManagedAttributes + : RaxManagedAttributes; + + // tslint:disable-next-line:no-empty-interface + interface IntrinsicAttributes extends Rax.Attributes {} + // tslint:disable-next-line:no-empty-interface + interface IntrinsicClassAttributes extends Rax.ClassAttributes {} + + interface IntrinsicElements { + // HTML + a: Rax.DetailedHTMLProps, HTMLAnchorElement>; + abbr: Rax.DetailedHTMLProps, HTMLElement>; + address: Rax.DetailedHTMLProps, HTMLElement>; + area: Rax.DetailedHTMLProps, HTMLAreaElement>; + article: Rax.DetailedHTMLProps, HTMLElement>; + aside: Rax.DetailedHTMLProps, HTMLElement>; + audio: Rax.DetailedHTMLProps, HTMLAudioElement>; + b: Rax.DetailedHTMLProps, HTMLElement>; + base: Rax.DetailedHTMLProps, HTMLBaseElement>; + bdi: Rax.DetailedHTMLProps, HTMLElement>; + bdo: Rax.DetailedHTMLProps, HTMLElement>; + big: Rax.DetailedHTMLProps, HTMLElement>; + blockquote: Rax.DetailedHTMLProps, HTMLElement>; + body: Rax.DetailedHTMLProps, HTMLBodyElement>; + br: Rax.DetailedHTMLProps, HTMLBRElement>; + button: Rax.DetailedHTMLProps, HTMLButtonElement>; + canvas: Rax.DetailedHTMLProps, HTMLCanvasElement>; + caption: Rax.DetailedHTMLProps, HTMLElement>; + cite: Rax.DetailedHTMLProps, HTMLElement>; + code: Rax.DetailedHTMLProps, HTMLElement>; + col: Rax.DetailedHTMLProps, HTMLTableColElement>; + colgroup: Rax.DetailedHTMLProps< + Rax.ColgroupHTMLAttributes, + HTMLTableColElement + >; + data: Rax.DetailedHTMLProps, HTMLElement>; + datalist: Rax.DetailedHTMLProps, HTMLDataListElement>; + dd: Rax.DetailedHTMLProps, HTMLElement>; + del: Rax.DetailedHTMLProps, HTMLElement>; + details: Rax.DetailedHTMLProps, HTMLElement>; + dfn: Rax.DetailedHTMLProps, HTMLElement>; + dialog: Rax.DetailedHTMLProps, HTMLDialogElement>; + div: Rax.DetailedHTMLProps, HTMLDivElement>; + dl: Rax.DetailedHTMLProps, HTMLDListElement>; + dt: Rax.DetailedHTMLProps, HTMLElement>; + em: Rax.DetailedHTMLProps, HTMLElement>; + embed: Rax.DetailedHTMLProps, HTMLEmbedElement>; + fieldset: Rax.DetailedHTMLProps< + Rax.FieldsetHTMLAttributes, + HTMLFieldSetElement + >; + figcaption: Rax.DetailedHTMLProps, HTMLElement>; + figure: Rax.DetailedHTMLProps, HTMLElement>; + footer: Rax.DetailedHTMLProps, HTMLElement>; + form: Rax.DetailedHTMLProps, HTMLFormElement>; + h1: Rax.DetailedHTMLProps, HTMLHeadingElement>; + h2: Rax.DetailedHTMLProps, HTMLHeadingElement>; + h3: Rax.DetailedHTMLProps, HTMLHeadingElement>; + h4: Rax.DetailedHTMLProps, HTMLHeadingElement>; + h5: Rax.DetailedHTMLProps, HTMLHeadingElement>; + h6: Rax.DetailedHTMLProps, HTMLHeadingElement>; + head: Rax.DetailedHTMLProps, HTMLHeadElement>; + header: Rax.DetailedHTMLProps, HTMLElement>; + hgroup: Rax.DetailedHTMLProps, HTMLElement>; + hr: Rax.DetailedHTMLProps, HTMLHRElement>; + html: Rax.DetailedHTMLProps, HTMLHtmlElement>; + i: Rax.DetailedHTMLProps, HTMLElement>; + iframe: Rax.DetailedHTMLProps, HTMLIFrameElement>; + img: Rax.DetailedHTMLProps, HTMLImageElement>; + input: Rax.DetailedHTMLProps, HTMLInputElement>; + ins: Rax.DetailedHTMLProps, HTMLModElement>; + kbd: Rax.DetailedHTMLProps, HTMLElement>; + keygen: Rax.DetailedHTMLProps, HTMLElement>; + label: Rax.DetailedHTMLProps, HTMLLabelElement>; + legend: Rax.DetailedHTMLProps, HTMLLegendElement>; + li: Rax.DetailedHTMLProps, HTMLLIElement>; + link: Rax.DetailedHTMLProps, HTMLLinkElement>; + main: Rax.DetailedHTMLProps, HTMLElement>; + map: Rax.DetailedHTMLProps, HTMLMapElement>; + mark: Rax.DetailedHTMLProps, HTMLElement>; + menu: Rax.DetailedHTMLProps, HTMLElement>; + menuitem: Rax.DetailedHTMLProps, HTMLElement>; + meta: Rax.DetailedHTMLProps, HTMLMetaElement>; + meter: Rax.DetailedHTMLProps, HTMLElement>; + nav: Rax.DetailedHTMLProps, HTMLElement>; + noindex: Rax.DetailedHTMLProps, HTMLElement>; + noscript: Rax.DetailedHTMLProps, HTMLElement>; + object: Rax.DetailedHTMLProps, HTMLObjectElement>; + ol: Rax.DetailedHTMLProps, HTMLOListElement>; + optgroup: Rax.DetailedHTMLProps< + Rax.OptgroupHTMLAttributes, + HTMLOptGroupElement + >; + option: Rax.DetailedHTMLProps, HTMLOptionElement>; + output: Rax.DetailedHTMLProps, HTMLElement>; + p: Rax.DetailedHTMLProps, HTMLParagraphElement>; + param: Rax.DetailedHTMLProps, HTMLParamElement>; + picture: Rax.DetailedHTMLProps, HTMLElement>; + pre: Rax.DetailedHTMLProps, HTMLPreElement>; + progress: Rax.DetailedHTMLProps< + Rax.ProgressHTMLAttributes, + HTMLProgressElement + >; + q: Rax.DetailedHTMLProps, HTMLQuoteElement>; + rp: Rax.DetailedHTMLProps, HTMLElement>; + rt: Rax.DetailedHTMLProps, HTMLElement>; + ruby: Rax.DetailedHTMLProps, HTMLElement>; + s: Rax.DetailedHTMLProps, HTMLElement>; + samp: Rax.DetailedHTMLProps, HTMLElement>; + script: Rax.DetailedHTMLProps, HTMLScriptElement>; + section: Rax.DetailedHTMLProps, HTMLElement>; + select: Rax.DetailedHTMLProps, HTMLSelectElement>; + small: Rax.DetailedHTMLProps, HTMLElement>; + source: Rax.DetailedHTMLProps, HTMLSourceElement>; + span: Rax.DetailedHTMLProps, HTMLSpanElement>; + strong: Rax.DetailedHTMLProps, HTMLElement>; + style: Rax.DetailedHTMLProps, HTMLStyleElement>; + sub: Rax.DetailedHTMLProps, HTMLElement>; + summary: Rax.DetailedHTMLProps, HTMLElement>; + sup: Rax.DetailedHTMLProps, HTMLElement>; + table: Rax.DetailedHTMLProps, HTMLTableElement>; + tbody: Rax.DetailedHTMLProps< + Rax.HTMLAttributes, + HTMLTableSectionElement + >; + td: Rax.DetailedHTMLProps< + Rax.TdHTMLAttributes, + HTMLTableDataCellElement + >; + textarea: Rax.DetailedHTMLProps< + Rax.TextareaHTMLAttributes, + HTMLTextAreaElement + >; + tfoot: Rax.DetailedHTMLProps< + Rax.HTMLAttributes, + HTMLTableSectionElement + >; + th: Rax.DetailedHTMLProps< + Rax.ThHTMLAttributes, + HTMLTableHeaderCellElement + >; + thead: Rax.DetailedHTMLProps< + Rax.HTMLAttributes, + HTMLTableSectionElement + >; + time: Rax.DetailedHTMLProps, HTMLElement>; + title: Rax.DetailedHTMLProps, HTMLTitleElement>; + tr: Rax.DetailedHTMLProps, HTMLTableRowElement>; + track: Rax.DetailedHTMLProps, HTMLTrackElement>; + u: Rax.DetailedHTMLProps, HTMLElement>; + ul: Rax.DetailedHTMLProps, HTMLUListElement>; + var: Rax.DetailedHTMLProps, HTMLElement>; + video: Rax.DetailedHTMLProps, HTMLVideoElement>; + wbr: Rax.DetailedHTMLProps, HTMLElement>; + webview: Rax.DetailedHTMLProps< + Rax.WebViewHTMLAttributes, + HTMLWebViewElement + >; + + // SVG + svg: Rax.SVGProps; + + animate: Rax.SVGProps; // TODO: It is SVGAnimateElement but is not in TypeScript's lib.dom.d.ts for now. + animateMotion: Rax.SVGProps; + animateTransform: Rax.SVGProps; // TODO: It is SVGAnimateTransformElement but is not in TypeScript's lib.dom.d.ts for now. + circle: Rax.SVGProps; + clipPath: Rax.SVGProps; + defs: Rax.SVGProps; + desc: Rax.SVGProps; + ellipse: Rax.SVGProps; + feBlend: Rax.SVGProps; + feColorMatrix: Rax.SVGProps; + feComponentTransfer: Rax.SVGProps; + feComposite: Rax.SVGProps; + feConvolveMatrix: Rax.SVGProps; + feDiffuseLighting: Rax.SVGProps; + feDisplacementMap: Rax.SVGProps; + feDistantLight: Rax.SVGProps; + feDropShadow: Rax.SVGProps; + feFlood: Rax.SVGProps; + feFuncA: Rax.SVGProps; + feFuncB: Rax.SVGProps; + feFuncG: Rax.SVGProps; + feFuncR: Rax.SVGProps; + feGaussianBlur: Rax.SVGProps; + feImage: Rax.SVGProps; + feMerge: Rax.SVGProps; + feMergeNode: Rax.SVGProps; + feMorphology: Rax.SVGProps; + feOffset: Rax.SVGProps; + fePointLight: Rax.SVGProps; + feSpecularLighting: Rax.SVGProps; + feSpotLight: Rax.SVGProps; + feTile: Rax.SVGProps; + feTurbulence: Rax.SVGProps; + filter: Rax.SVGProps; + foreignObject: Rax.SVGProps; + g: Rax.SVGProps; + image: Rax.SVGProps; + line: Rax.SVGProps; + linearGradient: Rax.SVGProps; + marker: Rax.SVGProps; + mask: Rax.SVGProps; + metadata: Rax.SVGProps; + mpath: Rax.SVGProps; + path: Rax.SVGProps; + pattern: Rax.SVGProps; + polygon: Rax.SVGProps; + polyline: Rax.SVGProps; + radialGradient: Rax.SVGProps; + rect: Rax.SVGProps; + stop: Rax.SVGProps; + switch: Rax.SVGProps; + symbol: Rax.SVGProps; + text: Rax.SVGProps; + textPath: Rax.SVGProps; + tspan: Rax.SVGProps; + use: Rax.SVGProps; + view: Rax.SVGProps; + + // weex + list: any; + cell: any; + loading: any; + refresh: any; + 'recycle-list': any; + scroller: any; + slider: any; + indicator: any; + waterfall: any; + web: any; + richtext: any; + + // MiniApp + slot: any; + swiper: any; + 'swiper-item': any; + 'scroll-view': any; + 'cover-view': any; + 'cover-image': any; + 'movable-view': any; + 'movable-area': any; + icon: any; + 'rich-text': any; + 'picker-view': any; + picker: any; + navigator: any; + 'web-view': any; + 'lifestyle': any; + 'contact-button': any; + 'aria-component': any; + 'functional-page-navigator': any; + 'live-player': any; + 'ive-pusher': any; + ad: any; + 'open-data': any; + 'page-meta': any; + 'navigation-bar': any; + } + } +} diff --git a/types/rax/package.json b/types/rax/package.json new file mode 100644 index 0000000000..e6696d08e7 --- /dev/null +++ b/types/rax/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "csstype": "^2.2.0" + } +} diff --git a/types/rax/tsconfig.json b/types/rax/tsconfig.json new file mode 100644 index 0000000000..3ba1bb3b51 --- /dev/null +++ b/types/rax/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "preserve" + }, + "files": [ + "index.d.ts" + ] +} diff --git a/types/rax/tslint.json b/types/rax/tslint.json new file mode 100644 index 0000000000..6d27bd5e40 --- /dev/null +++ b/types/rax/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "dt-header": false, + "no-empty-interface": false, + "no-object-literal-type-assertion": false, + "no-unnecessary-generics": false, + "strict-export-declare-modifiers": false, + "void-return": false + } +}