mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-12 22:36:10 +08:00
Add properties used in tests.
Add accessor for child context. Add WrappedComponent property.
This commit is contained in:
11
react-intl/index.d.ts
vendored
11
react-intl/index.d.ts
vendored
@@ -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> {
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user