mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[react] Add propTypes to ForwardRefExoticComponent (#38337)
* Add propTypes to ForwardRefExoticComponent * Add test
This commit is contained in:
parent
40b3584ae5
commit
bdfdaf7fef
1
types/react/index.d.ts
vendored
1
types/react/index.d.ts
vendored
@ -725,6 +725,7 @@ declare namespace React {
|
||||
// but can be given its own specific name
|
||||
interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
|
||||
defaultProps?: Partial<P>;
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
}
|
||||
|
||||
function forwardRef<T, P = {}>(Component: RefForwardingComponent<T, P>): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
||||
|
||||
@ -402,6 +402,9 @@ const ForwardingRefComponent = React.forwardRef((props: {}, ref: React.Ref<RefCo
|
||||
return React.createElement(RefComponent, { ref });
|
||||
});
|
||||
|
||||
const ForwardingRefComponentPropTypes: React.WeakValidationMap<Props> = {};
|
||||
ForwardingRefComponent.propTypes = ForwardingRefComponentPropTypes;
|
||||
|
||||
function RefCarryingComponent() {
|
||||
const ref: React.RefObject<RefComponent> = React.createRef();
|
||||
// Without the explicit type argument, TypeScript infers `{ref: React.RefObject<RefComponent>}`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user