@shopify/useful-types
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -36,3 +36,8 @@ export declare type ArrayElement<T> = T extends (infer U)[] ? U : never; | ||
export declare type RequireSome<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>; | ||
declare type IsAny<T> = 0 extends 1 & T ? true : false; | ||
declare type IsUnknown<T> = IsAny<T> extends true ? false : unknown extends T ? true : false; | ||
export declare type DeepReadonly<T> = T extends Primitive ? T : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends WeakMap<infer K, infer V> ? WeakMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends WeakSet<infer U> ? WeakSet<DeepReadonly<U>> : T extends Promise<infer U> ? Promise<DeepReadonly<U>> : T extends {} ? { | ||
readonly [K in keyof T]: DeepReadonly<T[K]>; | ||
} : IsUnknown<T> extends true ? unknown : Readonly<T>; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@shopify/useful-types", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"license": "MIT", | ||
@@ -42,4 +42,3 @@ "description": "A few handy TypeScript types", | ||
} | ||
}, | ||
"gitHead": "ef9afc562672dcda9d7800753dc6b777ecd2d751" | ||
} | ||
} |
@@ -88,3 +88,3 @@ # `@shopify/useful-types` | ||
- `DeepPartial<T>`: Recusively maps over all properties in a type and transforms them to be optional. Useful when you need to make optional all of the properties (and nested properties) of an existing type. | ||
- `DeepPartial<T>`: Recursively maps over all properties in a type and transforms them to be optional. Useful when you need to make optional all of the properties (and nested properties) of an existing type. | ||
@@ -158,1 +158,14 @@ ```ts | ||
``` | ||
- `DeepReadonly<T>`: Recursively maps over all properties in a type and transforms them to be read-only. | ||
```ts | ||
interface Obj { | ||
foo: string; | ||
bar: { | ||
baz: boolean; | ||
}; | ||
} | ||
type DeepReadonlyObj = DeepReadonly<Obj>; // {readonly foo: string; readonly bar: { readonly baz: boolean }} | ||
``` |
Sorry, the diff of this file is not supported yet
14012
50
170
12