Skip to content

Commit e96b0be

Browse files
committed
fix: add explicit return types
The return type of `NumericFormat` and `PatternFormat` was being inferred as `JSX.Element` which caused the following type error (typescript v5.7.3): ``` error TS2786: 'PatternFormat' cannot be used as a JSX component. Its type '<BaseType = InputAttributes>(props: PatternFormatProps<BaseType>) => Element' is not a valid JSX element type. Type '<BaseType = InputAttributes>(props: PatternFormatProps<BaseType>) => Element' is not assignable to type '(props: any) => ReactNode | Promise<ReactNode>'. Type 'Element' is not assignable to type 'ReactNode | Promise<ReactNode>'. Property 'children' is missing in type 'Element' but required in type 'ReactPortal'. ``` Instead of being inferred, explicitly add the return type of `React.ReactElement` which represents a JSX element.
1 parent 8de2517 commit e96b0be

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/numeric_format.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ export function useNumericFormat<BaseType = InputAttributes>(
566566

567567
export default function NumericFormat<BaseType = InputAttributes>(
568568
props: NumericFormatProps<BaseType>,
569-
) {
569+
): React.ReactElement {
570570
const numericFormatProps = useNumericFormat(props);
571571

572572
return <NumberFormatBase {...numericFormatProps} />;

src/pattern_format.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export function usePatternFormat<BaseType = InputAttributes>(
265265

266266
export default function PatternFormat<BaseType = InputAttributes>(
267267
props: PatternFormatProps<BaseType>,
268-
) {
268+
): React.ReactElement {
269269
const patternFormatProps = usePatternFormat(props);
270270

271271
return <NumberFormatBase {...patternFormatProps} />;

0 commit comments

Comments
 (0)