@cloudflare/types
Advanced tools
Comparing version 1.1.13 to 1.2.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [1.2.0](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/types@1.1.13...@cloudflare/types@1.2.0) (2019-09-09) | ||
### Features | ||
* **types:** RUM-105 Add ValueOfReadonlyArray type helper ([cce1d2a](http://stash.cfops.it:7999/fe/stratus/commits/cce1d2a)) | ||
* **types:** RUM-105 Update ValueOfArray type to support ReadonlyArray ([b4eafcb](http://stash.cfops.it:7999/fe/stratus/commits/b4eafcb)) | ||
## [1.1.13](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/types@1.1.12...@cloudflare/types@1.1.13) (2019-09-04) | ||
@@ -8,0 +20,0 @@ |
{ | ||
"name": "@cloudflare/types", | ||
"description": "", | ||
"version": "1.1.13", | ||
"version": "1.2.0", | ||
"types": "./src", | ||
@@ -28,3 +28,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "a592e76a5d72babbf44ca1c470da490b4ed05520" | ||
"gitHead": "d26548bcf3db5e8a10c0cb066497ed7dc0c94dc5" | ||
} |
@@ -47,5 +47,15 @@ import * as React from 'react'; | ||
* type Name = ValueOfArray<typeof Names> // string | ||
* | ||
* @example | ||
* // typeof readonlyNames === readonly ["Robert", "Ollie", "John", "Cina", "Millie"] | ||
* const nameTuple = ["Robert", "Ollie", "John", "Cina", "Millie"] as const | ||
* // Name === "Robert" | "Ollie" | "John" | "Cina" | "Millie" | ||
* type Name = ValueOfReadonlyArray<typeof nameTuple> | ||
*/ | ||
export type ValueOfArray<T extends Array<any>> = T extends (infer U)[] | ||
export type ValueOfArray< | ||
T extends Array<any> | ReadonlyArray<any> | ||
> = T extends Array<infer U> | ||
? U | ||
: T extends ReadonlyArray<infer RO> | ||
? RO | ||
: never; | ||
@@ -105,18 +115,2 @@ | ||
/** | ||
* Converts union of readonly arrays to union of their values. | ||
* | ||
* @example | ||
* type UnionedArrays = readonly [5] | readonly [6] | ||
* type Result = ExtractUnionedArrayTypes<UnionedArrays> // "5" | "6" | ||
* | ||
*/ | ||
export type ExtractUnionedArrayTypes<T extends ReadonlyArray<any>> = (( | ||
...t: NonReadonly<T> | ||
) => any) extends ((...i: infer I) => any) | ||
? I extends ReadonlyArray<infer U> | ||
? U | ||
: never | ||
: never; | ||
/** | ||
* Remove types from T that are assignable to U | ||
@@ -123,0 +117,0 @@ */ |
47309
1392