From e040a8c7175dae3a369cc2aa244172b7617e047c Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Fri, 28 Jun 2024 12:15:59 +0200 Subject: [PATCH 1/2] fix(merge-styles): keep same type output for DeepPartialV2 to match original DeepPartial --- packages/merge-styles/src/DeepPartial.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/merge-styles/src/DeepPartial.ts b/packages/merge-styles/src/DeepPartial.ts index ca351bd5feb54..cfca387a79bee 100644 --- a/packages/merge-styles/src/DeepPartial.ts +++ b/packages/merge-styles/src/DeepPartial.ts @@ -1,3 +1,5 @@ +/* eslint-disable @fluentui/max-len */ + /** * 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} @@ -13,8 +15,14 @@ type DeepPartialObject = { [Key in keyof T]?: DeepPartialV2; }; +/** + * Why `T extends Function ? {}` : + * While this transform is incorrect, in order not run into infinite type instantiation to maintain type creation compatibility with original {@link DeepPartial} we need to hit `[P in keyof T]? T[P]` part of the mapped type from original, + * which would transform to bottom type `{}` if `Function` would be `T` + * + */ export type DeepPartialV2 = T extends Function - ? T + ? {} : T extends Array ? IDeepPartialArray : T extends object From 7b492b716be54b68d52e728182388170db72a883 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Fri, 28 Jun 2024 12:16:42 +0200 Subject: [PATCH 2/2] change file --- ...-merge-styles-917f7ae8-0a61-47db-83f7-e29e8264ac4e.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@fluentui-merge-styles-917f7ae8-0a61-47db-83f7-e29e8264ac4e.json diff --git a/change/@fluentui-merge-styles-917f7ae8-0a61-47db-83f7-e29e8264ac4e.json b/change/@fluentui-merge-styles-917f7ae8-0a61-47db-83f7-e29e8264ac4e.json new file mode 100644 index 0000000000000..a8cdf823eb0b4 --- /dev/null +++ b/change/@fluentui-merge-styles-917f7ae8-0a61-47db-83f7-e29e8264ac4e.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: keep same type output for DeepPartialV2 to match original DeepPartial", + "packageName": "@fluentui/merge-styles", + "email": "martinhochel@microsoft.com", + "dependentChangeType": "patch" +}