mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-05 16:10:11 +08:00
[React.14] Add ReactInstance type (Component<any, any> | Element)
This commit is contained in:
Vendored
+19
-18
@@ -94,6 +94,8 @@ declare namespace __React {
|
||||
export var wheel: EventSimulator;
|
||||
}
|
||||
|
||||
export function renderIntoDocument(
|
||||
element: DOMElement<any>): Element;
|
||||
export function renderIntoDocument<P>(
|
||||
element: ReactElement<P>): Component<P, any>;
|
||||
export function renderIntoDocument<C extends Component<any, any>>(
|
||||
@@ -104,43 +106,42 @@ declare namespace __React {
|
||||
|
||||
export function isElementOfType(
|
||||
element: ReactElement<any>, type: ReactType): boolean;
|
||||
export function isTextComponent(instance: Component<any, any>): boolean;
|
||||
export function isDOMComponent(instance: Component<any, any>): boolean;
|
||||
export function isCompositeComponent(instance: Component<any, any>): boolean;
|
||||
export function isDOMComponent(instance: ReactInstance): boolean;
|
||||
export function isCompositeComponent(instance: ReactInstance): boolean;
|
||||
export function isCompositeComponentWithType(
|
||||
instance: Component<any, any>,
|
||||
instance: ReactInstance,
|
||||
type: ComponentClass<any>): boolean;
|
||||
|
||||
export function findAllInRenderedTree(
|
||||
tree: Component<any, any>,
|
||||
fn: (i: Component<any, any>) => boolean): Component<any, any>;
|
||||
root: Component<any, any>,
|
||||
fn: (i: ReactInstance) => boolean): ReactInstance[];
|
||||
|
||||
export function scryRenderedDOMComponentsWithClass(
|
||||
tree: Component<any, any>,
|
||||
className: string): DOMComponent<any>[];
|
||||
root: Component<any, any>,
|
||||
className: string): Element[];
|
||||
export function findRenderedDOMComponentWithClass(
|
||||
tree: Component<any, any>,
|
||||
className: string): DOMComponent<any>;
|
||||
root: Component<any, any>,
|
||||
className: string): Element;
|
||||
|
||||
export function scryRenderedDOMComponentsWithTag(
|
||||
tree: Component<any, any>,
|
||||
tagName: string): DOMComponent<any>[];
|
||||
root: Component<any, any>,
|
||||
tagName: string): Element[];
|
||||
export function findRenderedDOMComponentWithTag(
|
||||
tree: Component<any, any>,
|
||||
tagName: string): DOMComponent<any>;
|
||||
root: Component<any, any>,
|
||||
tagName: string): Element;
|
||||
|
||||
export function scryRenderedComponentsWithType<P>(
|
||||
tree: Component<any, any>,
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>[];
|
||||
export function scryRenderedComponentsWithType<C extends Component<any, any>>(
|
||||
tree: Component<any, any>,
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<any>): C[];
|
||||
|
||||
export function findRenderedComponentWithType<P>(
|
||||
tree: Component<any, any>,
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>;
|
||||
export function findRenderedComponentWithType<C extends Component<any, any>>(
|
||||
tree: Component<any, any>,
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<any>): C;
|
||||
|
||||
export function createRenderer(): ShallowRenderer;
|
||||
|
||||
Vendored
+2
-6
@@ -8,10 +8,8 @@
|
||||
declare namespace __React {
|
||||
|
||||
namespace __DOM {
|
||||
function findDOMNode<TElement extends Element>(
|
||||
componentOrElement: __React.Component<any, any> | Element): TElement;
|
||||
function findDOMNode(
|
||||
componentOrElement: __React.Component<any, any> | Element): Element;
|
||||
function findDOMNode<E extends Element>(instance: ReactInstance): E;
|
||||
function findDOMNode(instance: ReactInstance): Element;
|
||||
|
||||
function render<P>(
|
||||
element: DOMElement<P>,
|
||||
@@ -49,8 +47,6 @@ declare namespace __React {
|
||||
nextElement: ReactElement<P>,
|
||||
container: Element,
|
||||
callback?: (component: Component<P, S>) => any): Component<P, S>;
|
||||
|
||||
|
||||
}
|
||||
|
||||
namespace __DOMServer {
|
||||
|
||||
Vendored
+3
-8
@@ -112,6 +112,8 @@ declare namespace __React {
|
||||
// Component API
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type ReactInstance = Component<any, any> | Element;
|
||||
|
||||
// Base component for plain JS classes
|
||||
class Component<P, S> implements ComponentLifecycle<P, S> {
|
||||
static propTypes: ValidationMap<any>;
|
||||
@@ -128,7 +130,7 @@ declare namespace __React {
|
||||
state: S;
|
||||
context: {};
|
||||
refs: {
|
||||
[key: string]: Component<any, any> | Element
|
||||
[key: string]: ReactInstance
|
||||
};
|
||||
}
|
||||
|
||||
@@ -138,13 +140,6 @@ declare namespace __React {
|
||||
getInitialState?(): S;
|
||||
}
|
||||
|
||||
interface DOMComponent<P> extends ClassicComponent<P, any> {
|
||||
tagName: string;
|
||||
}
|
||||
|
||||
type HTMLComponent = DOMComponent<HTMLProps>;
|
||||
type SVGComponent = DOMComponent<SVGProps>;
|
||||
|
||||
interface ChildContextProvider<CC> {
|
||||
getChildContext(): CC;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user