-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 토글 컴포넌트 forwardRef, generic 관련 타입 추론 안 되는 문제 해결
- Loading branch information
1 parent
fe8c161
commit 09aa783
Showing
2 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { | ||
ComponentPropsWithoutRef, | ||
ComponentPropsWithRef, | ||
ElementType, | ||
} from "react"; | ||
|
||
export interface AsProps<T extends ElementType> { | ||
as?: T; | ||
} | ||
|
||
export type PolymorphicRef<T extends ElementType> = | ||
ComponentPropsWithRef<T>["ref"]; | ||
|
||
export type PolymorphicComponentProps< | ||
T extends ElementType, | ||
Props = {}, | ||
> = AsProps<T> & | ||
ComponentPropsWithoutRef<T> & | ||
Props & { | ||
ref?: PolymorphicRef<T>; | ||
}; |