Comparing version 2.7.2 to 2.7.3
@@ -1,2 +0,5 @@ | ||
import { IfEquals, IfCompatible, IfUndefined, IfAny, IfJson, IfNull } from './type-check'; | ||
import { | ||
IfEquals, IfCompatible, IfUndefined, | ||
IfJson, IfNull, IfFunction | ||
} from './type-check'; | ||
@@ -20,7 +23,7 @@ /** | ||
export type RequiredKeys<T> = _RequiredKeys<T> | ||
export type _RequiredKeys<T> = { | ||
export type _RequiredKeys<T> = ValuesOf<{ | ||
[K in keyof T]-?: IfUndefined<T[K]> extends true ? never | ||
: T extends { [K1 in K]: any } ? K | ||
: never | ||
}[keyof T]; | ||
}>; | ||
@@ -32,7 +35,7 @@ /** | ||
export type OptionalKeys<T> = _OptionalKeys<T> | ||
export type _OptionalKeys<T> = { | ||
export type _OptionalKeys<T> = ValuesOf<{ | ||
[K in keyof T]-?: IfUndefined<T[K]> extends true ? never | ||
: T extends { [K1 in K]: any } ? never | ||
: K | ||
}[keyof T]; | ||
}>; | ||
@@ -43,7 +46,8 @@ | ||
*/ | ||
export type ReadonlyKeys<T> = { | ||
[K in keyof T]-?: IfEquals<{ [Q in K]: T[K] }, { -readonly [Q in K]: T[K] }, never, K> | ||
}[keyof T]; | ||
export type ReadonlyKeys<T> = _ReadonlyKeys<T> | ||
type _ReadonlyKeys<T, J = Required<T>> = ValuesOf<{ | ||
[K in keyof J]: K extends symbol ? never | ||
: IfEquals<{ [Q in K]: J[K] }, { -readonly [Q in K]: J[K] }, never, K> | ||
}>; | ||
/** | ||
@@ -64,5 +68,7 @@ * @desc Returns JSON friendly keys of an object | ||
*/ | ||
export type WritableKeys<T> = { | ||
[K in keyof T]-?: IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }, never, K> | ||
}[keyof T]; | ||
export type WritableKeys<T> = _WritableKeys<T>; | ||
type _WritableKeys<T> = ValuesOf<{ | ||
[K in keyof T]-?: K extends symbol ? never | ||
: IfEquals<{ [Q in K]: T[K] }, { readonly [Q in K]: T[K] }, never, K> | ||
}>; | ||
@@ -73,5 +79,3 @@ | ||
*/ | ||
export type WritableJsonKeys<T> = Extract<{ | ||
[K in keyof T]-?: IfEquals<{ [Q in K]: T[K] }, { -readonly [Q in K]: T[K] }, K, never> | ||
}[keyof T], JsonKeys<T>>; | ||
export type WritableJsonKeys<T> = Extract<WritableKeys<T>, JsonKeys<T>>; | ||
@@ -81,7 +85,6 @@ /** | ||
*/ | ||
export type FunctionKeys<T> = ValuesOf<{ | ||
[K in keyof T]-?: IfUndefined<T[K]> extends false ? | ||
IfAny<T[K]> extends false | ||
? T[K] extends Function ? K | ||
: never : never : never; | ||
export type FunctionKeys<T> = _FunctionKeys<T>; | ||
type _FunctionKeys<T> = ValuesOf<{ | ||
[K in keyof T]-?: K extends symbol ? never | ||
: IfFunction<T[K]> extends true ? K : never; | ||
}>; | ||
@@ -92,7 +95,6 @@ | ||
*/ | ||
export type NonFunctionKeys<T> = ValuesOf<{ | ||
[K in keyof T]-?: IfUndefined<T[K]> extends false ? | ||
IfAny<T[K]> extends false | ||
? T[K] extends Function ? never | ||
: K : K : K; | ||
export type NonFunctionKeys<T> = _NonFunctionKeys<T>; | ||
type _NonFunctionKeys<T> = ValuesOf<{ | ||
[K in keyof T]-?: K extends symbol ? never | ||
: IfFunction<T[K]> extends true ? never : K; | ||
}>; | ||
@@ -104,4 +106,6 @@ | ||
*/ | ||
export type KeysCompatible<T, U> = ValuesOf<{ | ||
[K in keyof T]-?: IfCompatible<T[K], U, K, never>; | ||
export type KeysCompatible<T, U> = _KeysCompatible<T, U>; | ||
type _KeysCompatible<T, U> = ValuesOf<{ | ||
[K in keyof T]-?: K extends symbol ? never | ||
: IfCompatible<T[K], U, K, never>; | ||
}>; | ||
@@ -112,5 +116,7 @@ | ||
*/ | ||
export type KeysEquals<T, U> = ValuesOf<{ | ||
[K in keyof T]-?: IfEquals<T[K], U, K, never>; | ||
export type KeysEquals<T, U> = _KeysEquals<T, U>; | ||
type _KeysEquals<T, U> = ValuesOf<{ | ||
[K in keyof T]-?: K extends symbol ? never | ||
: IfEquals<T[K], U, K, never>; | ||
}>; | ||
@@ -116,4 +116,5 @@ import { Primitive, Type } from './common'; | ||
: IfNull<T> extends true ? N | ||
: T extends Function ? Y | ||
: N; | ||
: T extends Type ? N | ||
: T extends Function ? Y | ||
: N; | ||
@@ -120,0 +121,0 @@ export type IfFunctionOrAny<T, Y = true, N = false> = |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "2.7.2", | ||
"version": "2.7.3", | ||
"types": "lib/index.d.ts", | ||
@@ -18,0 +18,0 @@ "main": "lib/index.js", |
26774
673