mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Support for strictNullChecks
This commit is contained in:
7
types/react-intl/index.d.ts
vendored
7
types/react-intl/index.d.ts
vendored
@@ -12,6 +12,7 @@
|
||||
|
||||
declare namespace ReactIntl {
|
||||
type DateSource = Date | string | number;
|
||||
type MessageValue = string | number | boolean | Date | null | undefined;
|
||||
|
||||
interface Locale {
|
||||
locale: string;
|
||||
@@ -69,8 +70,8 @@ declare namespace ReactIntl {
|
||||
formatRelative(value: DateSource, 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 | number | boolean | Date}): string;
|
||||
formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number | boolean | Date}): string;
|
||||
formatMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: MessageValue}): string;
|
||||
formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: MessageValue}): string;
|
||||
locale: string;
|
||||
formats: any;
|
||||
messages: { [id: string]: string };
|
||||
@@ -138,7 +139,7 @@ declare namespace ReactIntl {
|
||||
}
|
||||
|
||||
interface Props extends MessageDescriptor {
|
||||
values?: {[key: string]: string | number | boolean | Date | JSX.Element};
|
||||
values?: {[key: string]: MessageValue | JSX.Element};
|
||||
tagName?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ const SomeFunctionalComponentWithIntl: React.ComponentClass<SomeComponentProps>
|
||||
const formattedRelative = formatRelative(new Date().getTime(), { format: "short" });
|
||||
const formattedNumber = formatNumber(123, { format: "short" });
|
||||
const formattedPlural = formatPlural(1, { style: "ordinal" });
|
||||
const formattedMessage = formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" });
|
||||
const formattedMessage = formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger", nullAllowed: null, undefinedAllowed: undefined });
|
||||
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" });
|
||||
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", nullAllowed: null, undefinedAllowed: undefined });
|
||||
return (
|
||||
<div className={className}>
|
||||
</div>
|
||||
@@ -136,6 +136,13 @@ class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlPro
|
||||
values={{ valueOne: 1, valueTen: 10 }}
|
||||
tagName="div" />
|
||||
|
||||
<FormattedMessage
|
||||
id="test"
|
||||
description="Test"
|
||||
defaultMessage="Hi {blank} and {empty}!"
|
||||
values={{ blank: null, empty: undefined }}
|
||||
tagName="div" />
|
||||
|
||||
<FormattedHTMLMessage
|
||||
id="test"
|
||||
description="Test"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"jsx": "react",
|
||||
@@ -22,4 +22,4 @@
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user