Add properties used in tests.

Add accessor for child context.
Add WrappedComponent property.
This commit is contained in:
Tamlyn Rhodes
2017-03-23 14:09:02 +00:00
parent 8a308e57a7
commit e4cc71081f
2 changed files with 13 additions and 4 deletions

11
react-intl/index.d.ts vendored
View File

@@ -1,6 +1,6 @@
// Type definitions for react-intl 2.2.1
// Project: http://formatjs.io/react/
// Definitions by: Bruno Grieder <https://github.com/bgrieder>, Christian Droulers <https://github.com/cdroulers>, Fedor Nezhivoi <https://github.com/gyzerok>, Till Wolff <https://github.com/tillwolff>
// Definitions by: Bruno Grieder <https://github.com/bgrieder>, Christian Droulers <https://github.com/cdroulers>, Fedor Nezhivoi <https://github.com/gyzerok>, Till Wolff <https://github.com/tillwolff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
@@ -14,7 +14,8 @@ declare namespace ReactIntl {
pluralRuleFunction?: (n: number, ord: boolean) => string;
}
function injectIntl<T>(component: React.ComponentClass<InjectedIntlProps & T> | React.StatelessComponent<InjectedIntlProps & T>): React.ComponentClass<T>;
function injectIntl<T>(component: React.ComponentClass<InjectedIntlProps & T> | React.StatelessComponent<InjectedIntlProps & T>):
React.ComponentClass<T> & { WrappedComponent: React.ComponentClass<InjectedIntlProps & T> | React.StatelessComponent<InjectedIntlProps & T> };
function addLocaleData(data: Locale[] | Locale): void;
@@ -227,7 +228,11 @@ declare namespace ReactIntl {
defaultFormats?: Object;
}
}
class IntlProvider extends React.Component<IntlProvider.Props, any> { }
class IntlProvider extends React.Component<IntlProvider.Props, any> {
getChildContext(): {
intl: InjectedIntl;
}
}
class LocaleData extends Array<Locale> {
}

View File

@@ -168,7 +168,7 @@ class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlPro
}
}
const SomeComponentWithIntl: React.ComponentClass<SomeComponentProps> = injectIntl(SomeComponent);
const SomeComponentWithIntl = injectIntl(SomeComponent);
class TestApp extends React.Component<{}, {}> {
public render(): React.ReactElement<{}> {
@@ -191,6 +191,10 @@ class TestApp extends React.Component<{}, {}> {
}
}
const intlProvider = new IntlProvider({ locale: 'en' }, {});
const { intl } = intlProvider.getChildContext();
const wrappedComponent = <SomeComponentWithIntl.WrappedComponent className="test" intl={intl}/>
export default {
TestApp,
SomeComponent: SomeComponentWithIntl