Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Commit

Permalink
Added typings for wrappedComponent / wrappedInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Mar 1, 2017
1 parent 8b5e3ab commit ffee4a3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/index.d.ts
Expand Up @@ -4,14 +4,18 @@
import React = require("react");

export type IStoresToProps<T, P> = (stores: any, nextProps: P, context:any) => T;
export type IReactComponent<P> = React.StatelessComponent<P> | React.ComponentClass<P>
export type IReactComponent<P> = React.StatelessComponent<P> | React.ComponentClass<P>;
export type IWrappedComponent<P> = {
wrappedComponent: IReactComponent<P>;
wrappedInstance: React.ReactElement<P>;
}

export function observer<P>(clazz: IReactComponent<P>): React.ClassicComponentClass<P>;
export function observer<P>(clazz: React.ClassicComponentClass<P>): React.ClassicComponentClass<P>;
export function observer<P, TFunction extends React.ComponentClass<P | void>>(target: TFunction): TFunction; // decorator signature

export function inject<P>(...stores: string[]): <TFunction extends IReactComponent<P>>(target: TFunction) => TFunction; // decorator signature
export function inject<T, P>(storesToProps : IStoresToProps<T, P>): <TFunction extends IReactComponent<T | P>>(target: TFunction) => TFunction; // decorator
export function inject<P>(...stores: string[]): (<TFunction extends IReactComponent<P>>(target: TFunction) => TFunction) & IWrappedComponent<P>; // decorator signature
export function inject<T, P>(storesToProps : IStoresToProps<T, P>): (<TFunction extends IReactComponent<T | P>>(target: TFunction) => TFunction) & IWrappedComponent<P>; // decorator

// Deprecated: observer with with stores
export function observer<P>(stores: string[], clazz: IReactComponent<P>): React.ClassicComponentClass<P>;
Expand Down

0 comments on commit ffee4a3

Please sign in to comment.