-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(merge-styles): introduce DeepPartialV2
type to avoid infinite type instantiation and make unions declaration more performant
#31703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Hotell
merged 6 commits into
microsoft:master
from
Hotell:fix/v8/improve-infinite-type-issues
Jun 14, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3e3f54e
fix(merge-styles): improve DeepPartial type infinite recursion trigge…
Hotell 7dda160
fix(merge-styles): simplify union types and mitigate recursive type r…
Hotell 9a73119
change file
Hotell a30d326
fix(merge-styles): additional typings tweaks
Hotell 24c99ed
fixup! fix(merge-styles): improve DeepPartial type infinite recursion…
Hotell eaaac0c
fix: more tweeaks after customer validation
Hotell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.