inferred-types 0.16.0 → 0.18.1
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/.tsbuildinfo +1 -0
- package/devops/build.js +1 -3
- package/dist/{types/utility/state/KeyStorage.d.ts → index.d.ts} +9767 -8195
- package/dist/index.js +659 -0
- package/dist/index.mjs +577 -0
- package/on-hold/tests/api-spec.ts +9 -15
- package/package.json +27 -39
- package/pnpm-lock.yaml +2807 -3858
- package/src/errors/InferenceError.ts +1 -1
- package/src/shared/randomString.ts +1 -1
- package/src/types/Constructor.ts +5 -0
- package/src/types/Not.ts +3 -1
- package/src/types/Transformer.ts +1 -2
- package/src/types/Where.ts +36 -0
- package/src/types/alphabetic/PascalCase.ts +5 -4
- package/src/types/alphabetic/index.ts +9 -5
- package/src/types/{fluent.ts → fluent/fluent.ts} +8 -9
- package/src/types/fluent/index.ts +42 -0
- package/src/types/index.ts +13 -7
- package/src/types/ruleset-types.ts +1 -1
- package/src/types/{SameKeys.ts → type-conversion/SameKeys.ts} +0 -0
- package/src/types/type-conversion/WrapValue.ts +15 -0
- package/src/types/type-conversion/index.ts +11 -4
- package/src/utility/dictionary/dictionaryTransform.ts +6 -7
- package/tests/Where.spec.ts +39 -0
- package/tests/constructor.spec.ts +40 -0
- package/tests/data/index.ts +8 -3
- package/tests/kv/dict-to-kv-and-back.spec.ts +2 -6
- package/tsconfig.json +4 -3
- package/dist/cjs/index.js +0 -21
- package/dist/es/index.js +0 -17
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/Mutation/MutationFunction.d.ts +0 -16
- package/dist/types/Mutation/MutationIdentity.d.ts +0 -30
- package/dist/types/Mutation/index.d.ts +0 -2
- package/dist/types/errors/InferenceError.d.ts +0 -1
- package/dist/types/errors/index.d.ts +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/shared/index.d.ts +0 -3
- package/dist/types/shared/randomString.d.ts +0 -1
- package/dist/types/shared/uuid.d.ts +0 -1
- package/dist/types/shared/valueTypes.d.ts +0 -27
- package/dist/types/types/Api.d.ts +0 -10
- package/dist/types/types/EnumValues.d.ts +0 -14
- package/dist/types/types/ExpandRecursively.d.ts +0 -3
- package/dist/types/types/First.d.ts +0 -4
- package/dist/types/types/FunctionType.d.ts +0 -9
- package/dist/types/types/If.d.ts +0 -10
- package/dist/types/types/Include.d.ts +0 -16
- package/dist/types/types/Includes.d.ts +0 -5
- package/dist/types/types/KeyedRecord.d.ts +0 -22
- package/dist/types/types/Keys.d.ts +0 -17
- package/dist/types/types/Length.d.ts +0 -8
- package/dist/types/types/Mutable.d.ts +0 -6
- package/dist/types/types/Narrowable.d.ts +0 -5
- package/dist/types/types/Not.d.ts +0 -11
- package/dist/types/types/Numeric.d.ts +0 -14
- package/dist/types/types/Opaque.d.ts +0 -12
- package/dist/types/types/Retain.d.ts +0 -16
- package/dist/types/types/SameKeys.d.ts +0 -11
- package/dist/types/types/Transformer.d.ts +0 -11
- package/dist/types/types/TypeGuard.d.ts +0 -7
- package/dist/types/types/alphabetic/AllCaps.d.ts +0 -12
- package/dist/types/types/alphabetic/CamelCase.d.ts +0 -2
- package/dist/types/types/alphabetic/CapFirstAlpha.d.ts +0 -13
- package/dist/types/types/alphabetic/CapitalizeWords.d.ts +0 -4
- package/dist/types/types/alphabetic/DashToSnake.d.ts +0 -1
- package/dist/types/types/alphabetic/DashUppercase.d.ts +0 -14
- package/dist/types/types/alphabetic/Dasherize.d.ts +0 -15
- package/dist/types/types/alphabetic/HasUppercase.d.ts +0 -13
- package/dist/types/types/alphabetic/Intrinsic.d.ts +0 -4
- package/dist/types/types/alphabetic/IsCapitalized.d.ts +0 -15
- package/dist/types/types/alphabetic/KebabCase.d.ts +0 -12
- package/dist/types/types/alphabetic/LowerAllCaps.d.ts +0 -4
- package/dist/types/types/alphabetic/PascalCase.d.ts +0 -16
- package/dist/types/types/alphabetic/Pluralize.d.ts +0 -36
- package/dist/types/types/alphabetic/SnakeCase.d.ts +0 -14
- package/dist/types/types/alphabetic/alpha-characters.d.ts +0 -36
- package/dist/types/types/alphabetic/index.d.ts +0 -16
- package/dist/types/types/append-types.d.ts +0 -9
- package/dist/types/types/dictionary/Get.d.ts +0 -7
- package/dist/types/types/dictionary/index.d.ts +0 -1
- package/dist/types/types/fluent.d.ts +0 -51
- package/dist/types/types/index.d.ts +0 -34
- package/dist/types/types/kv/DictFromKv.d.ts +0 -6
- package/dist/types/types/kv/KeyValue.d.ts +0 -11
- package/dist/types/types/kv/KvFrom.d.ts +0 -13
- package/dist/types/types/kv/KvTuple.d.ts +0 -14
- package/dist/types/types/kv/index.d.ts +0 -4
- package/dist/types/types/lists/UniqueForProp.d.ts +0 -14
- package/dist/types/types/lists/index.d.ts +0 -1
- package/dist/types/types/maybe.d.ts +0 -8
- package/dist/types/types/props.d.ts +0 -100
- package/dist/types/types/ruleset-types.d.ts +0 -59
- package/dist/types/types/runtime.d.ts +0 -33
- package/dist/types/types/string-literals/Break.d.ts +0 -12
- package/dist/types/types/string-literals/Concat.d.ts +0 -8
- package/dist/types/types/string-literals/LeftWhitespace.d.ts +0 -9
- package/dist/types/types/string-literals/Replace.d.ts +0 -11
- package/dist/types/types/string-literals/RightWhitespace.d.ts +0 -9
- package/dist/types/types/string-literals/StringLength.d.ts +0 -10
- package/dist/types/types/string-literals/Trim.d.ts +0 -11
- package/dist/types/types/string-literals/TrimLeft.d.ts +0 -11
- package/dist/types/types/string-literals/TrimRight.d.ts +0 -11
- package/dist/types/types/string-literals/form-fields.d.ts +0 -12
- package/dist/types/types/string-literals/index.d.ts +0 -10
- package/dist/types/types/tuples/DictArray.d.ts +0 -19
- package/dist/types/types/tuples/FirstKey.d.ts +0 -8
- package/dist/types/types/tuples/FirstKeyValue.d.ts +0 -8
- package/dist/types/types/tuples/FirstOfEach.d.ts +0 -11
- package/dist/types/types/tuples/FromDictArray.d.ts +0 -10
- package/dist/types/types/tuples/SecondOfEach.d.ts +0 -10
- package/dist/types/types/tuples/index.d.ts +0 -6
- package/dist/types/types/type-conversion/TupleToUnion.d.ts +0 -10
- package/dist/types/types/type-conversion/UnionToIntersection.d.ts +0 -5
- package/dist/types/types/type-conversion/UnionToTuple.d.ts +0 -9
- package/dist/types/types/type-conversion/index.d.ts +0 -3
- package/dist/types/types/type-testing.d.ts +0 -13
- package/dist/types/utility/api/api.d.ts +0 -2
- package/dist/types/utility/api/index.d.ts +0 -1
- package/dist/types/utility/createFnWithProps.d.ts +0 -1
- package/dist/types/utility/dictionary/arrayToKeyLookup.d.ts +0 -9
- package/dist/types/utility/dictionary/dictFilter.d.ts +0 -8
- package/dist/types/utility/dictionary/dictionaryTransform.d.ts +0 -9
- package/dist/types/utility/dictionary/entries.d.ts +0 -17
- package/dist/types/utility/dictionary/index.d.ts +0 -8
- package/dist/types/utility/dictionary/kv/dictToKv.d.ts +0 -16
- package/dist/types/utility/dictionary/kv/filterDictArray.d.ts +0 -9
- package/dist/types/utility/dictionary/kv/index.d.ts +0 -4
- package/dist/types/utility/dictionary/kv/kv.d.ts +0 -10
- package/dist/types/utility/dictionary/kv/kvToDict.d.ts +0 -15
- package/dist/types/utility/dictionary/mapValues.d.ts +0 -13
- package/dist/types/utility/dictionary/strArrayToDict.d.ts +0 -6
- package/dist/types/utility/dictionary/valuesOfProp.d.ts +0 -1
- package/dist/types/utility/index.d.ts +0 -11
- package/dist/types/utility/keys.d.ts +0 -5
- package/dist/types/utility/lists/groupBy.d.ts +0 -12
- package/dist/types/utility/lists/index.d.ts +0 -1
- package/dist/types/utility/literals/ExplicitFunction.d.ts +0 -6
- package/dist/types/utility/literals/arrayToObject.d.ts +0 -41
- package/dist/types/utility/literals/defineType.d.ts +0 -8
- package/dist/types/utility/literals/identity.d.ts +0 -6
- package/dist/types/utility/literals/index.d.ts +0 -5
- package/dist/types/utility/literals/literal.d.ts +0 -41
- package/dist/types/utility/map-reduce/filter.d.ts +0 -26
- package/dist/types/utility/map-reduce/index.d.ts +0 -1
- package/dist/types/utility/modelling/IoModel.d.ts +0 -26
- package/dist/types/utility/modelling/Model.d.ts +0 -22
- package/dist/types/utility/modelling/index.d.ts +0 -1
- package/dist/types/utility/ruleset.d.ts +0 -18
- package/dist/types/utility/runtime/condition.d.ts +0 -3
- package/dist/types/utility/runtime/conditions/index.d.ts +0 -12
- package/dist/types/utility/runtime/conditions/isArray.d.ts +0 -2
- package/dist/types/utility/runtime/conditions/isBoolean.d.ts +0 -5
- package/dist/types/utility/runtime/conditions/isFalse.d.ts +0 -4
- package/dist/types/utility/runtime/conditions/isFunction.d.ts +0 -15
- package/dist/types/utility/runtime/conditions/isLiteral.d.ts +0 -2
- package/dist/types/utility/runtime/conditions/isNull.d.ts +0 -1
- package/dist/types/utility/runtime/conditions/isNumber.d.ts +0 -1
- package/dist/types/utility/runtime/conditions/isObject.d.ts +0 -10
- package/dist/types/utility/runtime/conditions/isString.d.ts +0 -2
- package/dist/types/utility/runtime/conditions/isSymbol.d.ts +0 -1
- package/dist/types/utility/runtime/conditions/isTrue.d.ts +0 -20
- package/dist/types/utility/runtime/conditions/isUndefined.d.ts +0 -1
- package/dist/types/utility/runtime/ifTypeOf.d.ts +0 -23
- package/dist/types/utility/runtime/index.d.ts +0 -5
- package/dist/types/utility/runtime/type.d.ts +0 -27
- package/dist/types/utility/runtime/withValue.d.ts +0 -19
- package/dist/types/utility/state/Configurator.d.ts +0 -36
- package/dist/types/utility/state/FluentConfigurator.d.ts +0 -27
- package/dist/types/utility/state/index.d.ts +0 -3
- package/src/types/alphabetic/Intrinsic.ts +0 -6
- package/src/utility/modelling/IoModel.ts +0 -38
- package/tests/FluentApi-spec.ts +0 -90
- package/tests/FluentConfigurator-spec.hold +0 -88
- package/tests/IoModel-spec.hold +0 -209
- package/tests/lists/groupBy.spec.ts +0 -0
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Indicates whether `T` has _all_ uppercase characters in it.
|
|
3
|
-
* ```ts
|
|
4
|
-
* // true
|
|
5
|
-
* type T = AllCaps<"FOOBAR">;
|
|
6
|
-
* // false
|
|
7
|
-
* type T = AllCaps<"FooBar">;
|
|
8
|
-
* // "unknown"
|
|
9
|
-
* type T = AllCaps<string>;
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export declare type AllCaps<T extends string> = string extends T ? "unknown" : T extends Uppercase<T> ? true : false;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { NonAlpha, Replace } from "../index";
|
|
2
|
-
/**
|
|
3
|
-
* Strips the non-alpha characters that lead a string
|
|
4
|
-
*/
|
|
5
|
-
export declare type StripLeftNonAlpha<S extends string> = S extends `${infer First}${infer Rest}` ? First extends NonAlpha ? StripLeftNonAlpha<Rest> : S : never;
|
|
6
|
-
/**
|
|
7
|
-
* identifies the leading characters which are _not_ alphabetical
|
|
8
|
-
*/
|
|
9
|
-
export declare type LeadingNonAlpha<S extends string> = Replace<S, StripLeftNonAlpha<S>, "">;
|
|
10
|
-
/**
|
|
11
|
-
* Capitalize the first alphabetical character in the string
|
|
12
|
-
*/
|
|
13
|
-
export declare type CapFirstAlpha<T extends string> = LeadingNonAlpha<T> extends string ? `${LeadingNonAlpha<T>}${Capitalize<Replace<T, LeadingNonAlpha<T>, "">>}` : Capitalize<T>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Capitalize all words in a string
|
|
3
|
-
*/
|
|
4
|
-
export declare type CapitalizeWords<S extends string> = S extends `${infer L} ${infer R}` ? `${CapitalizeWords<L>} ${CapitalizeWords<R>}` : S extends `${infer L},${infer R}` ? `${CapitalizeWords<L>},${CapitalizeWords<R>}` : S extends `${infer L}.${infer R}` ? `${CapitalizeWords<L>}.${CapitalizeWords<R>}` : Capitalize<S>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare type DashToSnake<T extends string> = T extends `${infer HEAD}-${infer TAIL}` ? DashToSnake<`${HEAD}_${TAIL}`> : T;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { HasUppercase } from "./HasUppercase";
|
|
2
|
-
declare type _DU<T extends string> = T extends Lowercase<T> ? T : `-${Lowercase<T>}`;
|
|
3
|
-
/**
|
|
4
|
-
* Converts uppercase characters to a dash and then the lowercase equivalent
|
|
5
|
-
* ```ts
|
|
6
|
-
* // "one-two-three"
|
|
7
|
-
* type T = DashUppercase<"oneTwoThree">;
|
|
8
|
-
* ```
|
|
9
|
-
*
|
|
10
|
-
* _Intended to be used as a lower level utility; prefer `Dasherize<T>` for more full-fledged
|
|
11
|
-
* dash solution_.
|
|
12
|
-
*/
|
|
13
|
-
export declare type DashUppercase<T extends string> = HasUppercase<T> extends false ? T : T extends `${infer C0}${infer C1}${infer R}` ? `${_DU<C0>}${_DU<C1>}${DashUppercase<R>}` : T extends `${infer C0}${infer R}` ? `${_DU<C0>}${DashUppercase<R>}` : "";
|
|
14
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DashUppercase, LowerAllCaps } from "../index";
|
|
2
|
-
import { Trim } from "../string-literals/index";
|
|
3
|
-
/**
|
|
4
|
-
* Converts a string literal into a _dasherized_ format while ignoring _exterior_ whitepace.
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* // "foo-bar"
|
|
8
|
-
* type Dash = Dasherize<"foo_bar">;
|
|
9
|
-
* type Dash = Dasherize<"fooBar">;
|
|
10
|
-
* type Dash = Dasherize<"FooBar">;
|
|
11
|
-
* // "\n foo-bar \t"
|
|
12
|
-
* type Dash = Dasherize<"\n foo bar \t">;
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare type Dasherize<S extends string> = string extends S ? string : DashUppercase<Trim<LowerAllCaps<S>>> extends `${infer Begin}${"_" | " "}${infer Rest}` ? Dasherize<`${Lowercase<Begin>}-${Rest}`> : Lowercase<DashUppercase<Uncapitalize<Trim<LowerAllCaps<S>>>>>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { UpperAlpha } from "./alpha-characters";
|
|
2
|
-
/**
|
|
3
|
-
* Indicates whether `T` has uppercase characters in it.
|
|
4
|
-
* ```ts
|
|
5
|
-
* // true
|
|
6
|
-
* type T = HasUppercase<"Foobar">;
|
|
7
|
-
* // false
|
|
8
|
-
* type T = HasUppercase<"foobar">;
|
|
9
|
-
* // "unknown"
|
|
10
|
-
* type T = HasUppercase<string>;
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export declare type HasUppercase<T extends string> = string extends T ? "unknown" : T extends `${string}${UpperAlpha}${string}` ? true : false;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns true or false value based on whether the string literal is capitalized.
|
|
3
|
-
* ```ts
|
|
4
|
-
* // true
|
|
5
|
-
* type T2 = IsCapitalized<"One">;
|
|
6
|
-
* // false
|
|
7
|
-
* type T1 = IsCapitalized<"one">;
|
|
8
|
-
* // "unknown"
|
|
9
|
-
* const a: string = "Hi";
|
|
10
|
-
* type T3 = IsCapitalized<typeof a>;
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Note: _if the value passed in is a "string" then the result will be "unknown"_
|
|
14
|
-
*/
|
|
15
|
-
export declare type IsCapitalized<T extends string> = string extends T ? "unknown" : T extends Capitalize<T> ? true : false;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Dasherize } from "./index";
|
|
2
|
-
/**
|
|
3
|
-
* **KebabCase<T>** is an _alias_ for **Dasherize<T>**.
|
|
4
|
-
* ```ts
|
|
5
|
-
* // "foo-bar"
|
|
6
|
-
* type Kebab = KebabCase<"foo_bar">;
|
|
7
|
-
* type Kebab = KebabCase<"fooBar">;
|
|
8
|
-
* type Kebab = KebabCase<"FooBar">;
|
|
9
|
-
* // "\n foo-bar \t"
|
|
10
|
-
* type Kebab = KebabCase<"\n foo bar \t">;
|
|
11
|
-
* ``` */
|
|
12
|
-
export declare type KebabCase<T extends string> = Dasherize<T>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Capitalize, LowerAllCaps, Trim } from "../index";
|
|
2
|
-
declare type Delimiter = "_" | "-" | " ";
|
|
3
|
-
/** convert all delimiters to dashes */
|
|
4
|
-
declare type DashDelim<T extends string> = T extends `${infer Begin}${" "}${infer Rest}` ? DashDelim<`${Begin}-${Rest}`> : T extends `${infer Begin}${"_"}${infer Rest}` ? DashDelim<`${Begin}-${Rest}`> : T;
|
|
5
|
-
/**
|
|
6
|
-
* Converts a string literal type to a **PascalCase** representation.
|
|
7
|
-
* ```ts
|
|
8
|
-
* // "FooBar"
|
|
9
|
-
* type T = PascalCase<"fooBar">;
|
|
10
|
-
* type T = PascalCase<"foo-bar">;
|
|
11
|
-
* type T = PascalCase<"foo_bar">;
|
|
12
|
-
* type T = PascalCase<"\n foo_bar \t">;
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare type PascalCase<S extends string> = string extends S ? string : Trim<DashDelim<LowerAllCaps<S>>> extends `${infer Begin}${Delimiter}${infer Rest}` ? PascalCase<`${Capitalize<Begin>}${Capitalize<Rest>}`> : Capitalize<Trim<LowerAllCaps<S>>>;
|
|
16
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
declare type Consonant = "b" | "c" | "d" | "f" | "g" | "h" | "j" | "k" | "l" | "m" | "n" | "p" | "q" | "r" | "s" | "t" | "v" | "w" | "x" | "z" | "y";
|
|
2
|
-
declare type Exceptions = "photo => photos" | "piano => pianos" | "halo => halos" | "foot => feet" | "man => men" | "woman => women" | "person => people" | "mouse => mice" | "series => series" | "sheep => sheep" | "money => monies" | "deer => deer";
|
|
3
|
-
declare type SingularException<T = Exceptions> = T extends `${infer SINGULAR} => ${infer PLURAL}` ? SINGULAR : never;
|
|
4
|
-
declare type PluralException<T extends SingularException, E extends Exceptions = Exceptions> = E extends `${T} => ${infer PLURAL}` ? PLURAL : never;
|
|
5
|
-
declare type SingularNoun = "s" | "sh" | "ch" | "x" | "z" | "o";
|
|
6
|
-
declare type F = "f" | "fe";
|
|
7
|
-
declare type Y = `${Consonant}y`;
|
|
8
|
-
declare type RemoveTrailingY<T> = T extends `${infer HEAD}y` ? HEAD : T;
|
|
9
|
-
/** validates that a word ends with a pluralization exception */
|
|
10
|
-
declare type isException<T extends string> = T extends SingularException ? T : never;
|
|
11
|
-
/** validates that a string literal ends in "is" */
|
|
12
|
-
declare type EndsIn_IS<T extends string> = T extends `${infer HEAD}is` ? T : never;
|
|
13
|
-
/** validates that a string literal is a singular noun */
|
|
14
|
-
declare type EndsInSingularNoun<T extends string> = T extends `${infer HEAD}${SingularNoun}` ? T : never;
|
|
15
|
-
/** validates that a string literal ends in "f" or "fe" */
|
|
16
|
-
declare type EndsIn_F<T extends string> = T extends `${infer HEAD}${F}` ? T : never;
|
|
17
|
-
/** validates that a string literal ends a consonant followed by "y" */
|
|
18
|
-
declare type EndsIn_Y<T extends string> = T extends `${infer HEAD}${Y}` ? T : never;
|
|
19
|
-
/**
|
|
20
|
-
* strings which end in the letters "is" should have an "es" added to the end
|
|
21
|
-
*/
|
|
22
|
-
declare type PluralizeEndingIn_IS<T extends string> = T extends `${infer HEAD}is` ? `${HEAD}ises` : T;
|
|
23
|
-
/**
|
|
24
|
-
* singular nouns should have "es" added to the end
|
|
25
|
-
*/
|
|
26
|
-
declare type PluralizeEndingSingularNoun<T extends string> = T extends `${infer HEAD}${SingularNoun}` ? `${T}es` : T;
|
|
27
|
-
/**
|
|
28
|
-
* strings which end in the letters "f" or "fe" should have "ves" replace the ending
|
|
29
|
-
*/
|
|
30
|
-
declare type PluralizeEnding_F<T extends string> = T extends `${infer HEAD}${F}` ? `${HEAD}ves` : T;
|
|
31
|
-
/**
|
|
32
|
-
* singular nouns should have "es" added to the end
|
|
33
|
-
*/
|
|
34
|
-
declare type PluralizeEndingIn_Y<T extends string> = T extends `${infer HEAD}${Y}` ? `${RemoveTrailingY<T>}ies` : T;
|
|
35
|
-
export declare type Pluralize<T extends string> = T extends isException<T> ? PluralException<T> : T extends EndsIn_IS<T> ? PluralizeEndingIn_IS<T> : T extends EndsInSingularNoun<T> ? PluralizeEndingSingularNoun<T> : T extends EndsIn_F<T> ? PluralizeEnding_F<T> : T extends EndsIn_Y<T> ? PluralizeEndingIn_Y<T> : `${T}s`;
|
|
36
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { DashUppercase, LowerAllCaps, Trim } from "../index";
|
|
2
|
-
/** convert space to dash */
|
|
3
|
-
declare type SpaceToDash<T extends string> = T extends `${infer Begin}${" "}${infer Rest}` ? SpaceToDash<`${Begin}-${Rest}`> : T;
|
|
4
|
-
/**
|
|
5
|
-
* Converts a string literal type to _snake_case_.
|
|
6
|
-
* ```ts
|
|
7
|
-
* // "foo_bar"
|
|
8
|
-
* type T = SnakeCase<"fooBar">;
|
|
9
|
-
* type T = SnakeCase<"FooBar">;
|
|
10
|
-
* type T = SnakeCase<"foo-bar">;
|
|
11
|
-
* type T = SnakeCase<"\n foo bar \t">;
|
|
12
|
-
* ``` */
|
|
13
|
-
export declare type SnakeCase<S extends string> = string extends S ? string : DashUppercase<Uncapitalize<SpaceToDash<Trim<LowerAllCaps<S>>>>> extends `${infer Begin}${"-"}${infer Rest}` ? SnakeCase<`${Lowercase<Begin>}_${Rest}`> : Lowercase<DashUppercase<Uncapitalize<Trim<LowerAllCaps<S>>>>>;
|
|
14
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export declare type LowerAlpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
2
|
-
/** Uppercase alphabetic character */
|
|
3
|
-
export declare type UpperAlpha = Uppercase<LowerAlpha>;
|
|
4
|
-
/**
|
|
5
|
-
* Alphabetical characters (upper and lower)
|
|
6
|
-
*/
|
|
7
|
-
export declare type Alpha = UpperAlpha | LowerAlpha;
|
|
8
|
-
export declare type Whitespace = " " | "\n" | "\t";
|
|
9
|
-
export declare type Punctuation = "." | "," | ";" | "!" | "?";
|
|
10
|
-
/**
|
|
11
|
-
* Characters which typically are used to separate words (but not including a space)
|
|
12
|
-
*/
|
|
13
|
-
export declare type StringDelimiter = "_" | "-" | "/" | "\\";
|
|
14
|
-
export declare type OpenningBracket = "(" | "[" | "{";
|
|
15
|
-
export declare type ClosingBracket = ")" | "]" | "}";
|
|
16
|
-
/**
|
|
17
|
-
* Openning and closing parenthesis
|
|
18
|
-
*/
|
|
19
|
-
export declare type Parenthesis = "(" | ")";
|
|
20
|
-
/**
|
|
21
|
-
* Openning and closing brackets
|
|
22
|
-
*/
|
|
23
|
-
export declare type Bracket = OpenningBracket | ClosingBracket;
|
|
24
|
-
/**
|
|
25
|
-
* Numeric string characters
|
|
26
|
-
*/
|
|
27
|
-
export declare type NumericString = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
28
|
-
/**
|
|
29
|
-
* Any alphabetic or numeric string character
|
|
30
|
-
*/
|
|
31
|
-
export declare type AlphaNumeric = Alpha | NumericString;
|
|
32
|
-
export declare type SpecialCharacters = "@" | "~" | "^" | "#" | "&" | "*";
|
|
33
|
-
/**
|
|
34
|
-
* Non-alphabetic characters including whitespace, string numerals, and
|
|
35
|
-
*/
|
|
36
|
-
export declare type NonAlpha = Whitespace | Punctuation | NumericString | Bracket | SpecialCharacters;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from "./AllCaps";
|
|
2
|
-
export * from "./CamelCase";
|
|
3
|
-
export * from "./CapFirstAlpha";
|
|
4
|
-
export * from "./CapitalizeWords";
|
|
5
|
-
export * from "./DashToSnake";
|
|
6
|
-
export * from "./DashUppercase";
|
|
7
|
-
export * from "./Dasherize";
|
|
8
|
-
export * from "./HasUppercase";
|
|
9
|
-
export * from "./Intrinsic";
|
|
10
|
-
export * from "./IsCapitalized";
|
|
11
|
-
export * from "./KebabCase";
|
|
12
|
-
export * from "./LowerAllCaps";
|
|
13
|
-
export * from "./PascalCase";
|
|
14
|
-
export * from "./Pluralize";
|
|
15
|
-
export * from "./SnakeCase";
|
|
16
|
-
export * from "./alpha-characters";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare type AppendToObject<T, U extends keyof any, V> = {
|
|
2
|
-
[K in keyof T | U]: K extends keyof T ? T[K] : V;
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* Appends a new Key/Value to an existing dictionary <T>
|
|
6
|
-
*/
|
|
7
|
-
export declare type AppendToDictionary<TDict, TKey extends string, TValue> = {
|
|
8
|
-
[K in keyof TDict | TKey]: K extends keyof TDict ? TDict[K] : TValue;
|
|
9
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the type of a property of an object:
|
|
3
|
-
* ```ts
|
|
4
|
-
* const car = { make: "Chevy", model: "Malibu", }
|
|
5
|
-
* ```
|
|
6
|
-
*/
|
|
7
|
-
export declare type Get<T, K> = K extends `${infer FK}.${infer L}` ? FK extends keyof T ? Get<T[FK], L> : never : K extends keyof T ? T[K] : never;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Get";
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* **ToFluent**
|
|
3
|
-
*
|
|
4
|
-
* Converts the typing of a dictionary of functions into the same
|
|
5
|
-
* function signatures but changes the return type to be the Fluent API.
|
|
6
|
-
*
|
|
7
|
-
* **Note:** this utility also allows a non-fluent API surface `X` to be included as
|
|
8
|
-
* part of the API surface if this is desired.
|
|
9
|
-
*/
|
|
10
|
-
export declare type ToFluent<T extends {
|
|
11
|
-
[key: string]: (...args: any[]) => any;
|
|
12
|
-
}, X extends object = {}> = {
|
|
13
|
-
[K in keyof T]: (...args: Parameters<T[K]>) => ToFluent<T, X> & X;
|
|
14
|
-
} & X;
|
|
15
|
-
/**
|
|
16
|
-
* A _pure_ Fluent API which promotes an API surface where _every_ API endpoint must be a function
|
|
17
|
-
* which returns the same API surface.
|
|
18
|
-
*
|
|
19
|
-
* To provide value, this style of Fluent API will need to perform useful _side effects_ when functions
|
|
20
|
-
* on the API surface are called as this structure does not provide any means to maintain an internal state
|
|
21
|
-
* which can be returned later.
|
|
22
|
-
*
|
|
23
|
-
* **Note:** _if you prefer a Fluent API with means to _escape_ with an internally managed state then
|
|
24
|
-
* you should prefer the use of the `FluentApi` type._
|
|
25
|
-
*/
|
|
26
|
-
export declare type PureFluentApi<TApi extends Record<string, (...args: any[]) => PureFluentApi<TApi, any>>, TExclude extends string = ""> = {
|
|
27
|
-
[P in keyof TApi]: (...args: Parameters<TApi[P]>) => PureFluentApi<Omit<TApi, TExclude>>;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Represents a **Fluent API** which exposes a API as a dictionary of functions. These functions will:
|
|
31
|
-
*
|
|
32
|
-
* 1. mutate an internal state or cause useful side-effects
|
|
33
|
-
* 2. return the same API surface
|
|
34
|
-
*
|
|
35
|
-
* While in the case where the Fluent API is used to cause useful side effects, you might only
|
|
36
|
-
* need the Fluent API surface to achieve your objectives but if instead it is used to
|
|
37
|
-
* build up a useful _internal state_, then we must allow for
|
|
38
|
-
* If this were 100% pure, however, the internal state would be unreachable and this pattern would
|
|
39
|
-
* not be very valuable. Therefore, a secondary API, is expressed which allows for non-fluent
|
|
40
|
-
*
|
|
41
|
-
* At some point the internal state will be configured "enough" and the API will be extended to allow
|
|
42
|
-
* the extraction of this state. This functional goal is expressed with the following generics:
|
|
43
|
-
*
|
|
44
|
-
* - `TFluent` is the fluent API which exposes a dictionary of functions
|
|
45
|
-
* - `TEscape` is a non-fluent API used to do whatever you like but often is the means to
|
|
46
|
-
* pass out the interior state which has been configured by the fluent parts of the API
|
|
47
|
-
* - `TExclude` represents part of the API which -- due to the internal state -- should be hidden
|
|
48
|
-
*/
|
|
49
|
-
export declare type FluentApi<TFluent extends {
|
|
50
|
-
[K in keyof TFluent]: (...args: Parameters<TFluent[K]>) => FluentApi<TFluent, TEscape>;
|
|
51
|
-
}, TEscape extends object = {}, TExclude extends string = ""> = Omit<TFluent & TEscape, TExclude>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export * from "./Api";
|
|
2
|
-
export * from "./EnumValues";
|
|
3
|
-
export * from "./ExpandRecursively";
|
|
4
|
-
export * from "./First";
|
|
5
|
-
export * from "./FunctionType";
|
|
6
|
-
export * from "./If";
|
|
7
|
-
export * from "./Include";
|
|
8
|
-
export * from "./Includes";
|
|
9
|
-
export * from "./KeyedRecord";
|
|
10
|
-
export * from "./Keys";
|
|
11
|
-
export * from "./Length";
|
|
12
|
-
export * from "./Mutable";
|
|
13
|
-
export * from "./Narrowable";
|
|
14
|
-
export * from "./Not";
|
|
15
|
-
export * from "./Numeric";
|
|
16
|
-
export * from "./Opaque";
|
|
17
|
-
export * from "./Retain";
|
|
18
|
-
export * from "./SameKeys";
|
|
19
|
-
export * from "./Transformer";
|
|
20
|
-
export * from "./TypeGuard";
|
|
21
|
-
export * from "./append-types";
|
|
22
|
-
export * from "./fluent";
|
|
23
|
-
export * from "./maybe";
|
|
24
|
-
export * from "./props";
|
|
25
|
-
export * from "./ruleset-types";
|
|
26
|
-
export * from "./runtime";
|
|
27
|
-
export * from "./type-testing";
|
|
28
|
-
export * from "./alphabetic/index";
|
|
29
|
-
export * from "./dictionary/index";
|
|
30
|
-
export * from "./kv/index";
|
|
31
|
-
export * from "./lists/index";
|
|
32
|
-
export * from "./string-literals/index";
|
|
33
|
-
export * from "./tuples/index";
|
|
34
|
-
export * from "./type-conversion/index";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ExpandRecursively } from "../ExpandRecursively";
|
|
2
|
-
/**
|
|
3
|
-
* Provides a strongly typed _key_ and _value_ for a dictionary `T`
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* type Obj = { foo: 1, bar: "hi" };
|
|
7
|
-
* // ["foo", 1 ]
|
|
8
|
-
* type Foo = KeyValue<Obj, "foo">;
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
export declare type KeyValue<T extends object, K extends keyof T> = [K & keyof T, ExpandRecursively<T[K]>];
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type utility which takes an object type and converts to an array of KV objects:
|
|
3
|
-
* ```ts
|
|
4
|
-
* // [ {key: "id", value: 123 } | {key: "foo", value: "bar" } ][]
|
|
5
|
-
* type Arr = KvFrom<{ id: 123, foo: "bar" }>;
|
|
6
|
-
* ```
|
|
7
|
-
*/
|
|
8
|
-
export declare type KvFrom<T extends object> = Array<{
|
|
9
|
-
[K in keyof T]: {
|
|
10
|
-
key: K;
|
|
11
|
-
value: T[K];
|
|
12
|
-
};
|
|
13
|
-
}[keyof T]>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* **KvTuple**
|
|
3
|
-
*
|
|
4
|
-
* a key/value of type `T` represented as `[key, kv]`
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* type Obj = { foo: 1, bar: "hi" };
|
|
8
|
-
* // ["foo", { foo: 1 } ]
|
|
9
|
-
* type Foo = KvTuple<Obj, "foo">;
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* **Note:** _consider use of `KeyValue<T,K>` as an alternate representation_
|
|
13
|
-
*/
|
|
14
|
-
export declare type KvTuple<T, K extends keyof T> = [K, Record<K, T[K]>];
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Get } from "../dictionary/Get";
|
|
2
|
-
import { Narrowable } from "../Narrowable";
|
|
3
|
-
/**
|
|
4
|
-
* Create a union type based on a given property in an array of objects
|
|
5
|
-
* ```ts
|
|
6
|
-
* const data = [
|
|
7
|
-
* { id: 123, color: "blue" },
|
|
8
|
-
* { id: 456, color: "red" },
|
|
9
|
-
* ] as const;
|
|
10
|
-
* // 123 | 456
|
|
11
|
-
* type U = UniqueForProp<typeof data, "id">;
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export declare type UniqueForProp<T extends readonly Record<string, Narrowable>[], P extends string> = Readonly<Get<T[number], P>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./UniqueForProp";
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Alpha } from "common-types";
|
|
2
|
-
/**
|
|
3
|
-
* Extracts the _required_ keys in the object's type
|
|
4
|
-
*/
|
|
5
|
-
export declare type RequiredKeys<T extends object> = {
|
|
6
|
-
[K in keyof T]-?: {} extends {
|
|
7
|
-
[P in K]: T[K];
|
|
8
|
-
} ? never : K;
|
|
9
|
-
}[keyof T];
|
|
10
|
-
/**
|
|
11
|
-
* Extracts the _optional_ keys in the object's type
|
|
12
|
-
*/
|
|
13
|
-
export declare type OptionalKeys<T extends object> = {
|
|
14
|
-
[K in keyof T]-?: {} extends {
|
|
15
|
-
[P in K]: T[K];
|
|
16
|
-
} ? K : never;
|
|
17
|
-
}[keyof T];
|
|
18
|
-
/**
|
|
19
|
-
* The _keys_ on a given object `T` which have a literal value of `W`.
|
|
20
|
-
*
|
|
21
|
-
* Optionally, you may provide a generic `E` to exclude certain keys in
|
|
22
|
-
* resultset.
|
|
23
|
-
* ```ts
|
|
24
|
-
* // "foo"
|
|
25
|
-
* type Str = KeysWithValue<{ foo: "hi"; bar: 5 }>;
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare type KeysWithValue<W extends any, T extends object> = {
|
|
29
|
-
[K in keyof T]: T[K] extends W ? Readonly<K> : never;
|
|
30
|
-
}[keyof T];
|
|
31
|
-
/**
|
|
32
|
-
* A `PrivateKey` must start with a `_` character and then follow with
|
|
33
|
-
* an alphabetic character
|
|
34
|
-
*/
|
|
35
|
-
export declare type PrivateKey = `_${Alpha}${string}`;
|
|
36
|
-
/**
|
|
37
|
-
* Keys on an object which have a `_` character as first part of the
|
|
38
|
-
* name are considered private and this utility will create a union
|
|
39
|
-
* of all the keys in this category.
|
|
40
|
-
*/
|
|
41
|
-
export declare type PrivateKeys<T extends object> = {
|
|
42
|
-
[K in keyof T]: K extends `_${string}` ? K : never;
|
|
43
|
-
}[keyof T];
|
|
44
|
-
/**
|
|
45
|
-
* **PublicKeys**
|
|
46
|
-
*
|
|
47
|
-
* Builds a union type of all keys which are "public" where a public
|
|
48
|
-
* key is any key which _does not_ start with the `_` character.
|
|
49
|
-
*/
|
|
50
|
-
export declare type PublicKeys<T extends object> = {
|
|
51
|
-
[K in keyof T]: K extends `_${string}` ? never : K;
|
|
52
|
-
}[keyof T];
|
|
53
|
-
export declare type StringKeys<T extends object> = {
|
|
54
|
-
[K in keyof T]: K extends string ? Readonly<K> : never;
|
|
55
|
-
}[keyof T];
|
|
56
|
-
/**
|
|
57
|
-
* The keys of an object which _are not_ a string type
|
|
58
|
-
*/
|
|
59
|
-
export declare type NonStringKeys<T extends object> = {
|
|
60
|
-
[K in keyof T]: K extends string ? never : Readonly<K>;
|
|
61
|
-
}[keyof T];
|
|
62
|
-
export declare type NumericKeys<T extends object> = {
|
|
63
|
-
[K in keyof T]: K extends number ? Readonly<K> : never;
|
|
64
|
-
}[keyof T];
|
|
65
|
-
export declare type NonNumericKeys<T extends object> = {
|
|
66
|
-
[K in keyof T]: K extends number ? never : Readonly<K>;
|
|
67
|
-
}[keyof T];
|
|
68
|
-
/**
|
|
69
|
-
* **RequiredProps**
|
|
70
|
-
*
|
|
71
|
-
* Reduces an object type to only key/value pairs where the key is required
|
|
72
|
-
*/
|
|
73
|
-
export declare type RequiredProps<T extends object> = Pick<T, RequiredKeys<T>>;
|
|
74
|
-
/**
|
|
75
|
-
* **OptionalProps**
|
|
76
|
-
*
|
|
77
|
-
* Reduces an object to only key/value pairs where the key is optional
|
|
78
|
-
*/
|
|
79
|
-
export declare type OptionalProps<T extends object> = Pick<T, RequiredKeys<T>>;
|
|
80
|
-
/**
|
|
81
|
-
* **WithValue**
|
|
82
|
-
*
|
|
83
|
-
* Reduces an object's type down to only those key/value pairs where the
|
|
84
|
-
* value is of type `W`.
|
|
85
|
-
* ```ts
|
|
86
|
-
* const foo = { a: 1, b: "hi", c: () => "hello" }
|
|
87
|
-
* // { c: () => "hello" }
|
|
88
|
-
* type W = WithValue<Function, typeof foo>
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
export declare type WithValue<W extends any, T extends object, E extends any = undefined> = undefined extends E ? Pick<T, KeysWithValue<W, T>> : Omit<Pick<T, KeysWithValue<W, T>>, KeysWithValue<E, T>>;
|
|
92
|
-
/**
|
|
93
|
-
* Reduces an object to only the key/value pairs where the key is a
|
|
94
|
-
* string.
|
|
95
|
-
*/
|
|
96
|
-
export declare type WithStringKeys<T extends object> = Omit<T, NonStringKeys<T>>;
|
|
97
|
-
/**
|
|
98
|
-
* Reduces an object to only the key/value pairs where the key is numeric.
|
|
99
|
-
*/
|
|
100
|
-
export declare type WithNumericKeys<T extends object> = Omit<T, NonNumericKeys<T>>;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { TypeCondition } from "../utility/runtime/ifTypeOf";
|
|
2
|
-
import { OptionalKeys } from "./props";
|
|
3
|
-
import { SameKeys } from "./SameKeys";
|
|
4
|
-
/**
|
|
5
|
-
* **RuleDefinition**
|
|
6
|
-
*
|
|
7
|
-
* A rule definition is the typing for the fluent API surface that is built up
|
|
8
|
-
* with the **ruleset** utility.
|
|
9
|
-
*/
|
|
10
|
-
export declare type RuleDefinition<
|
|
11
|
-
/** the data which will be evaluated on rule execution */
|
|
12
|
-
T extends object,
|
|
13
|
-
/** the optional props -- as a union type -- which must be defined per the rule */
|
|
14
|
-
H extends string = "",
|
|
15
|
-
/** the key/values which will be evaluated on execution (wide type) */
|
|
16
|
-
E extends Partial<SameKeys<T>> = {},
|
|
17
|
-
/** the key/values which will be evaluated on execution (narrow type) */
|
|
18
|
-
N extends Partial<SameKeys<T>> = {}> = {
|
|
19
|
-
/**
|
|
20
|
-
* sets up a true/false check that a given property is defined; this
|
|
21
|
-
* condition can only be applied to _optional_ properties.
|
|
22
|
-
*/
|
|
23
|
-
has(optProp: OptionalKeys<T>): RuleDefinition<T, H & typeof optProp, E, N>;
|
|
24
|
-
/**
|
|
25
|
-
* Validates that a given property extends a certain value's type; comparison
|
|
26
|
-
* is made assuming "wide types".
|
|
27
|
-
*/
|
|
28
|
-
equals<K extends keyof T, V extends Pick<T, K>>(prop: K, value: V): RuleDefinition<T, H, E & Record<K, V>, N>;
|
|
29
|
-
/**
|
|
30
|
-
* Validates that a given property extends a certain value's type; comparison
|
|
31
|
-
* is made assuming "narrow types". This is only available for props which
|
|
32
|
-
* expose a
|
|
33
|
-
*/
|
|
34
|
-
narrowlyEquals<K extends keyof T, V extends Pick<T, K>>(prop: K, value: V): RuleDefinition<T, H, E, N & Record<K, V>>;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* **DynamicRule**
|
|
38
|
-
*
|
|
39
|
-
* A dynamic rule allows type and runtime validation of a data structure
|
|
40
|
-
* which extends a known `State`. It then returns the literal type `true`
|
|
41
|
-
* or `false`.
|
|
42
|
-
*
|
|
43
|
-
* ```ts
|
|
44
|
-
* type State = { id?: string; favorite: boolean; color: string };
|
|
45
|
-
* // type-safe way to check whether optional prop is actually set
|
|
46
|
-
* const rule: DynamicRule<State> = s => s
|
|
47
|
-
* .has("id")
|
|
48
|
-
* .equals("favorite", true)
|
|
49
|
-
* .equals("color", "red");
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare type DynamicRule<TState extends any, TResult extends true | false> = (rule: TypeCondition<any, TState>) => TResult;
|
|
53
|
-
/**
|
|
54
|
-
* **DynamicRuleSet**
|
|
55
|
-
*
|
|
56
|
-
* A function which accepts the agreed `TState` generic as input and returns a discrete
|
|
57
|
-
* `true` or `false` value.
|
|
58
|
-
*/
|
|
59
|
-
export declare type DynamicRuleSet<TState extends any, TRules extends Record<string, TypeCondition<any, TState>>> = (rules: TRules) => true | false;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { TypeGuard } from "./index";
|
|
2
|
-
export declare type RuntimeType<T> = {
|
|
3
|
-
__kind: "type";
|
|
4
|
-
type: T;
|
|
5
|
-
is: TypeGuard<T>;
|
|
6
|
-
};
|
|
7
|
-
export declare type RuntimeProp<P extends Readonly<PropertyKey>, T extends RuntimeType<any>> = {
|
|
8
|
-
__kind: "prop";
|
|
9
|
-
key: Readonly<P>;
|
|
10
|
-
valueType: Readonly<T["type"]>;
|
|
11
|
-
/**
|
|
12
|
-
* Provides the _type_ to the type system when used with `typeof`.
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* const t = number();
|
|
16
|
-
* // number
|
|
17
|
-
* type T = typeof t.type;
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* **Note:** _the runtime system will get a string equivalent name:_
|
|
21
|
-
* ```ts
|
|
22
|
-
* const t = number();
|
|
23
|
-
* // "number"
|
|
24
|
-
* console.log(t.type);
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
type: Record<P, T["type"]>;
|
|
28
|
-
is: TypeGuard<Record<P, T["type"]>>;
|
|
29
|
-
};
|
|
30
|
-
export declare type TypeOptions<T extends Partial<object> = {}> = {
|
|
31
|
-
/** each type has a default type guard but you can override if you need to be more specific */
|
|
32
|
-
typeGuard?: TypeGuard<T>;
|
|
33
|
-
} & T;
|