This PR updates the SomeReactComponent type to include all of the things that are accepted in a React.FunctionComponent (or React.FC) type.
Before
Currently, if someone were to use the withParamValidation or withLayoutParamValidation HOC on a React component manually annotated with React.FC, such as:
import type React from "react";
import { withParamValidation, type InferPagePropsType } from "next-typesafe-url";
import { route } from "./routeType";
const SomePage: React.FC<InferPagePropsType<typeof route>> = () => null;
export default withParamValidation(SomePage, route);
TypeScript will throw an error.
Argument of type 'FunctionComponent<InferPagePropsType<{ ... }>> & { ...; }' is not assignable to parameter of type 'SomeReactComponent'.
Type 'ReactNode' is not assignable to type 'Element | Promise<Element>'.
Type 'undefined' is not assignable to type 'Element | Promise<Element>'.ts(2345)
After
TypeScript will no longer show the previous error.
Description
This PR updates the
SomeReactComponent
type to include all of the things that are accepted in aReact.FunctionComponent
(orReact.FC
) type.Before
Currently, if someone were to use the
withParamValidation
orwithLayoutParamValidation
HOC on a React component manually annotated withReact.FC
, such as:TypeScript will throw an error.
After
TypeScript will no longer show the previous error.