mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-31 11:40:47 +08:00
[react] better return-type inference for (scry|find)RenderedComponent(s?)WithType
This commit is contained in:
Vendored
+4
-10
@@ -130,19 +130,13 @@ declare namespace __React {
|
||||
root: Component<any, any>,
|
||||
tagName: string): Element;
|
||||
|
||||
export function scryRenderedComponentsWithType<P>(
|
||||
export function scryRenderedComponentsWithType<T extends Component<{}, {}>>(
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>[];
|
||||
export function scryRenderedComponentsWithType<C extends Component<any, any>>(
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<any>): C[];
|
||||
type: { new(): T }): T[];
|
||||
|
||||
export function findRenderedComponentWithType<P>(
|
||||
export function findRenderedComponentWithType<T extends Component<{}, {}>>(
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>;
|
||||
export function findRenderedComponentWithType<C extends Component<any, any>>(
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<any>): C;
|
||||
type: { new(): T }): T;
|
||||
|
||||
export function createRenderer(): ShallowRenderer;
|
||||
}
|
||||
|
||||
@@ -541,6 +541,11 @@ renderer.render(React.createElement(Timer));
|
||||
var output: React.ReactElement<React.Props<Timer>> =
|
||||
renderer.getRenderOutput();
|
||||
|
||||
var foundComponent: ModernComponent = TestUtils.findRenderedComponentWithType(
|
||||
inst, ModernComponent);
|
||||
var foundComponents: ModernComponent[] = TestUtils.scryRenderedComponentsWithType(
|
||||
inst, ModernComponent);
|
||||
|
||||
//
|
||||
// TransitionGroup addon
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user