inferred-types 0.22.5 → 0.22.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -517,6 +517,33 @@ declare type DictPartialApplication<T extends Record<string, any>, I extends boo
|
|
|
517
517
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? Record<K, ReturnType<T[K]>> : true extends I ? never : Record<K, T[K]>;
|
|
518
518
|
}[keyof T]>;
|
|
519
519
|
|
|
520
|
+
/**
|
|
521
|
+
* Allow a dictionary have it's value's type changed to `T` while maintaining the keys in
|
|
522
|
+
* the original object `I` so long as the original value for the KV pair extends `V`.
|
|
523
|
+
*
|
|
524
|
+
* If `V` is not specified then it defaults to _any_ and therefore all KVs are preserved.
|
|
525
|
+
*
|
|
526
|
+
* ```ts
|
|
527
|
+
* type Obj = { foo: "hello", bar: 42, baz: () => "world" };
|
|
528
|
+
* // { foo: number, bar: number, baz: number };
|
|
529
|
+
* type AllNumbers = DictChangeValue<Obj, number>;
|
|
530
|
+
* // { foo: number }
|
|
531
|
+
* type StringToBool = DictChangeValue<Obj, boolean, string>
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
declare type DictChangeValue<
|
|
535
|
+
/** the object who's value-type we're changing */
|
|
536
|
+
I extends Record<string, any>,
|
|
537
|
+
/** the return type that functions should be modified to have */
|
|
538
|
+
T extends any,
|
|
539
|
+
/**
|
|
540
|
+
*The type we expect in the value; if the value extends type `V` then the value will
|
|
541
|
+
* be converted to type `O`; if not then the KV pair will be discarded
|
|
542
|
+
*/
|
|
543
|
+
V extends any = any> = SimplifyObject<{
|
|
544
|
+
[K in keyof I]: I[K] extends V ? Record<K, T> : never;
|
|
545
|
+
}[keyof I]>;
|
|
546
|
+
|
|
520
547
|
/**
|
|
521
548
|
* **DictPrependWithFn**
|
|
522
549
|
*
|
|
@@ -1675,4 +1702,4 @@ interface IFluentConfigurator<C> {
|
|
|
1675
1702
|
*/
|
|
1676
1703
|
declare function FluentConfigurator<I>(initial?: I): IFluentConfigurator<{}>;
|
|
1677
1704
|
|
|
1678
|
-
export { AllCaps, Alpha, AlphaNumeric, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AssertExtends, Bracket, Break, CamelCase, CapitalizeWords, ClosingBracket, Condition, Configurator, Constructor, DashToSnake, DashUppercase, Dasherize, DefinePropertiesApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DynamicRule, DynamicRuleSet, Email, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, ExtendsClause, ExtendsNarrowlyClause, Filter, FinalReturn, First, FirstKey, FirstKeyValue, FirstOfEach, FluentConfigurator, FluentFunction, FromDictArray, FunctionType, GeneralDictionary, Get, HasUppercase, IConfigurator, IFluentConfigurator, If, IfExtends, IfExtendsThen, Include, Includes, IsArray, IsBoolean, IsCapitalized, IsFalse, IsFunction, IsObject, IsString, IsTrue, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LowerAllCaps, LowerAlpha, MaybeFalse, MaybeTrue, Model, Mutable, MutableProps, MutationFunction, MutationIdentity, Narrowable, NonAlpha, NonNumericKeys, NonStringKeys, Not, Numeric, NumericKeys, NumericString, ObjectType, Opaque, OpeningBracket, OptionalKeys, OptionalProps, Parenthesis, PascalCase, Pluralize, PrivateKey, PrivateKeys, PublicKeys, Punctuation, PureFluentApi, Replace, RequireProps, RequiredKeys, RequiredProps, Retain, RightWhitespace, RuleDefinition, RuntimeProp, RuntimeType, SameKeys, SecondOfEach, SimplifyObject, SnakeCase, SpecialCharacters, StringDelimiter, StringKeys, StringLength, ToFluent, Transformer, Trim, TrimLeft, TrimRight, TupleToUnion, Type, TypeApi, TypeCondition, TypeDefinition, TypeGuard, TypeOptions, UnionToIntersection, UnionToTuple, UniqueDictionary, UniqueForProp, UpperAlpha, ValueTuple, ValueTypeFunc, ValueTypes, Where, WhereNot, Whitespace, WithNumericKeys, WithStringKeys, WithValue, ZipCode, and, api, arrayToKeyLookup, arrayToObject, condition, createFnWithProps, createMutationFunction, defineProperties, defineType, dictToKv, dictionaryTransform, entries, equals, filterDictArray, fnWithProps, greater, groupBy, idLiteral, idTypeGuard, identity, ifTypeOf, isArray, isBoolean, isFalse, isFunction, isNull, isNumber, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, less, literal, mapValues, nameLiteral, or, randomString, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, uuid, valueTypes, withValue };
|
|
1705
|
+
export { AllCaps, Alpha, AlphaNumeric, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AssertExtends, Bracket, Break, CamelCase, CapitalizeWords, ClosingBracket, Condition, Configurator, Constructor, DashToSnake, DashUppercase, Dasherize, DefinePropertiesApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictChangeValue, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DynamicRule, DynamicRuleSet, Email, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, ExtendsClause, ExtendsNarrowlyClause, Filter, FinalReturn, First, FirstKey, FirstKeyValue, FirstOfEach, FluentConfigurator, FluentFunction, FromDictArray, FunctionType, GeneralDictionary, Get, HasUppercase, IConfigurator, IFluentConfigurator, If, IfExtends, IfExtendsThen, Include, Includes, IsArray, IsBoolean, IsCapitalized, IsFalse, IsFunction, IsObject, IsString, IsTrue, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LowerAllCaps, LowerAlpha, MaybeFalse, MaybeTrue, Model, Mutable, MutableProps, MutationFunction, MutationIdentity, Narrowable, NonAlpha, NonNumericKeys, NonStringKeys, Not, Numeric, NumericKeys, NumericString, ObjectType, Opaque, OpeningBracket, OptionalKeys, OptionalProps, Parenthesis, PascalCase, Pluralize, PrivateKey, PrivateKeys, PublicKeys, Punctuation, PureFluentApi, Replace, RequireProps, RequiredKeys, RequiredProps, Retain, RightWhitespace, RuleDefinition, RuntimeProp, RuntimeType, SameKeys, SecondOfEach, SimplifyObject, SnakeCase, SpecialCharacters, StringDelimiter, StringKeys, StringLength, ToFluent, Transformer, Trim, TrimLeft, TrimRight, TupleToUnion, Type, TypeApi, TypeCondition, TypeDefinition, TypeGuard, TypeOptions, UnionToIntersection, UnionToTuple, UniqueDictionary, UniqueForProp, UpperAlpha, ValueTuple, ValueTypeFunc, ValueTypes, Where, WhereNot, Whitespace, WithNumericKeys, WithStringKeys, WithValue, ZipCode, and, api, arrayToKeyLookup, arrayToObject, condition, createFnWithProps, createMutationFunction, defineProperties, defineType, dictToKv, dictionaryTransform, entries, equals, filterDictArray, fnWithProps, greater, groupBy, idLiteral, idTypeGuard, identity, ifTypeOf, isArray, isBoolean, isFalse, isFunction, isNull, isNumber, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, less, literal, mapValues, nameLiteral, or, randomString, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, uuid, valueTypes, withValue };
|
package/package.json
CHANGED
|
@@ -5,6 +5,14 @@ import { SimplifyObject } from "../SimplifyObject";
|
|
|
5
5
|
* the original object `I` so long as the original value for the KV pair extends `V`.
|
|
6
6
|
*
|
|
7
7
|
* If `V` is not specified then it defaults to _any_ and therefore all KVs are preserved.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* type Obj = { foo: "hello", bar: 42, baz: () => "world" };
|
|
11
|
+
* // { foo: number, bar: number, baz: number };
|
|
12
|
+
* type AllNumbers = DictChangeValue<Obj, number>;
|
|
13
|
+
* // { foo: number }
|
|
14
|
+
* type StringToBool = DictChangeValue<Obj, boolean, string>
|
|
15
|
+
* ```
|
|
8
16
|
*/
|
|
9
17
|
export type DictChangeValue<
|
|
10
18
|
/** the object who's value-type we're changing */
|