-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react): 新增 ExtendComponentProps
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react' | ||
import { Merge } from '../types' | ||
|
||
/** | ||
* 继承组件属性。 | ||
* | ||
* @template TComponent 组件 | ||
* @template TExclude 需去除的属性 | ||
* @template TRef 新的 ref | ||
* @template TOverride 覆盖属性 | ||
*/ | ||
export type ExtendComponentProps< | ||
TComponent extends | ||
| React.ComponentType | ||
| keyof JSX.IntrinsicElements | ||
| React.JSXElementConstructor<any>, | ||
TExclude extends keyof React.ComponentProps<TComponent>, | ||
TRef extends any = never, | ||
TOverride extends Partial<React.ComponentProps<TComponent>> = never | ||
> = Merge< | ||
Merge< | ||
Omit<React.ComponentProps<TComponent>, TExclude>, | ||
[TOverride] extends [never] ? {} : TOverride | ||
>, | ||
[TRef] extends [never] ? {} : React.RefAttributes<TRef> | ||
> |
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