Comparing version 0.1.14 to 0.1.15
@@ -10,7 +10,5 @@ import {IsEqual} from './comparison'; | ||
TValue | ||
> = TObject extends object | ||
? TKey extends keyof TObject | ||
? TObject[TKey] extends TValue | ||
? TKey | ||
: never | ||
> = TKey extends keyof TObject | ||
? TObject[TKey] extends TValue | ||
? TKey | ||
: never | ||
@@ -21,4 +19,9 @@ : never; | ||
TObject extends object, | ||
TValue | ||
> = __KeyOfValueWithType<TObject, keyof TObject, TValue>; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? __KeyOfValueWithType<TObject, keyof TObject, TValue> | ||
: never | ||
: __KeyOfValueWithType<TObject, keyof TObject, TValue>; | ||
@@ -29,8 +32,6 @@ type __KeyOfValueNotWithType< | ||
TValue | ||
> = TObject extends object | ||
? TKey extends keyof TObject | ||
? TObject[TKey] extends TValue | ||
? never | ||
: TKey | ||
: never | ||
> = TKey extends keyof TObject | ||
? TObject[TKey] extends TValue | ||
? never | ||
: TKey | ||
: never; | ||
@@ -40,5 +41,20 @@ | ||
TObject extends object, | ||
TValue | ||
> = __KeyOfValueNotWithType<TObject, keyof TObject, TValue>; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? __KeyOfValueNotWithType<TObject, keyof TObject, TValue> | ||
: never | ||
: __KeyOfValueNotWithType<TObject, keyof TObject, TValue>; | ||
export type KeyOfUnionValueNotWithType< | ||
TObject extends object, | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? __KeyOfValueNotWithType<TObject, keyof TObject, TValue> | ||
: never | ||
: __KeyOfValueNotWithType<TObject, keyof TObject, TValue>; | ||
type __KeyOfValueContainingType< | ||
@@ -48,7 +64,5 @@ TObject extends object, | ||
TValue | ||
> = TObject extends object | ||
? TKey extends keyof TObject | ||
? TValue extends TObject[TKey] | ||
? TKey | ||
: never | ||
> = TKey extends keyof TObject | ||
? TValue extends TObject[TKey] | ||
? TKey | ||
: never | ||
@@ -59,4 +73,9 @@ : never; | ||
TObject extends object, | ||
TValue | ||
> = __KeyOfValueContainingType<TObject, keyof TObject, TValue>; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? __KeyOfValueContainingType<TObject, keyof TObject, TValue> | ||
: never | ||
: __KeyOfValueContainingType<TObject, keyof TObject, TValue>; | ||
@@ -67,8 +86,6 @@ type __KeyOfValueNotContainingType< | ||
TValue | ||
> = TObject extends object | ||
? TKey extends keyof TObject | ||
? TValue extends TObject[TKey] | ||
? never | ||
: TKey | ||
: never | ||
> = TKey extends keyof TObject | ||
? TValue extends TObject[TKey] | ||
? never | ||
: TKey | ||
: never; | ||
@@ -78,4 +95,9 @@ | ||
TObject extends object, | ||
TValue | ||
> = __KeyOfValueNotContainingType<TObject, keyof TObject, TValue>; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? __KeyOfValueNotContainingType<TObject, keyof TObject, TValue> | ||
: never | ||
: __KeyOfValueNotContainingType<TObject, keyof TObject, TValue>; | ||
@@ -88,15 +110,17 @@ // Extract values | ||
TValue | ||
> = TObject extends object | ||
? TKey extends keyof TObject | ||
? TObject[TKey] extends TValue | ||
? TObject[TKey] | ||
: never | ||
> = TKey extends keyof TObject | ||
? TObject[TKey] extends TValue | ||
? TObject[TKey] | ||
: never | ||
: never; | ||
export type ValueWithType<TObject extends object, TValue> = __ValueWithType< | ||
TObject, | ||
keyof TObject, | ||
TValue | ||
>; | ||
export type ValueWithType< | ||
TObject extends object, | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? __ValueWithType<TObject, keyof TObject, TValue> | ||
: never | ||
: __ValueWithType<TObject, keyof TObject, TValue>; | ||
@@ -107,8 +131,6 @@ type __ValueNotWithType< | ||
TValue | ||
> = TObject extends object | ||
? TKey extends keyof TObject | ||
? TObject[TKey] extends TValue | ||
? never | ||
: TObject[TKey] | ||
: never | ||
> = TKey extends keyof TObject | ||
? TObject[TKey] extends TValue | ||
? never | ||
: TObject[TKey] | ||
: never; | ||
@@ -118,4 +140,9 @@ | ||
TObject extends object, | ||
TValue | ||
> = __ValueNotWithType<TObject, keyof TObject, TValue>; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? __ValueNotWithType<TObject, keyof TObject, TValue> | ||
: never | ||
: __ValueNotWithType<TObject, keyof TObject, TValue>; | ||
@@ -126,7 +153,5 @@ type __ValueContainingType< | ||
TValue | ||
> = TObject extends object | ||
? TKey extends keyof TObject | ||
? TValue extends TObject[TKey] | ||
? TObject[TKey] | ||
: never | ||
> = TKey extends keyof TObject | ||
? TValue extends TObject[TKey] | ||
? TObject[TKey] | ||
: never | ||
@@ -137,4 +162,9 @@ : never; | ||
TObject extends object, | ||
TValue | ||
> = __ValueContainingType<TObject, keyof TObject, TValue>; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? __ValueContainingType<TObject, keyof TObject, TValue> | ||
: never | ||
: __ValueContainingType<TObject, keyof TObject, TValue>; | ||
@@ -145,8 +175,6 @@ type __ValueNotContainingType< | ||
TValue | ||
> = TObject extends object | ||
? TKey extends keyof TObject | ||
? TValue extends TObject[TKey] | ||
? never | ||
: TObject[TKey] | ||
: never | ||
> = TKey extends keyof TObject | ||
? TValue extends TObject[TKey] | ||
? never | ||
: TObject[TKey] | ||
: never; | ||
@@ -156,18 +184,27 @@ | ||
TObject extends object, | ||
TValue | ||
> = __ValueNotContainingType<TObject, keyof TObject, TValue>; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? __ValueNotContainingType<TObject, keyof TObject, TValue> | ||
: never | ||
: __ValueNotContainingType<TObject, keyof TObject, TValue>; | ||
export type ValueOfKey< | ||
TObject extends object, | ||
TKey extends keyof TObject | ||
> = TObject extends object | ||
? TKey extends keyof TObject | ||
? TObject[TKey] | ||
TKey extends keyof TObject, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? TKey extends keyof TObject | ||
? TObject[TKey] | ||
: never | ||
: never | ||
: never; | ||
: TObject[TKey]; | ||
export type ValueNotOfKey< | ||
TObject extends object, | ||
TKey extends keyof TObject | ||
> = ValueOfKey<TObject, Exclude<keyof TObject, TKey>>; | ||
TKey extends keyof TObject, | ||
TDistributeUnion extends boolean = true | ||
> = ValueOfKey<TObject, Exclude<keyof TObject, TKey>, TDistributeUnion>; | ||
@@ -178,13 +215,19 @@ // Keep or omit values by keys | ||
TObject extends object, | ||
TKey extends keyof TObject | ||
> = TObject extends object | ||
? Pick<TObject, Extract<keyof TObject, TKey>> | ||
: never; | ||
TKey extends keyof TObject, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? Pick<TObject, Extract<keyof TObject, TKey>> | ||
: never | ||
: Pick<TObject, Extract<keyof TObject, TKey>>; | ||
export type OmitValueOfKey< | ||
TObject extends object, | ||
TKey extends keyof TObject | ||
> = TObject extends object | ||
? Pick<TObject, Exclude<keyof TObject, TKey>> | ||
: never; | ||
TKey extends keyof TObject, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? Pick<TObject, Exclude<keyof TObject, TKey>> | ||
: never | ||
: Pick<TObject, Exclude<keyof TObject, TKey>>; | ||
@@ -195,34 +238,47 @@ // Keep or omit values with given type | ||
TObject extends object, | ||
TValue | ||
> = TObject extends object | ||
? {[K in KeyOfValueWithType<TObject, TValue>]: TObject[K]} | ||
: never; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? {[K in KeyOfValueWithType<TObject, TValue, true>]: TObject[K]} | ||
: never | ||
: {[K in KeyOfValueWithType<TObject, TValue, false>]: TObject[K]}; | ||
export type OmitValueWithType< | ||
TObject extends object, | ||
TValue | ||
> = TObject extends object | ||
? {[K in KeyOfValueNotWithType<TObject, TValue>]: TObject[K]} | ||
: never; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? {[K in KeyOfValueNotWithType<TObject, TValue, true>]: TObject[K]} | ||
: never | ||
: {[K in KeyOfValueNotWithType<TObject, TValue, false>]: TObject[K]}; | ||
export type KeepValueContainingType< | ||
TObject extends object, | ||
TValue | ||
> = TObject extends object | ||
? {[K in KeyOfValueContainingType<TObject, TValue>]: TObject[K]} | ||
: never; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? {[K in KeyOfValueContainingType<TObject, TValue, true>]: TObject[K]} | ||
: never | ||
: {[K in KeyOfValueContainingType<TObject, TValue, false>]: TObject[K]}; | ||
export type OmitValueContainingType< | ||
TObject extends object, | ||
TValue | ||
> = TObject extends object | ||
? {[K in KeyOfValueNotContainingType<TObject, TValue>]: TObject[K]} | ||
: never; | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
> = TDistributeUnion extends true | ||
? TObject extends object | ||
? {[K in KeyOfValueNotContainingType<TObject, TValue, true>]: TObject[K]} | ||
: never | ||
: {[K in KeyOfValueNotContainingType<TObject, TValue, false>]: TObject[K]}; | ||
// Optionalize values | ||
export type OptionalizeUndefined<TObject extends object> = Partial< | ||
KeepValueContainingType<TObject, undefined> | ||
> & | ||
OmitValueContainingType<TObject, undefined>; | ||
export type OptionalizeUndefined< | ||
TObject extends object, | ||
TDistributeUnion extends boolean = true | ||
> = Partial<KeepValueContainingType<TObject, undefined, TDistributeUnion>> & | ||
OmitValueContainingType<TObject, undefined, TDistributeUnion>; | ||
@@ -229,0 +285,0 @@ // Miscellaneous |
{ | ||
"name": "tslang", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "TypeScript Language Type Utilities.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
9447
273