@karmaniverous/entity-tools
Advanced tools
Comparing version 0.4.6 to 0.5.0
@@ -275,2 +275,25 @@ /** | ||
/** | ||
* Returns `true` if no property of `T` indicated in `N` has a `never` type. | ||
* | ||
* @typeParam T - The `object` type to check for `never` properties. | ||
* @typeParam N - A tuple of keys of `T` to check for `never` type. | ||
* | ||
* @returns `true` if no property of `T` indicated in `N` has a `never` type, otherwise a custom error type. | ||
* | ||
* @example | ||
* ```ts | ||
* type ReturnsTrue = NotNever<{ a: string; b: number; c: boolean }, ['b', 'c']>; | ||
* // true | ||
* | ||
* type ReturnsError = NotNever<{ a: string; b: number; c: never }, ['b', 'c']>; | ||
* // { __error__: 'c is never' } | ||
* ``` | ||
* | ||
* @category Utilities | ||
*/ | ||
type NotNever<T extends object, N extends (string & keyof T)[]> = N extends [infer Head, ...infer Tail] ? Head extends string & keyof T ? [T[Head]] extends [never] ? { | ||
__error__: `${Head} is never`; | ||
} : Tail extends string[] ? NotNever<T, Tail extends (string & keyof T)[] ? Tail : []> : true : true : true; | ||
/** | ||
* Returns the properties of `object` `O` with types that extend type `T`. Ignores `undefined` types. | ||
@@ -379,2 +402,2 @@ * | ||
export { type AllDisjoint, type DefaultTranscodeMap, type Entity, type EntityKeys, type EntityMap, type EntityMapValues, type EntityValue, type Exactify, type FlattenEntityMap, type MakeOptional, type MutuallyExclusive, type Nil, type PartialTranscodable, type PropertiesNotOfType, type PropertiesOfType, type SortOrder, type TranscodableProperties, type TranscodeMap, type Transcodes, type UntranscodableProperties, type WithRequiredAndNonNullable, defaultTranscodes, isNil, sort }; | ||
export { type AllDisjoint, type DefaultTranscodeMap, type Entity, type EntityKeys, type EntityMap, type EntityMapValues, type EntityValue, type Exactify, type FlattenEntityMap, type MakeOptional, type MutuallyExclusive, type Nil, type NotNever, type PartialTranscodable, type PropertiesNotOfType, type PropertiesOfType, type SortOrder, type TranscodableProperties, type TranscodeMap, type Transcodes, type UntranscodableProperties, type WithRequiredAndNonNullable, defaultTranscodes, isNil, sort }; |
@@ -129,3 +129,3 @@ { | ||
"types": "dist/index.d.ts", | ||
"version": "0.4.6", | ||
"version": "0.5.0", | ||
"dependencies": { | ||
@@ -132,0 +132,0 @@ "radash": "^12.1.0" |
32222
749