@mirohq/design-system-types
Advanced tools
Comparing version 0.9.0 to 0.10.0
# @mirohq-internal/design-system-types | ||
## 0.10.0 | ||
### Minor Changes | ||
- [#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: | ||
_OneOrMore_: creates a type that can be a single value or an array of that value. | ||
```ts | ||
type Result = OneOrMore<number> | ||
// number | number[] | ||
``` | ||
_MergeUnion_: merges two types by combining their properties. Overlapping properties result in a union of their values. | ||
```ts | ||
type TypeA = { foo: number; bar: string } | ||
type TypeB = { bar: boolean; baz: number } | ||
type Result = MergeUnion<TypeA, TypeB> | ||
// { foo: number, bar: string | boolean, baz: number } | ||
``` | ||
## 0.9.0 | ||
@@ -4,0 +27,0 @@ |
{ | ||
"name": "@mirohq/design-system-types", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Miro", |
@@ -0,5 +1,28 @@ | ||
/** | ||
* Convert a type into a union of the value itself with null and undefined. | ||
* | ||
* @example | ||
* type Text = string | ||
* type Result = Nullable<Text> | ||
* | ||
* result: string | null | undefined | ||
*/ | ||
export type Nullable<T> = T | null | undefined | ||
/** | ||
* A type that can be a number or a string representation of a number. | ||
* | ||
* @example | ||
* type Num<X extends Numeric> = X | ||
* type Result = Num<1 | '1'> | ||
*/ | ||
export type Numeric = number | `${number}` | ||
/** | ||
* A type that can be a boolean or a string representation of a boolean. | ||
* | ||
* @example | ||
* type Bool<X extends Booleanish> = X | ||
* type Result = Bool<true | 'true'> | ||
*/ | ||
export type Booleanish = boolean | `${boolean}` | ||
@@ -55,9 +78,23 @@ | ||
export interface TypeA { | ||
foo: number | ||
bar: string | ||
} | ||
export interface TypeB { | ||
foo: boolean | ||
qux: number | ||
} | ||
/** | ||
* Convert a type into a union of the value itself and an array of the value. | ||
* | ||
* @example | ||
* type Result = OneOrMore<number> | ||
* number | number[] | ||
*/ | ||
type OneOrMore<T> = T | T[] | ||
/** | ||
* Converts a union type into an intersection type. | ||
* | ||
* @example | ||
* type Union = { foo: number } | { bar: string } | ||
* type Result = UnionToIntersection<Union> | ||
* { foo: number } & { bar: string } | ||
*/ | ||
type UnionToIntersection<U> = (U extends any ? (x: U) => any : never) extends ( | ||
x: infer I | ||
) => any | ||
? I | ||
: never |
9237
125