mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-07 09:49:07 +00:00
add number to possible types of values passed to FormattedMessage
This commit is contained in:
Vendored
+2
-2
@@ -67,7 +67,7 @@ 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?: {[key: string]: string}) => string;
|
||||
formatMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number}) => string;
|
||||
formatHTMLMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string}) => string;
|
||||
locale: string;
|
||||
formats: any;
|
||||
@@ -136,7 +136,7 @@ declare namespace ReactIntl {
|
||||
}
|
||||
|
||||
export interface Props extends MessageDescriptor {
|
||||
values?: {[key: string]: string | JSX.Element};
|
||||
values?: {[key: string]: string | number | JSX.Element};
|
||||
tagName?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ const SomeFunctionalComponentWithIntl: React.ComponentClass<SomeComponentProps>
|
||||
const formattedNumber = formatNumber(123, { format: "short" });
|
||||
const formattedPlural = formatPlural(1, { style: "ordinal" });
|
||||
const formattedMessage = formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" });
|
||||
const formattedMessagePlurals = formatMessage({ id: "hello", defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" }, { name: "Roger", unreadCount: 123 });
|
||||
const formattedHTMLMessage = formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{name}</strong>!" }, { name: "Roger" });
|
||||
return (
|
||||
<div className={className}>
|
||||
@@ -70,6 +71,7 @@ class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlPro
|
||||
const formattedNumber = intl.formatNumber(123, { format: "short" });
|
||||
const formattedPlural = intl.formatPlural(1, { style: "ordinal" });
|
||||
const formattedMessage = intl.formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" });
|
||||
const formattedMessagePlurals = intl.formatMessage({ id: "hello", defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" }, { name: "Roger", unreadCount: 123 });
|
||||
const formattedHTMLMessage = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{name}</strong>!" }, { name: "Roger" });
|
||||
return <div className={this.props.className}>
|
||||
<FormattedRelative
|
||||
@@ -94,6 +96,20 @@ class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlPro
|
||||
values={{ name: <p>p</p> }}
|
||||
tagName="div" />
|
||||
|
||||
<FormattedMessage
|
||||
id="test"
|
||||
description="Test"
|
||||
defaultMessage="Hi numbers {count}!"
|
||||
values={{ count: 123 }}
|
||||
tagName="div" />
|
||||
|
||||
<FormattedMessage
|
||||
id="test"
|
||||
description="Test"
|
||||
defaultMessage="Hi plurals: {valueOne, number} {valueOne, plural, one {plural} other {plurals}} {valueTen, number} {valueTen, plural, one {plural} other {plurals}} !"
|
||||
values={{ valueOne: 1, valueTen: 10 }}
|
||||
tagName="div" />
|
||||
|
||||
<FormattedHTMLMessage
|
||||
id="test"
|
||||
description="Test"
|
||||
|
||||
Reference in New Issue
Block a user