@mirohq/design-system-types 0.7.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,57 @@
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
+
18
+ ## 0.8.0
19
+
20
+ ### Minor Changes
21
+
22
+ - [#606](https://github.com/miroapp-dev/design-system/pull/606) [`1053d1fc`](https://github.com/miroapp-dev/design-system/commit/1053d1fc7d972cbf43e869b220af1c56719a77c7) Thanks [@ivanbanov](https://github.com/ivanbanov)! - Added new type OmitFromUnion.
23
+
24
+ Example
25
+
26
+ ```ts
27
+ type Union = { foo: true; x: 1 } | { bar: false; x: 2 }
28
+ type Result = OmitFromUnion<Union, 'x'>
29
+ // { foo: true } | { bar: false }
30
+ ```
31
+
32
+ ### Patch Changes
33
+
34
+ - [#606](https://github.com/miroapp-dev/design-system/pull/606) [`1053d1fc`](https://github.com/miroapp-dev/design-system/commit/1053d1fc7d972cbf43e869b220af1c56719a77c7) Thanks [@ivanbanov](https://github.com/ivanbanov)! - Fixed styled component types to handle extended components returning union types.
35
+
36
+ ```tsx
37
+ const UnionComponent = (
38
+ props:
39
+ | { id: string; hidden?: never }
40
+ | { hidden: boolean; name: string }
41
+ ): JSX.Element => <div {...props} />
42
+
43
+ const StyledComponent = styled(UnionComponent)
44
+
45
+ // Before
46
+ // fail hidden and name were stripped out
47
+ <StyledComponent hidden name='foo' />
48
+
49
+ // Now
50
+ // the component will properly infer the right type
51
+ <StyledComponent id='foo' />
52
+ <StyledComponent hidden name='foo' />
53
+ ```
54
+
3
55
  ## 0.7.0
4
56
 
5
57
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirohq/design-system-types",
3
- "version": "0.7.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
@@ -6,7 +6,57 @@ export type Booleanish = boolean | `${boolean}`
6
6
 
7
7
  /**
8
8
  * Extracts valid key properties from object.
9
+ *
10
+ * @example
11
+ * Extract valid keys from an object
12
+ *
13
+ * type Obj = 1 | 'foo' | { bar: true } | true
14
+ * type Result = ExtractValidKeys<Obj>
15
+ * 1 | 'foo' | true
9
16
  */
10
17
  export type ExtractValidKeys<T> = T extends string | number | boolean | symbol
11
18
  ? T
12
19
  : never
20
+
21
+ /**
22
+ * Removes specified keys from a union type.
23
+ *
24
+ * @example
25
+ * Remove 'x' key from the union type
26
+ *
27
+ * type Union = { foo: true, x: 1 } | { bar: false, x: 2 }
28
+ * type Result = OmitFromUnion<Union, 'x'>
29
+ * { foo: true } | { bar: false }
30
+ */
31
+ export type OmitFromUnion<T, K extends keyof any> = T extends any
32
+ ? Omit<T, K>
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
+ }
package/src/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from './scales'
2
1
  export * from './global'
3
2
  export * from './react'