@mirohq/design-system-types 0.7.0 → 0.8.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 +37 -0
- package/package.json +1 -1
- package/src/global.d.ts +21 -0
- package/src/index.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @mirohq-internal/design-system-types
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
9
|
+
Example
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
type Union = { foo: true; x: 1 } | { bar: false; x: 2 }
|
|
13
|
+
type Result = OmitFromUnion<Union, 'x'>
|
|
14
|
+
// { foo: true } | { bar: false }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#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.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
const UnionComponent = (
|
|
23
|
+
props:
|
|
24
|
+
| { id: string; hidden?: never }
|
|
25
|
+
| { hidden: boolean; name: string }
|
|
26
|
+
): JSX.Element => <div {...props} />
|
|
27
|
+
|
|
28
|
+
const StyledComponent = styled(UnionComponent)
|
|
29
|
+
|
|
30
|
+
// Before
|
|
31
|
+
// fail hidden and name were stripped out
|
|
32
|
+
<StyledComponent hidden name='foo' />
|
|
33
|
+
|
|
34
|
+
// Now
|
|
35
|
+
// the component will properly infer the right type
|
|
36
|
+
<StyledComponent id='foo' />
|
|
37
|
+
<StyledComponent hidden name='foo' />
|
|
38
|
+
```
|
|
39
|
+
|
|
3
40
|
## 0.7.0
|
|
4
41
|
|
|
5
42
|
### Minor Changes
|
package/package.json
CHANGED
package/src/global.d.ts
CHANGED
|
@@ -6,7 +6,28 @@ 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
|
package/src/index.d.ts
CHANGED