Skip to content

Commit

Permalink
fix: typescript <v5.1での型エラーを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
Qs-F committed Nov 7, 2024
1 parent cc36346 commit d94d718
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/smarthr-ui/src/libs/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {
type FC,
type PropsWithoutRef,
type ReactNode,
type Ref,
type RefAttributes,
forwardRef,
Expand All @@ -11,8 +11,10 @@ export const includeDisabledTrigger = (trigger: React.ReactNode) =>
(bool: boolean) => bool,
)

type Element = ReturnType<FC>

/** forwardRef でジェネリクスを使うためのラッパー
* via https://www.totaltypescript.com/forwardref-with-generic-components */
export const genericsForwardRef = <T, P = object>(
render: (props: PropsWithoutRef<P>, ref: Ref<T>) => ReactNode,
): ((props: P & RefAttributes<T>) => ReactNode) => forwardRef(render) as any
render: (props: PropsWithoutRef<P>, ref: Ref<T>) => Element,
): ((props: P & RefAttributes<T>) => Element) => forwardRef(render) as any

0 comments on commit d94d718

Please sign in to comment.