diff --git a/types/react/README.md b/types/react/README.md
deleted file mode 100644
index 594b16d48f..0000000000
--- a/types/react/README.md
+++ /dev/null
@@ -1,60 +0,0 @@
-## Known Problems & Workarounds
-
-### **The type of `cloneElement` is incorrect.**
-`cloneElement(element, props)` should should accept a `props` object with a subset of the properties on `element.props`. React attributes such as `key` and `ref` should also be accepted in `props`, but should not exist on `element.props`. The "correct" way to model this, then, is with
-```ts
-declare function cloneElement
;
-```
-However, type inference for `Q` defaults to `{}` when [intersected with another type](https://github.com/Microsoft/TypeScript/pull/5738#issuecomment-181904905). And since any object is assignable to `{}`, we would lose the type safety of the `P extends Q` constraint. Therefore, the type of `props` is left as `Q`, which should work for most cases. If you need to call `cloneElement` with `key` or `ref`, you'll need a type cast:
-```ts
-interface ButtonProps {
- label: string,
- isDisabled?: boolean;
-}
-var element: React.CElement;
-
-React.cloneElement(element, { label: "label" });
-
-// cloning with optional props requires a cast
-React.cloneElement(element, <{ isDisabled?: boolean }>{ isDisabled: true });
-
-// cloning with key or ref requires a cast
-React.cloneElement(element, >{ ref: button => button.reset() });
-React.cloneElement(element, <{ isDisabled?: boolean } & React.Attributes>{
- key: "disabledButton",
- isDisabled: true
-});
-```
-
-### **`React.Component
` subclass members aren't contextually typed.**
-This problem manifests itself in two ways. It should be fixed in [TypeScript 2.0](https://github.com/Microsoft/TypeScript/pull/6118).
-
- - You might expect `componentDidUpdate(prevProps, prevState)` to have `prevProps` and `prevState` contextually typed as `P` and `S` respectively, but currently that is not the case. You must explicitly type-annotate both arguments.
-
- - You may get a cryptic error message when either `React.createElement` or `React.createFactory` doesn't recognize the `type` argument that you passed in as a valid `React.Component` subclass, because you overrode one of the static or instance members with a type that's not compatible with the superclass property's type. For example, with the following code:
- ```ts
- import * as React from "react";
-
- class MyComponent extends React.Component {
- static contextTypes = {
- someValue: React.PropTypes.string
- };
- }
-
- React.createFactory(MyComponent);
- ```
- you might get this error:
- ```
- error TS2345: Argument of type 'typeof MyComponent' is not assignable to parameter of type 'string | ComponentClass | StatelessComponent'
- Type 'typeof ModernComponent' is not assignable to type 'StatelessComponent'.
- Types of property 'contextTypes' are incompatible.
- Type '{ someValue: Requireable; }' is not assignable to type 'ValidationMap'.
- Index signature is missing in type '{ someValue: Requireable; }'.
- ```
- The work around is to add an explicit type annotation:
- ```ts
- static contextTypes: React.ValidationMap = ...
- ```
diff --git a/types/react/index.d.ts b/types/react/index.d.ts
index abc5dd3f4a..6b5b163048 100644
--- a/types/react/index.d.ts
+++ b/types/react/index.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for React 15.6
+// Type definitions for React 16.0
// Project: http://facebook.github.io/react/
// Definitions by: Asana
// AssureSign
@@ -12,9 +12,41 @@
// Tanguy Krotoff
// Dovydas Navickas
// Stéphane Goetz
+// Rich Seviora
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
+/*
+Known Problems & Workarounds
+1. The type of cloneElement is incorrect.
+cloneElement(element, props) should accept props object with a subset of properties on element.props.
+React attributes, such as key and ref, should also be accepted in props, but should not exist on element.props.
+The "correct" way to model this, then, is with:
+declare function cloneElement
;
+However, type inference for Q defaults to {} when intersected with another type.
+(https://github.com/Microsoft/TypeScript/pull/5738#issuecomment-181904905)
+And since any object is assignable to {}, we would lose the type safety of the P extends Q constraint.
+Therefore, the type of props is left as Q, which should work for most cases.
+If you need to call cloneElement with key or ref, you'll need a type cast:
+interface ButtonProps {
+ label: string,
+ isDisabled?: boolean;
+}
+var element: React.CElement;
+React.cloneElement(element, { label: "label" });
+// cloning with optional props requires a cast
+React.cloneElement(element, <{ isDisabled?: boolean }>{ isDisabled: true });
+// cloning with key or ref requires a cast
+React.cloneElement(element, >{ ref: button => button.reset() });
+React.cloneElement(element, <{ isDisabled?: boolean } & React.Attributes>{
+ key: "disabledButton",
+ isDisabled: true
+});
+*/
+
type NativeAnimationEvent = AnimationEvent;
type NativeClipboardEvent = ClipboardEvent;
type NativeCompositionEvent = CompositionEvent;
@@ -321,6 +353,11 @@ declare namespace React {
componentWillUpdate?(nextProps: Readonly
, prevState: Readonly, prevContext: any): void;
componentWillUnmount?(): void;
+ /**
+ * Catches exceptions generated in descendant components. Unhandled exceptions will cause
+ * the entire component tree to unmount.
+ */
+ componentDidCatch?(error: Error, errorInfo: ErrorInfo): void;
}
interface Mixin
extends ComponentLifecycle
{
@@ -3354,6 +3391,16 @@ declare namespace React {
item(index: number): Touch;
identifiedTouch(identifier: number): Touch;
}
+
+ //
+ // Error Interfaces
+ // ----------------------------------------------------------------------
+ interface ErrorInfo {
+ /**
+ * Captures which component contained the exception, and it's ancestors.
+ */
+ componentStack: string;
+ }
}
declare global {
diff --git a/types/react/v15/index.d.ts b/types/react/v15/index.d.ts
new file mode 100644
index 0000000000..5082c5a1d6
--- /dev/null
+++ b/types/react/v15/index.d.ts
@@ -0,0 +1,3587 @@
+// Type definitions for React 15.6
+// Project: http://facebook.github.io/react/
+// Definitions by: Asana
+// AssureSign
+// Microsoft
+// John Reilly
+// Benoit Benezech
+// Patricio Zavolinsky
+// Digiguru
+// Eric Anderson
+// Albert Kurniawan
+// Tanguy Krotoff
+// Dovydas Navickas
+// Stéphane Goetz
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.3
+
+/*
+Known Problems & Workarounds
+
+1. The type of cloneElement is incorrect.
+cloneElement(element, props) should accept props object with a subset of properties on element.props.
+React attributes, such as key and ref, should also be accepted in props, but should not exist on element.props.
+The "correct" way to model this, then, is with:
+
+declare function cloneElement
;
+
+However, type inference for Q defaults to {} when intersected with another type.
+(https://github.com/Microsoft/TypeScript/pull/5738#issuecomment-181904905)
+And since any object is assignable to {}, we would lose the type safety of the P extends Q constraint.
+Therefore, the type of props is left as Q, which should work for most cases.
+If you need to call cloneElement with key or ref, you'll need a type cast:
+
+interface ButtonProps {
+ label: string,
+ isDisabled?: boolean;
+}
+var element: React.CElement;
+
+React.cloneElement(element, { label: "label" });
+
+// cloning with optional props requires a cast
+React.cloneElement(element, <{ isDisabled?: boolean }>{ isDisabled: true });
+
+// cloning with key or ref requires a cast
+React.cloneElement(element, >{ ref: button => button.reset() });
+React.cloneElement(element, <{ isDisabled?: boolean } & React.Attributes>{
+ key: "disabledButton",
+ isDisabled: true
+});
+*/
+
+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 NativeTransitionEvent = TransitionEvent;
+type NativeUIEvent = UIEvent;
+type NativeWheelEvent = WheelEvent;
+
+// tslint:disable-next-line:export-just-namespace
+export = React;
+export as namespace React;
+
+declare namespace React {
+ //
+ // React Elements
+ // ----------------------------------------------------------------------
+
+ type ReactType = string | ComponentType;
+ type ComponentType
;
+ }
+
+ interface SVGFactory extends DOMFactory, SVGElement> {
+ (props?: ClassAttributes & SVGAttributes | null, ...children: ReactNode[]): ReactSVGElement;
+ }
+
+ //
+ // React Nodes
+ // http://facebook.github.io/react/docs/glossary.html
+ // ----------------------------------------------------------------------
+
+ type ReactText = string | number;
+ type ReactChild = ReactElement | ReactText;
+
+ // Should be Array but type aliases cannot be recursive
+ type ReactFragment = {} | Array;
+ type ReactNode = ReactChild | ReactFragment | boolean | null | undefined;
+
+ //
+ // Top Level API
+ // ----------------------------------------------------------------------
+
+ function createClass
(spec: ComponentSpec
): ClassicComponentClass
;
+
+ // DOM Elements
+ function createFactory(
+ type: keyof ReactHTML): HTMLFactory;
+ function createFactory(
+ type: keyof ReactSVG): SVGFactory;
+ function createFactory
, T extends Element>(
+ type: string): DOMFactory
;
+
+ // Custom components
+ function createFactory
;
+ // ReactHTMLElement, less specific
+ function cloneElement
, T extends HTMLElement>(
+ element: ReactHTMLElement,
+ props?: P,
+ ...children: ReactNode[]): ReactHTMLElement;
+ // SVGElement
+ function cloneElement
, T extends SVGElement>(
+ element: ReactSVGElement,
+ props?: P,
+ ...children: ReactNode[]): ReactSVGElement;
+ // DOM Element (has to be the last, because type checking stops at first overload that fits)
+ function cloneElement
{
+ constructor(props?: P, context?: any);
+
+ // Disabling unified-signatures to have separate overloads. It's easier to understand this way.
+ // tslint:disable:unified-signatures
+ setState(f: (prevState: S, props: P) => Pick, callback?: () => any): void;
+ setState(state: Pick, callback?: () => any): void;
+ // tslint:enable:unified-signatures
+
+ forceUpdate(callBack?: () => any): void;
+ render(): JSX.Element | null | false;
+
+ // React.Props is now deprecated, which means that the `children`
+ // property is not available on `P` by default, even though you can
+ // always pass children as variadic arguments to `createElement`.
+ // In the future, if we can define its call signature conditionally
+ // on the existence of `children` in `P`, then we should remove this.
+ props: Readonly<{ children?: ReactNode }> & Readonly
{
+ 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) &
+ (new (props?: P, context?: any) => { props: P });
+
+ //
+ // Component Specs and Lifecycle
+ // ----------------------------------------------------------------------
+
+ interface ComponentLifecycle