@cloudflare/types
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -6,2 +6,10 @@ # Change Log | ||
## [1.1.3](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/types@1.1.2...@cloudflare/types@1.1.3) (2019-08-09) | ||
**Note:** Version bump only for package @cloudflare/types | ||
## [1.1.2](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/types@1.1.1...@cloudflare/types@1.1.2) (2019-08-06) | ||
@@ -8,0 +16,0 @@ |
{ | ||
"name": "@cloudflare/types", | ||
"description": "", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"types": "./src", | ||
@@ -28,3 +28,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "d50ce114c86a49e113f2c5c6094a0311b60603f4" | ||
"gitHead": "4415756814aae8cd065228fae6ea4e44fb5f4f34" | ||
} |
@@ -62,1 +62,67 @@ import * as React from 'react'; | ||
T2; | ||
/** | ||
* Converts union to intersection. | ||
* | ||
* @example | ||
* type A = "hello" | 5 | ||
* type IntersectionA = UnionToIntersection<A> = "hello" & 5 | ||
*/ | ||
export type UnionToIntersection<U> = (U extends any | ||
? (k: U) => void | ||
: never) extends ((k: infer I) => void) | ||
? I | ||
: never; | ||
/** | ||
* Doing keyof UnionOfObjects in TypeScript will give you intersection of keys. For example: | ||
* type UnionOfObjects = {a: string, b: number} | {a: string} | ||
* type Keys = keyof UnionOfObjects // "a"[] | ||
* | ||
* Sometimes, you might want all possible keys, in other words, you want union of keys. You can use this type for it. | ||
* | ||
* @example | ||
* type UnionOfObjects = {a: string, b: number } | {a: string} | ||
* type AllKeys = KeyOfUnion<UnionOfObjects> // "a" | "b" | ||
*/ | ||
export type KeyOfUnion<Union> = keyof UnionToIntersection<Union>; | ||
/** | ||
* Converts readonly array to non-readonly array. | ||
* | ||
* @example | ||
* const ReadonlyArray = [5, 4] as const; | ||
* | ||
* type NonReadonlyArray = NonReadonly<typeof ReadonlyArray> | ||
*/ | ||
export type NonReadonly<T extends ReadonlyArray<any>> = T extends ReadonlyArray< | ||
infer X | ||
> | ||
? X[] | ||
: never; | ||
/** | ||
* 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 | ||
*/ | ||
export type Diff<T, U> = T extends U ? never : T; | ||
/** | ||
* Remove types from T that are not assignable to U | ||
*/ | ||
export type Filter<T, U> = T extends U ? T : never; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44531
1368