mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Simplify types
This commit is contained in:
Vendored
+10
-11
@@ -6,6 +6,10 @@
|
||||
|
||||
declare namespace ReactIntl {
|
||||
|
||||
interface Values {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
interface Locale {
|
||||
locale: string;
|
||||
fields?: { [key: string]: string },
|
||||
@@ -61,20 +65,18 @@ declare namespace ReactIntl {
|
||||
formatRelative: (value: number, options?: FormattedRelative.PropsBase & { now?: any }) => string;
|
||||
formatNumber: (value: number, options?: FormattedNumber.PropsBase) => string;
|
||||
formatPlural: (value: number, options?: FormattedPlural.Base) => keyof FormattedPlural.PropsBase;
|
||||
formatMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: any) => string;
|
||||
formatHTMLMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: any) => string;
|
||||
}
|
||||
|
||||
interface InjectedConfig {
|
||||
formatMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Values) => string;
|
||||
formatHTMLMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Values) => string;
|
||||
locale: string;
|
||||
formats: any;
|
||||
messages: { [id: string]: string };
|
||||
defaultLocale: string;
|
||||
defaultFormats: any;
|
||||
now : () => number;
|
||||
}
|
||||
|
||||
interface InjectedIntlProps {
|
||||
intl: InjectedIntl & InjectedConfig & { now : () => number };
|
||||
intl: InjectedIntl;
|
||||
}
|
||||
|
||||
namespace IntlComponent {
|
||||
@@ -103,7 +105,7 @@ declare namespace ReactIntl {
|
||||
class FormattedTime extends React.Component<FormattedTime.Props, any> { }
|
||||
|
||||
namespace FormattedRelative {
|
||||
interface Base {
|
||||
export interface PropsBase {
|
||||
/*
|
||||
* one of "second", "minute", "hour", "day", "month" or "year"
|
||||
*/
|
||||
@@ -113,9 +115,6 @@ declare namespace ReactIntl {
|
||||
*/
|
||||
style?: "best-fit" | "numeric";
|
||||
format?: string;
|
||||
}
|
||||
|
||||
export interface PropsBase extends Base {
|
||||
updateInterval?: number;
|
||||
initialNow?: any;
|
||||
}
|
||||
@@ -135,7 +134,7 @@ declare namespace ReactIntl {
|
||||
}
|
||||
|
||||
export interface Props extends MessageDescriptor {
|
||||
values?: any;
|
||||
values?: Values;
|
||||
tagName?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,22 +58,11 @@ const SomeFunctionalComponentWithIntl: React.ComponentClass<SomeComponentProps>
|
||||
);
|
||||
});
|
||||
|
||||
@injectIntl
|
||||
class SomeDecoratedComponentWithIntl extends React.Component<SomeComponentProps & InjectedIntlProps, any> {
|
||||
public render () {
|
||||
const {
|
||||
intl : { formatMessage }
|
||||
} = this.props;
|
||||
|
||||
return (<div />);
|
||||
}
|
||||
}
|
||||
|
||||
class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlProps, void> {
|
||||
static propTypes: React.ValidationMap<any> = {
|
||||
intl: intlShape.isRequired
|
||||
};
|
||||
public render(): React.ReactElement<{}> {
|
||||
render(): React.ReactElement<{}> {
|
||||
const intl = this.props.intl;
|
||||
const formattedDate = intl.formatDate(new Date(), { format: "short" });
|
||||
const formattedTime = intl.formatTime(new Date(), { format: "short" });
|
||||
@@ -182,7 +171,7 @@ class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlPro
|
||||
const SomeComponentWithIntl: React.ComponentClass<SomeComponentProps> = injectIntl(SomeComponent);
|
||||
|
||||
class TestApp extends React.Component<{}, {}> {
|
||||
public render(): React.ReactElement<{}> {
|
||||
render(): React.ReactElement<{}> {
|
||||
const definedMessages = defineMessages({
|
||||
"sup": {
|
||||
id: "sup",
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"experimentalDecorators": true
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user