Skip to content

Commit dddbc04

Browse files
committed
Action Types
1 parent ae6f73e commit dddbc04

25 files changed

Lines changed: 144 additions & 52 deletions

src/type/action/awaited.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export function AwaitedDeferred<Type extends TSchema>(type: Type, options: TSche
4747
// Type
4848
// ------------------------------------------------------------------
4949
/** Applies an Awaited action to a type. */
50-
export function Awaited<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TAwaitedAction<Type> {
50+
export type TAwaited<Type extends TSchema> = (
51+
TAwaitedAction<Type>
52+
)
53+
/** Applies an Awaited action to a type. */
54+
export function Awaited<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TAwaited<Type> {
5155
return AwaitedAction(type, options)
5256
}

src/type/action/capitalize.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export function CapitalizeDeferred<Type extends TSchema>(type: Type, options: TS
4747
// Type
4848
// ------------------------------------------------------------------
4949
/** Applies a Capitalize action to the given type. */
50-
export function Capitalize<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TCapitalizeAction<Type> {
50+
export type TCapitalize<Type extends TSchema> = (
51+
TCapitalizeAction<Type>
52+
)
53+
/** Applies a Capitalize action to the given type. */
54+
export function Capitalize<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TCapitalize<Type> {
5155
return CapitalizeAction(type, options) as never
5256
}

src/type/action/conditional.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ export function ConditionalDeferred<Left extends TSchema, Right extends TSchema,
5050
// Type
5151
// ------------------------------------------------------------------
5252
/** Applies a Conditional action to the given types. */
53+
export type TConditional<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema> = (
54+
TConditionalAction<{}, { callstack: [] }, Left, Right, True, False>
55+
)
56+
/** Applies a Conditional action to the given types. */
5357
export function Conditional<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema>
54-
(left: Left, right: Right, true_: True, false_: False, options: TSchemaOptions = {}):
55-
TConditionalAction<{}, { callstack: [] }, Left, Right, True, False> {
58+
(left: Left, right: Right, true_: True, false_: False, options: TSchemaOptions = {}):
59+
TConditional<Left, Right, True, False> {
5660
return ConditionalAction({}, { callstack: [] }, left, right, true_, false_, options) as never
5761
}

src/type/action/constructor-parameters.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export function ConstructorParametersDeferred<Type extends TSchema>(type: Type,
4747
// Type
4848
// ------------------------------------------------------------------
4949
/** Applies a ConstructorParameters action to a type. */
50-
export function ConstructorParameters<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TConstructorParametersAction<Type> {
50+
export type TConstructorParameters<Type extends TSchema> = (
51+
TConstructorParametersAction<Type>
52+
)
53+
/** Applies a ConstructorParameters action to a type. */
54+
export function ConstructorParameters<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TConstructorParameters<Type> {
5155
return ConstructorParametersAction(type, options) as never
5256
}

src/type/action/evaluate.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export function EvaluateDeferred<Type extends TSchema>(type: Type, options: TSch
4747
// Type
4848
// ------------------------------------------------------------------
4949
/** Applies an Evaluate action to a type. */
50-
export function Evaluate<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TEvaluateAction<Type> {
50+
export type TEvaluate<Type extends TSchema> = (
51+
TEvaluateAction<Type>
52+
)
53+
/** Applies an Evaluate action to a type. */
54+
export function Evaluate<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TEvaluate<Type> {
5155
return EvaluateAction(type, options) as never
5256
}

src/type/action/exclude.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export function ExcludeDeferred<Left extends TSchema, Right extends TSchema>(lef
4747
// Type
4848
// ------------------------------------------------------------------
4949
/** Applies a Exclude action using the given types */
50-
export function Exclude<Left extends TSchema, Right extends TSchema>(left: Left, right: Right, options: TSchemaOptions = {}): TExcludeAction<Left, Right> {
50+
export type TExclude<Left extends TSchema, Right extends TSchema> = (
51+
TExcludeAction<Left, Right>
52+
)
53+
/** Applies a Exclude action using the given types */
54+
export function Exclude<Left extends TSchema, Right extends TSchema>(left: Left, right: Right, options: TSchemaOptions = {}): TExclude<Left, Right> {
5155
return ExcludeAction(left, right, options) as never
5256
}

src/type/action/extract.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export function ExtractDeferred<Left extends TSchema, Right extends TSchema>(lef
4747
// Type
4848
// ------------------------------------------------------------------
4949
/** Applies an Extract action using the given types. */
50-
export function Extract<Left extends TSchema, Right extends TSchema>(left: Left, right: Right, options: TSchemaOptions = {}): TExtractAction<Left, Right> {
50+
export type TExtract<Left extends TSchema, Right extends TSchema> = (
51+
TExtractAction<Left, Right>
52+
)
53+
/** Applies an Extract action using the given types. */
54+
export function Extract<Left extends TSchema, Right extends TSchema>(left: Left, right: Right, options: TSchemaOptions = {}): TExtract<Left, Right> {
5155
return ExtractAction(left, right, options) as never
5256
}

src/type/action/indexed.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ export function IndexDeferred<Type extends TSchema, Indexer extends TSchema>(typ
4949
// Index
5050
// ------------------------------------------------------------------
5151
/** Applies a Index action using the given types. */
52-
export function Index<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: readonly [...Indexer], options?: TSchemaOptions): TIndexAction<Type, TKeysToIndexer<Indexer>>
52+
export type TIndex<Type extends TSchema, Indexer extends TSchema> = (
53+
TIndexAction<Type, Indexer>
54+
)
55+
/** Applies a Index action using the given types. */
56+
export function Index<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: readonly [...Indexer], options?: TSchemaOptions): TIndex<Type, TKeysToIndexer<Indexer>>
5357
/** Applies a Index action using the given types. */
54-
export function Index<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer, options?: TSchemaOptions): TIndexAction<Type, Indexer>
58+
export function Index<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer, options?: TSchemaOptions): TIndex<Type, Indexer>
5559
/** Applies a Index action using the given types. */
5660
export function Index(type: TSchema, indexer_or_keys: PropertyKey[] | TSchema, options: TSchemaOptions = {}): never {
5761
const indexer = Guard.IsArray(indexer_or_keys) ? KeysToIndexer(indexer_or_keys as PropertyKey[]) : indexer_or_keys

src/type/action/instance-type.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export function InstanceTypeDeferred<Type extends TSchema>(type: Type, options:
4747
// Type
4848
// ------------------------------------------------------------------
4949
/** Applies a InstanceType action to the given type. */
50-
export function InstanceType<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TInstanceTypeAction<Type> {
50+
export type TInstanceType<Type extends TSchema> = (
51+
TInstanceTypeAction<Type>
52+
)
53+
/** Applies a InstanceType action to the given type. */
54+
export function InstanceType<Type extends TSchema>(type: Type, options: TSchemaOptions = {}): TInstanceType<Type> {
5155
return InstanceTypeAction(type, options) as never
5256
}

src/type/action/interface.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ export function IsInterfaceDeferred(value: unknown): value is TInterfaceDeferred
6060
// Factory
6161
// ------------------------------------------------------------------
6262
/** Creates an Interface using the given heritage and properties. */
63+
export type TInterface<Heritage extends TSchema[], Properties extends TProperties> = (
64+
TInterfaceAction<Heritage, Properties>
65+
)
66+
/** Creates an Interface using the given heritage and properties. */
6367
export function Interface<Heritage extends TSchema[], Properties extends TProperties>
6468
(heritage: [...Heritage], properties: Properties, options: TSchemaOptions = {}):
65-
TInterfaceAction<Heritage, Properties> {
69+
TInterface<Heritage, Properties> {
6670
return InterfaceAction(heritage, properties, options) as never
6771
}

0 commit comments

Comments
 (0)