Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Added typings for wrappedComponent / wrappedInstance
  • Loading branch information
mweststrate committed Mar 1, 2017
1 parent 8b5e3ab commit ffee4a3d443b9672349b2e3ac7d12ce0d4bc4d19
Showing 1 changed file with 7 additions and 3 deletions.
@@ -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>;

0 comments on commit ffee4a3

Please sign in to comment.