@mirohq/design-system-types 0.9.0 → 0.10.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,28 @@
1
1
  # @mirohq-internal/design-system-types
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#617](https://github.com/miroapp-dev/design-system/pull/617) [`9ea14f4a`](https://github.com/miroapp-dev/design-system/commit/9ea14f4a48ab87d13c0a38e37186fb50ea642b02) Thanks [@ivanbanov](https://github.com/ivanbanov)! - Added two new types:
8
+
9
+ _OneOrMore_: creates a type that can be a single value or an array of that value.
10
+
11
+ ```ts
12
+ type Result = OneOrMore<number>
13
+ // number | number[]
14
+ ```
15
+
16
+ _MergeUnion_: merges two types by combining their properties. Overlapping properties result in a union of their values.
17
+
18
+ ```ts
19
+ type TypeA = { foo: number; bar: string }
20
+ type TypeB = { bar: boolean; baz: number }
21
+
22
+ type Result = MergeUnion<TypeA, TypeB>
23
+ // { foo: number, bar: string | boolean, baz: number }
24
+ ```
25
+
3
26
  ## 0.9.0
4
27
 
5
28
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirohq/design-system-types",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "",
5
5
  "author": "Miro",
6
6
  "types": "src/index.d.ts",
package/src/global.d.ts CHANGED
@@ -1,7 +1,30 @@
1
+ /**
2
+ * Convert a type into a union of the value itself with null and undefined.
3
+ *
4
+ * @example
5
+ * type Text = string
6
+ * type Result = Nullable<Text>
7
+ *
8
+ * result: string | null | undefined
9
+ */
1
10
  export type Nullable<T> = T | null | undefined
2
11
 
12
+ /**
13
+ * A type that can be a number or a string representation of a number.
14
+ *
15
+ * @example
16
+ * type Num<X extends Numeric> = X
17
+ * type Result = Num<1 | '1'>
18
+ */
3
19
  export type Numeric = number | `${number}`
4
20
 
21
+ /**
22
+ * A type that can be a boolean or a string representation of a boolean.
23
+ *
24
+ * @example
25
+ * type Bool<X extends Booleanish> = X
26
+ * type Result = Bool<true | 'true'>
27
+ */
5
28
  export type Booleanish = boolean | `${boolean}`
6
29
 
7
30
  /**
@@ -52,11 +75,25 @@ export type MergeUnion<T, U> = {
52
75
  [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]
53
76
  } & OmitFromUnion<U, keyof T>
54
77
 
55
- export interface TypeA {
56
- foo: number
57
- bar: string
58
- }
59
- export interface TypeB {
60
- foo: boolean
61
- qux: number
62
- }
78
+ /**
79
+ * Convert a type into a union of the value itself and an array of the value.
80
+ *
81
+ * @example
82
+ * type Result = OneOrMore<number>
83
+ * number | number[]
84
+ */
85
+ type OneOrMore<T> = T | T[]
86
+
87
+ /**
88
+ * Converts a union type into an intersection type.
89
+ *
90
+ * @example
91
+ * type Union = { foo: number } | { bar: string }
92
+ * type Result = UnionToIntersection<Union>
93
+ * { foo: number } & { bar: string }
94
+ */
95
+ type UnionToIntersection<U> = (U extends any ? (x: U) => any : never) extends (
96
+ x: infer I
97
+ ) => any
98
+ ? I
99
+ : never