Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/react/v16/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ declare namespace React {
propTypes?: WeakValidationMap<P>;
}

function forwardRef<T, P = {}>(render: ForwardRefRenderFunction<T, P>): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
function forwardRef<T, P = {}>(render: ForwardRefRenderFunction<T, P>): ForwardRefExoticComponent<PropsWithoutRef<PropsWithChildren<P>> & RefAttributes<T>>;

/** Ensures that the props do not include ref at all */
type PropsWithoutRef<P> =
Expand Down
5 changes: 5 additions & 0 deletions types/react/v16/test/tsx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ const ForwardRef3 = React.forwardRef(
<ForwardRef3 ref={divFnRef}/>;
<ForwardRef3 ref={divRef}/>;

const ForwardRefWithChildren = React.forwardRef((props: React.PropsWithChildren<{}>, ref?: React.Ref<HTMLDivElement>) => <div ref={ref}>{props.children}</div>);
const ForwardRefWithChildren1 = React.forwardRef<{}, HTMLDivElement>((props, ref) => <div ref={ref}>{props.children}</div>);
<ForwardRefWithChildren>test</ForwardRefWithChildren>;
<ForwardRefWithChildren1>test</ForwardRefWithChildren1>;

const { Profiler } = React;

// 'id' is missing
Expand Down