@appnest/typed-actions
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -76,3 +76,3 @@ /** | ||
*/ | ||
export declare type OptionalSpreadTuple<T, U> = U extends void ? (T extends void ? [T?, U?] : [T, U?]) : [T, U]; | ||
export declare type OptionalSpreadTuple<T, U> = IfVoid<U, IfVoid<T, [T?, U?], [T, U?]>, [T, U]>; | ||
/** | ||
@@ -85,4 +85,10 @@ * Optional spread two generic parameters always forcing the last one to be optional. | ||
*/ | ||
export declare type OptionalSpreadTupleAlwaysOptional<T, U> = T extends void ? [T?, U?] : [T, U?]; | ||
export declare type OptionalSpreadTupleAlwaysOptional<T, U> = IfVoid<T, [T?, U?], [T, U?]>; | ||
/** | ||
* Choose the first type if T is "void". | ||
* Choose the second type if T is not "void". | ||
* Checks for undefined and null because "void" matches both. | ||
*/ | ||
export declare type IfVoid<T, VoidType, ElseType> = T extends undefined ? ElseType : (T extends null ? ElseType : (T extends void ? VoidType : ElseType)); | ||
/** | ||
* Creates an action object. | ||
@@ -126,3 +132,3 @@ * Payload and metadata is optional if their corresponding type is undefined. | ||
*/ | ||
export declare function actionCreator<Payload = P, Meta = M>(id: ActionIdType, status?: ActionStatusKind): Meta extends void ? ActionCreatorWithMeta<Payload, Meta> : ActionCreator<Payload, Meta>; | ||
export declare function actionCreator<Payload = P, Meta = M>(id: ActionIdType, status?: ActionStatusKind): IfVoid<Meta, ActionCreatorWithMeta<Payload, Meta>, ActionCreator<Payload, Meta>>; | ||
export declare function actionCreator<Payload = P, Meta = M>(id: ActionIdType, status: ActionStatusKind, defaultMeta: Meta): ActionCreatorWithMeta<Payload, Meta>; | ||
@@ -167,3 +173,3 @@ /** | ||
*/ | ||
export declare function asyncActionCreator<Start = P, Success = P, Failure = P, Meta = M>(id: ActionIdType): Meta extends void ? AsyncActionCreatorWithMeta<Start, Success, Failure, Meta> : AsyncActionCreator<Start, Success, Failure, Meta>; | ||
export declare function asyncActionCreator<Start = P, Success = P, Failure = P, Meta = M>(id: ActionIdType): IfVoid<Meta, AsyncActionCreatorWithMeta<Start, Success, Failure, Meta>, AsyncActionCreator<Start, Success, Failure, Meta>>; | ||
export declare function asyncActionCreator<Start = P, Success = P, Failure = P, Meta = M>(id: ActionIdType, defaultMeta: Meta): AsyncActionCreatorWithMeta<Start, Success, Failure, Meta>; | ||
@@ -198,3 +204,3 @@ /** | ||
*/ | ||
export declare function defaultAsyncActionCreator<Success = DefaultActionPayloadType, Meta = DefaultActionMetaType>(idOrNamespace?: ActionIdType, id?: ActionIdType): Meta extends void ? DefaultAsyncActionCreatorWithMeta<Success, Meta> : DefaultAsyncActionCreator<Success, Meta>; | ||
export declare function defaultAsyncActionCreator<Success = DefaultActionPayloadType, Meta = DefaultActionMetaType>(idOrNamespace?: ActionIdType, id?: ActionIdType): IfVoid<Meta, DefaultAsyncActionCreatorWithMeta<Success, Meta>, DefaultAsyncActionCreator<Success, Meta>>; | ||
/** | ||
@@ -201,0 +207,0 @@ * Returns a curried function with a action dispatcher function. |
@@ -76,3 +76,3 @@ /** | ||
*/ | ||
export declare type OptionalSpreadTuple<T, U> = U extends void ? (T extends void ? [T?, U?] : [T, U?]) : [T, U]; | ||
export declare type OptionalSpreadTuple<T, U> = IfVoid<U, IfVoid<T, [T?, U?], [T, U?]>, [T, U]>; | ||
/** | ||
@@ -85,4 +85,10 @@ * Optional spread two generic parameters always forcing the last one to be optional. | ||
*/ | ||
export declare type OptionalSpreadTupleAlwaysOptional<T, U> = T extends void ? [T?, U?] : [T, U?]; | ||
export declare type OptionalSpreadTupleAlwaysOptional<T, U> = IfVoid<T, [T?, U?], [T, U?]>; | ||
/** | ||
* Choose the first type if T is "void". | ||
* Choose the second type if T is not "void". | ||
* Checks for undefined and null because "void" matches both. | ||
*/ | ||
export declare type IfVoid<T, VoidType, ElseType> = T extends undefined ? ElseType : (T extends null ? ElseType : (T extends void ? VoidType : ElseType)); | ||
/** | ||
* Creates an action object. | ||
@@ -126,3 +132,3 @@ * Payload and metadata is optional if their corresponding type is undefined. | ||
*/ | ||
export declare function actionCreator<Payload = P, Meta = M>(id: ActionIdType, status?: ActionStatusKind): Meta extends void ? ActionCreatorWithMeta<Payload, Meta> : ActionCreator<Payload, Meta>; | ||
export declare function actionCreator<Payload = P, Meta = M>(id: ActionIdType, status?: ActionStatusKind): IfVoid<Meta, ActionCreatorWithMeta<Payload, Meta>, ActionCreator<Payload, Meta>>; | ||
export declare function actionCreator<Payload = P, Meta = M>(id: ActionIdType, status: ActionStatusKind, defaultMeta: Meta): ActionCreatorWithMeta<Payload, Meta>; | ||
@@ -167,3 +173,3 @@ /** | ||
*/ | ||
export declare function asyncActionCreator<Start = P, Success = P, Failure = P, Meta = M>(id: ActionIdType): Meta extends void ? AsyncActionCreatorWithMeta<Start, Success, Failure, Meta> : AsyncActionCreator<Start, Success, Failure, Meta>; | ||
export declare function asyncActionCreator<Start = P, Success = P, Failure = P, Meta = M>(id: ActionIdType): IfVoid<Meta, AsyncActionCreatorWithMeta<Start, Success, Failure, Meta>, AsyncActionCreator<Start, Success, Failure, Meta>>; | ||
export declare function asyncActionCreator<Start = P, Success = P, Failure = P, Meta = M>(id: ActionIdType, defaultMeta: Meta): AsyncActionCreatorWithMeta<Start, Success, Failure, Meta>; | ||
@@ -198,3 +204,3 @@ /** | ||
*/ | ||
export declare function defaultAsyncActionCreator<Success = DefaultActionPayloadType, Meta = DefaultActionMetaType>(idOrNamespace?: ActionIdType, id?: ActionIdType): Meta extends void ? DefaultAsyncActionCreatorWithMeta<Success, Meta> : DefaultAsyncActionCreator<Success, Meta>; | ||
export declare function defaultAsyncActionCreator<Success = DefaultActionPayloadType, Meta = DefaultActionMetaType>(idOrNamespace?: ActionIdType, id?: ActionIdType): IfVoid<Meta, DefaultAsyncActionCreatorWithMeta<Success, Meta>, DefaultAsyncActionCreator<Success, Meta>>; | ||
/** | ||
@@ -201,0 +207,0 @@ * Returns a curried function with a action dispatcher function. |
{ | ||
"name": "@appnest/typed-actions", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A lightweight library to create and type check flux/redux actions in typescript", | ||
@@ -5,0 +5,0 @@ "author": "runem", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
49879
698