-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(merge-styles): introduce
DeepPartialV2
type to avoid infinite t…
…ype instantiation and make unions declaration more performant (#31703)
- Loading branch information
Showing
14 changed files
with
162 additions
and
148 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-merge-styles-3328f941-f74b-4a07-8fc0-aca13cacd01f.json
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 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "fix(merge-styles): improve DeepPartial type infinite recursion triggerpoint", | ||
"packageName": "@fluentui/merge-styles", | ||
"email": "martinhochel@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
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 |
---|---|---|
@@ -1,6 +1,22 @@ | ||
/** | ||
* TypeScript type to return a deep partial object (each property can be undefined, recursively.) | ||
* @deprecated - This type will hit infinite type instantiation recursion. Please use {@link DeepPartialV2} | ||
*/ | ||
export type DeepPartial<T> = { | ||
[P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends object ? DeepPartial<T[P]> : T[P]; | ||
// eslint-disable-next-line deprecation/deprecation | ||
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends object ? DeepPartial<T[P]> : T[P]; | ||
}; | ||
|
||
interface IDeepPartialArray<T> extends Array<DeepPartialV2<T>> {} | ||
|
||
type DeepPartialObject<T> = { | ||
[Key in keyof T]?: DeepPartialV2<T[Key]>; | ||
}; | ||
|
||
export type DeepPartialV2<T> = T extends Function | ||
? T | ||
: T extends Array<infer U> | ||
? IDeepPartialArray<U> | ||
: T extends object | ||
? DeepPartialObject<T> | ||
: T; |
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
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
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
Oops, something went wrong.