-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[code-infra] Add documentation to internal types
- Loading branch information
Showing
5 changed files
with
47 additions
and
17 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,15 @@ | ||
/** | ||
* Combines a type with required and additional properties. | ||
* | ||
* @template P - The original type. | ||
* @template RequiredProps - The keys to make required. | ||
* @template AdditionalProps - Additional properties to include. | ||
*/ | ||
|
||
export type DefaultizedProps< | ||
P extends {}, | ||
RequiredProps extends keyof P, | ||
AdditionalProps extends {} = {}, | ||
> = Omit<P, RequiredProps | keyof AdditionalProps> & | ||
Required<Pick<P, RequiredProps>> & | ||
AdditionalProps; |
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,7 @@ | ||
/** | ||
* Makes specified keys in a type optional. | ||
* | ||
* @template T - The original type. | ||
* @template K - The keys to make optional. | ||
*/ | ||
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; |
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,8 @@ | ||
/** | ||
* Makes specified keys in a type required. | ||
* | ||
* @template T - The original type. | ||
* @template K - The keys to make required. | ||
*/ | ||
|
||
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>; |
13 changes: 13 additions & 0 deletions
13
packages/x-internals/src/types/SlotComponentPropsFromProps.ts
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,13 @@ | ||
/** | ||
* Defines the props for a slot component, which can be either partial props with overrides or a function returning such props. | ||
* | ||
* @template TProps - The original props type. | ||
* @template TOverrides - The overrides type. | ||
* @template TOwnerState - The owner state type. | ||
*/ | ||
|
||
export type SlotComponentPropsFromProps< | ||
TProps extends {}, | ||
TOverrides extends {}, | ||
TOwnerState extends {}, | ||
> = (Partial<TProps> & TOverrides) | ((ownerState: TOwnerState) => Partial<TProps> & TOverrides); |
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 |
---|---|---|
@@ -1,17 +1,4 @@ | ||
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
|
||
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>; | ||
|
||
export type DefaultizedProps< | ||
P extends {}, | ||
RequiredProps extends keyof P, | ||
AdditionalProps extends {} = {}, | ||
> = Omit<P, RequiredProps | keyof AdditionalProps> & | ||
Required<Pick<P, RequiredProps>> & | ||
AdditionalProps; | ||
|
||
export type SlotComponentPropsFromProps< | ||
TProps extends {}, | ||
TOverrides extends {}, | ||
TOwnerState extends {}, | ||
> = (Partial<TProps> & TOverrides) | ((ownerState: TOwnerState) => Partial<TProps> & TOverrides); | ||
export * from './DefaultizedProps'; | ||
export * from './MakeOptional'; | ||
export * from './MakeRequired'; | ||
export * from './SlotComponentPropsFromProps'; |