mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Add helper PropsWithChildren
This commit is contained in:
Vendored
+5
-3
@@ -468,7 +468,7 @@ declare namespace React {
|
||||
type FC<P = {}> = FunctionComponent<P>;
|
||||
|
||||
interface FunctionComponent<P = {}> {
|
||||
(props: P & { children?: ReactNode }, context?: any): ReactElement | null;
|
||||
(props: PropsWithChildren<P>, context?: any): ReactElement | null;
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
contextTypes?: ValidationMap<any>;
|
||||
defaultProps?: Partial<P>;
|
||||
@@ -476,7 +476,7 @@ declare namespace React {
|
||||
}
|
||||
|
||||
interface RefForwardingComponent<T, P = {}> {
|
||||
(props: P & { children?: ReactNode }, ref: Ref<T>): ReactElement | null;
|
||||
(props: PropsWithChildren<P>, ref: Ref<T>): ReactElement | null;
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
contextTypes?: ValidationMap<any>;
|
||||
defaultProps?: Partial<P>;
|
||||
@@ -722,6 +722,8 @@ declare namespace React {
|
||||
: P
|
||||
: P;
|
||||
|
||||
type PropsWithChildren<P> = P & { children?: ReactNode };
|
||||
|
||||
/**
|
||||
* NOTE: prefer ComponentPropsWithRef, if the ref is forwarded,
|
||||
* or ComponentPropsWithoutRef when refs are not supported.
|
||||
@@ -747,7 +749,7 @@ declare namespace React {
|
||||
|
||||
function memo<P extends object>(
|
||||
Component: SFC<P>,
|
||||
propsAreEqual?: (prevProps: Readonly<P & { children?: ReactNode }>, nextProps: Readonly<P & { children?: ReactNode }>) => boolean
|
||||
propsAreEqual?: (prevProps: Readonly<PropsWithChildren<P>>, nextProps: Readonly<PropsWithChildren<P>>) => boolean
|
||||
): NamedExoticComponent<P>;
|
||||
function memo<T extends ComponentType<any>>(
|
||||
Component: T,
|
||||
|
||||
@@ -13,6 +13,7 @@ import TransitionGroup = require("react-addons-transition-group");
|
||||
import update = require("react-addons-update");
|
||||
import createReactClass = require("create-react-class");
|
||||
import * as DOM from "react-dom-factories";
|
||||
import { PropsWithChildren } from '../index';
|
||||
|
||||
// NOTE: forward declarations for tests
|
||||
declare function setInterval(...args: any[]): any;
|
||||
@@ -803,3 +804,9 @@ const sfc: React.SFC<any> = Memoized2;
|
||||
// this $ExpectError is failing on TypeScript@next
|
||||
// // $ExpectError Property '$$typeof' is missing in type
|
||||
// const specialSfc2: React.SpecialSFC = props => null;
|
||||
|
||||
const propsWithChildren: PropsWithChildren<Props> = {
|
||||
hello: "world",
|
||||
foo: 42,
|
||||
children: functionComponent,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user