From 273d661bde9fa24d66dee8281f60368490895869 Mon Sep 17 00:00:00 2001 From: Kaixin Date: Wed, 8 Aug 2018 17:38:38 +0800 Subject: [PATCH] Support static property on component wrapper by the translate() HOC (#8) --- src/translate.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/translate.js b/src/translate.js index 35ab5e1..7477fc3 100644 --- a/src/translate.js +++ b/src/translate.js @@ -4,18 +4,20 @@ import hoistStatics from 'hoist-non-react-statics'; import type { I18nType } from '.'; import { I18nContext } from './I18nProvider'; -declare class TranslatedComponent extends React$Component { - static WrappedComponent: Class>; +declare class TranslatedComponent extends React$Component { + static WrappedComponent: Class> & $Shape; static displayName: ?string; props: OP; state: void; } -declare type TranslatedComponentClass = Class>; +declare type TranslatedComponentClass = Class>; -function translate( - WrappedComponent: React.ComponentType<$Supertype<{ i18n: I18nType } & Props>> -): TranslatedComponentClass { +function translate< + Props, + Com: React.ComponentType<$Supertype<{ i18n: I18nType } & Props>>, + ST: $Subtype<{ [_: $Keys]: any }> +>(WrappedComponent: Com): TranslatedComponentClass & ST { class Translate extends React.Component { static WrappedComponent = WrappedComponent; static displayName = `Translate(${WrappedComponent.displayName ||