@mirohq/design-system-types 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @mirohq-internal/design-system-types
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#611](https://github.com/miroapp-dev/design-system/pull/611) [`7ff8d5da`](https://github.com/miroapp-dev/design-system/commit/7ff8d5da5df65eeb28d1b6b3b0e6c12bacee97e1) Thanks [@ivanbanov](https://github.com/ivanbanov)! - Added new type MergeUnion.
8
+
9
+ Example
10
+
11
+ ```ts
12
+ type TypeA = { foo: number; bar: string }
13
+ type TypeB = { bar: boolean; baz: number }
14
+ type Result = MergeUnion<TypeA, TypeB>
15
+ // { foo: number, bar: string | boolean, baz: number }
16
+ ```
17
+
3
18
  ## 0.8.0
4
19
 
5
20
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirohq/design-system-types",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "author": "Miro",
6
6
  "types": "src/index.d.ts",
package/src/global.d.ts CHANGED
@@ -31,3 +31,32 @@ export type ExtractValidKeys<T> = T extends string | number | boolean | symbol
31
31
  export type OmitFromUnion<T, K extends keyof any> = T extends any
32
32
  ? Omit<T, K>
33
33
  : never
34
+
35
+ /**
36
+ * Merges two types into a new type by combining their properties.
37
+ * If a property exists in both types, the resulting type will have the union of their values.
38
+ * If a property exists in only one type, the resulting type will have the value of that property.
39
+ * If a property exists in both types but has different types, the resulting type will have the union of their types.
40
+ * Any properties that exist in the second type but not in the first type will be included in the resulting type.
41
+ *
42
+ * @example
43
+ * Merge two types
44
+ *
45
+ * type TypeA = { foo: number, bar: string }
46
+ * type TypeB = { bar: boolean, baz: number }
47
+ *
48
+ * type Result = MergeUnion<TypeA, TypeB>
49
+ * { foo: number, bar: string | boolean, baz: number }
50
+ */
51
+ export type MergeUnion<T, U> = {
52
+ [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]
53
+ } & OmitFromUnion<U, keyof T>
54
+
55
+ export interface TypeA {
56
+ foo: number
57
+ bar: string
58
+ }
59
+ export interface TypeB {
60
+ foo: boolean
61
+ qux: number
62
+ }