Skip to content

Commit

Permalink
fix(types): fix types of ofStatePart
Browse files Browse the repository at this point in the history
  • Loading branch information
megazazik committed May 14, 2020
1 parent 8cc80c1 commit 5ca883b
Showing 1 changed file with 42 additions and 33 deletions.
75 changes: 42 additions & 33 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,40 +166,49 @@ function createOnActionCallback(
};
}

export type Configs<S> = Array<AssistantConfig<Assistant<any>, S>>;

export function ofStatePart<K extends string, A extends Assistant<any>>(
select: K,
config: { new (): A }
): AssistantConfig<A, { [P in K]: StateOfAssistant<A> }>;
export function ofStatePart<NewS, A extends Assistant<any>>(
select: (s: NewS) => StateOfAssistant<A>,
config: { new (): A }
): AssistantConfig<A, NewS>;
export function ofStatePart<
K extends string,
A extends Assistant<any>,
S = StateOfAssistant<A>
>(
select: K,
config: ConstructorAssistantConfig<A, S> | CreateAssistantConfig<A, S>
): AssistantConfig<A, { [P in K]: S }>;
export function ofStatePart<
NewS,
A extends Assistant<any>,
S = StateOfAssistant<A>
>(
select: (s: NewS) => S,
config: ConstructorAssistantConfig<A, S> | CreateAssistantConfig<A, S>
): AssistantConfig<A, NewS>;
export function ofStatePart<K extends string, S>(
select: K,
configs: Configs<S>
): Configs<{ [P in K]: S }>;
export function ofStatePart<NewS, S>(
select: (s: NewS) => S,
// export type Configs<S> = Array<AssistantConfig<Assistant<any>, S>>;
export type Configs<S> = Array<AssistantConfig<Assistant<S>, any>>;

// export function ofStatePart<K extends string, A extends Assistant<any>>(
// select: K,
// config: { new (): A }
// ): AssistantConfig<A, { [P in K]: StateOfAssistant<A> }>;
// export function ofStatePart<NewS, A extends Assistant<any>>(
// select: (s: NewS) => StateOfAssistant<A>,
// config: { new (): A }
// ): AssistantConfig<A, NewS>;
// export function ofStatePart<
// K extends string,
// A extends Assistant<any>,
// S = StateOfAssistant<A>
// >(
// select: K,
// config: ConstructorAssistantConfig<A, S> | CreateAssistantConfig<A, S>
// ): AssistantConfig<A, { [P in K]: S }>;
// export function ofStatePart<
// NewS,
// A extends Assistant<any>,
// S = StateOfAssistant<A>
// >(
// select: (s: NewS) => S,
// config: ConstructorAssistantConfig<A, S> | CreateAssistantConfig<A, S>
// ): AssistantConfig<A, NewS>;
// export function ofStatePart<K extends string, S>(
// select: K,
// configs: Configs<S>
// ): Configs<{ [P in K]: S }>;
// export function ofStatePart<NewS, S>(
// select: (s: NewS) => S,
// configs: Configs<S>
// ): Configs<NewS>;
export function ofStatePart<S>(
select: ((s: any) => any) | string,
configs: Configs<S>
): Configs<NewS>;
): Configs<any>;
export function ofStatePart<S>(
select: ((s: any) => any) | string,
configs: AssistantConfig<Assistant<S>, any>
): AssistantConfig<Assistant<any>, any>;
/** Implementation */
export function ofStatePart(
select: string | ((s: any) => any),
Expand Down

0 comments on commit 5ca883b

Please sign in to comment.