Skip to content

Commit 6598d2e

Browse files
committed
support defining Static typings in asBaseComponent
1 parent 0d660e2 commit 6598d2e

File tree

14 files changed

+26
-14
lines changed

14 files changed

+26
-14
lines changed

generatedTypes/commons/asBaseComponent.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export interface BaseComponentInjectedProps {
66
*/
77
modifiers: ReturnType<typeof Modifiers.generateModifiersStyle>;
88
}
9-
declare function asBaseComponent<PROPS>(WrappedComponent: React.ComponentType<any>): React.ComponentType<PROPS>;
9+
declare function asBaseComponent<PROPS, STATICS = {}>(WrappedComponent: React.ComponentType<any>): React.ComponentType<PROPS> & STATICS;
1010
export default asBaseComponent;

generatedTypes/components/button/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,5 +321,5 @@ declare class Button extends PureComponent<Props, ButtonState> {
321321
render(): JSX.Element;
322322
}
323323
export { Button };
324-
declare const _default: React.ComponentType<ButtonPropTypes>;
324+
declare const _default: React.ComponentClass<ButtonPropTypes, any> | React.FunctionComponent<ButtonPropTypes>;
325325
export default _default;

generatedTypes/components/card/CardSection.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ export declare type CardSectionProps = ViewPropTypes & {
2525
*/
2626
trailingIcon?: ImageProps;
2727
};
28-
declare const _default: React.ComponentType<CardSectionProps>;
28+
declare const _default: React.ComponentClass<CardSectionProps, any> | React.FunctionComponent<CardSectionProps>;
2929
export default _default;

generatedTypes/components/card/index.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,11 @@ export declare type CardPropTypes = ViewPropTypes & TouchableOpacityProps & {
5959
hideIndicator?: boolean;
6060
};
6161
};
62-
declare const _default: React.ComponentType<CardPropTypes>;
62+
declare const _default: (React.ComponentClass<CardPropTypes, any> & {
63+
Image: React.ComponentType<import("./CardImage").CardImageProps>;
64+
Section: React.ComponentClass<import("./CardSection").CardSectionProps, any> | React.FunctionComponent<import("./CardSection").CardSectionProps>;
65+
}) | (React.FunctionComponent<CardPropTypes> & {
66+
Image: React.ComponentType<import("./CardImage").CardImageProps>;
67+
Section: React.ComponentClass<import("./CardSection").CardSectionProps, any> | React.FunctionComponent<import("./CardSection").CardSectionProps>;
68+
});
6369
export default _default;

generatedTypes/components/checkbox/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ interface CheckboxProps {
3939
style?: StyleProp<ViewStyle>;
4040
}
4141
declare type Props = CheckboxProps & TouchableOpacityProps;
42-
declare const _default: React.ComponentType<Props>;
42+
declare const _default: React.ComponentClass<Props, any> | React.FunctionComponent<Props>;
4343
export default _default;

generatedTypes/components/image/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ declare class Image extends PureComponent<Props> {
7070
render(): JSX.Element;
7171
}
7272
export { Image };
73-
declare const _default: React.ComponentType<ImageProps>;
73+
declare const _default: React.ComponentClass<ImageProps, any> | React.FunctionComponent<ImageProps>;
7474
export default _default;

generatedTypes/components/radioButton/RadioButton.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ interface RadioButtonPropTypes {
5050
*/
5151
iconOnRight?: boolean;
5252
}
53-
declare const _default: React.ComponentType<RadioButtonPropTypes>;
53+
declare const _default: React.ComponentClass<RadioButtonPropTypes, any> | React.FunctionComponent<RadioButtonPropTypes>;
5454
export default _default;

generatedTypes/components/radioButton/RadioGroup.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ interface RadioGroupPropTypes {
99
*/
1010
onValueChange?: (value: string | number | boolean) => void;
1111
}
12-
declare const _default: React.ComponentType<RadioGroupPropTypes>;
12+
declare const _default: React.ComponentClass<RadioGroupPropTypes, any> | React.FunctionComponent<RadioGroupPropTypes>;
1313
export default _default;

generatedTypes/components/text/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ declare class Text extends PureComponent<PropsTypes> {
4444
render(): JSX.Element;
4545
}
4646
export { Text };
47-
declare const _default: React.ComponentType<TextPropTypes>;
47+
declare const _default: React.ComponentClass<TextPropTypes, any> | React.FunctionComponent<TextPropTypes>;
4848
export default _default;

generatedTypes/components/touchableOpacity/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ export declare type TouchableOpacityProps = RNTouchableOpacityProps & ContainerM
2727
useNative?: boolean;
2828
ref?: any;
2929
};
30-
declare const _default: React.ComponentType<TouchableOpacityProps>;
30+
declare const _default: React.ComponentClass<TouchableOpacityProps, any> | React.FunctionComponent<TouchableOpacityProps>;
3131
export default _default;

generatedTypes/components/view/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ export interface ViewPropTypes extends ViewProps, ContainerModifiers {
2323
*/
2424
height?: string | number;
2525
}
26-
declare const _default: React.ComponentType<ViewPropTypes>;
26+
declare const _default: React.ComponentClass<ViewPropTypes, any> | React.FunctionComponent<ViewPropTypes>;
2727
export default _default;

generatedTypes/incubator/TouchableOpacity.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ declare type TouchableOpacityPropTypes = {
3838
*/
3939
style: ViewStyle;
4040
};
41-
declare const _default: React.ComponentType<TouchableOpacityPropTypes>;
41+
declare const _default: React.ComponentClass<TouchableOpacityPropTypes, any> | React.FunctionComponent<TouchableOpacityPropTypes>;
4242
export default _default;

src/commons/asBaseComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface BaseComponentInjectedProps {
1414
modifiers: ReturnType<typeof Modifiers.generateModifiersStyle>;
1515
}
1616

17-
function asBaseComponent<PROPS>(WrappedComponent: React.ComponentType<any>): React.ComponentType<PROPS> {
17+
function asBaseComponent<PROPS, STATICS = {}>(WrappedComponent: React.ComponentType<any>): React.ComponentType<PROPS> & STATICS {
1818
class BaseComponent extends UIComponent {
1919
state = Modifiers.generateModifiersStyle(undefined, BaseComponent.getThemeProps(this.props, this.context));
2020
static displayName: string | undefined;

src/components/card/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,10 @@ function createStyles({
369369
Card.Image = CardImage;
370370
Card.Section = CardSection;
371371

372-
export default asBaseComponent<CardPropTypes>(forwardRef(Card));
372+
export default asBaseComponent<
373+
CardPropTypes,
374+
{
375+
Image: typeof CardImage;
376+
Section: typeof CardSection;
377+
}
378+
>(forwardRef(Card));

0 commit comments

Comments
 (0)