mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Add memoizee definitions * Fix common issues, added doc * Removed blank line * fix test * Fix test methods * Fix check style * Fix check style * Fixing semver header * Fixing semver header * `memoizee`: Clean up types * Types 2.0 - Fix JS-quantities (#12739) * Enable strict null checking per readme FAQ. * Add tslint.json. * Improve test file with project spec. * Fix js-quantities d.ts, with adjustment of test. * Add trailing newline to tslint. * Simplify functional interface per linter. * js-quantities: add readme examples to tests * js-quantities: fix & clean declaration * d3-selection: Mark before param of insert() as optional (#13090) Selection<etc>.insert functions perfectly well without a `before` selector -- it does so in many d3 official examples. This corrects the type signature to mark it as optional. * [react-intl] bugfix for #12716 (#12906) * fix for issue introduced in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12716 * injectIntl is now usable as class decorator * fixed test * use inferface instead of type * format document * fix chai-json-schema styling (#13537) * googlemaps: Allow Marker.setAnimation(null) and Marker.setMap(null) (#13240) * googlemaps: Allow Marker.setAnimation(null) * Also, turn on strictNullChecks * Allow new google.maps.Map(null) since it's technically possible with Google's example code from the docs Signed-off-by: Iqbal Yusuf <iyusuf@corelogic.com> * googlemaps: Allow Marker.setMap(null) * Also, add more test code from the Google Maps API documentation Signed-off-by: Grant Hutchins <ghutchins@pivotal.io> * Added the brand property to the StripeCardData and fix style issues, lint (#13084) * Add the "brand" field to StipeCardData Added the StipeCardDataBrand type. Added the `brand` property to the `StripeCardData` declaration with the type `'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown'` Reference: https://stripe.com/docs/api#card_object * Run linter, fix issues. set --strictNullChecks. Unsure about ambient declaration: Removed as it seemed to be in error: 1. case was not correct 2. the export was the type of the global which is unconditionally defined. 3. this module does not seem a suitable candidate for a UMD declaration. * Use header version of 0.0; explain Stripe versioning in comments * Restore global * Added tests
174 lines
5.2 KiB
TypeScript
174 lines
5.2 KiB
TypeScript
/**
|
|
* Created by Bruno Grieder and Christian Droulers
|
|
* Updated by Fedor Nezhivoi
|
|
*/
|
|
|
|
///<reference types="react" />
|
|
|
|
import * as React from "react"
|
|
import * as reactMixin from "react-mixin"
|
|
|
|
import {
|
|
IntlProvider,
|
|
InjectedIntl,
|
|
addLocaleData,
|
|
hasLocaleData,
|
|
injectIntl,
|
|
intlShape,
|
|
defineMessages,
|
|
FormattedRelative,
|
|
FormattedMessage,
|
|
FormattedHTMLMessage,
|
|
FormattedNumber,
|
|
FormattedPlural,
|
|
FormattedDate,
|
|
FormattedTime
|
|
} from "react-intl"
|
|
|
|
import reactIntlEn = require("react-intl/locale-data/en");
|
|
|
|
addLocaleData(reactIntlEn);
|
|
console.log(hasLocaleData("en"));
|
|
|
|
interface SomeComponentProps {
|
|
className: string,
|
|
intl?: InjectedIntl
|
|
}
|
|
|
|
class SomeComponent extends React.Component<SomeComponentProps, void> {
|
|
static propTypes: React.ValidationMap<any> = {
|
|
intl: intlShape.isRequired
|
|
};
|
|
public render(): React.ReactElement<{}> {
|
|
const intl = this.props.intl;
|
|
const formattedDate = intl.formatDate(new Date(), { format: "short" });
|
|
const formattedTime = intl.formatTime(new Date(), { format: "short" });
|
|
const formattedRelative = intl.formatRelative(new Date().getTime(), { format: "short" });
|
|
const formattedNumber = intl.formatNumber(123, { format: "short" });
|
|
const formattedPlural = intl.formatPlural(1, { one: "hai!" });
|
|
const formattedMessage = intl.formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" });
|
|
const formattedHTMLMessage = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{name}</strong>!" }, { name: "Roger" });
|
|
return <div className={this.props.className}>
|
|
<FormattedRelative
|
|
value={new Date().getTime()}
|
|
units="hour"
|
|
style="numeric"
|
|
format="yyyy-MM-dd"
|
|
updateInterval={123}
|
|
initialNow={new Date()} />
|
|
|
|
<FormattedMessage
|
|
id="test"
|
|
description="Test"
|
|
defaultMessage="Hi, {name}!"
|
|
values={{ name: "bob" }}
|
|
tagName="div" />
|
|
|
|
<FormattedHTMLMessage
|
|
id="test"
|
|
description="Test"
|
|
defaultMessage="Hi, {name}!"
|
|
values={{ name: "bob" }}
|
|
tagName="div" />
|
|
|
|
<FormattedHTMLMessage
|
|
id="test"
|
|
description="Test"
|
|
defaultMessage="Hi, {name}!"
|
|
values={{ name: "bob" }}
|
|
tagName="div" />
|
|
|
|
<FormattedNumber
|
|
value={123456.78}
|
|
format="N"
|
|
localeMatcher="lookup"
|
|
style="currency"
|
|
currency="USD"
|
|
currencyDisplay="name"
|
|
useGrouping={false}
|
|
minimumIntegerDigits={1}
|
|
minimumFractionDigits={1}
|
|
minimumSignificantDigits={2}
|
|
maximumFractionDigits={3}
|
|
maximumSignificantDigits={3} />
|
|
|
|
<FormattedPlural
|
|
style="cardinal"
|
|
value={3}
|
|
other="hai?"
|
|
zero="no hai"
|
|
one="hai"
|
|
two="hai2"
|
|
few="haifew"
|
|
many="haiku" />
|
|
|
|
<FormattedDate
|
|
value={new Date()}
|
|
format="short"
|
|
localeMatcher="best fit"
|
|
formatMatcher="basic"
|
|
timeZone="EDT"
|
|
hour12={false}
|
|
weekday="short"
|
|
era="short"
|
|
year="2-digit"
|
|
month="2-digit"
|
|
day="2-digit"
|
|
hour="2-digit"
|
|
minute="2-digit"
|
|
second="2-digit"
|
|
timeZoneName="short" />
|
|
|
|
<FormattedTime
|
|
value={new Date()}
|
|
format="short"
|
|
localeMatcher="best fit"
|
|
formatMatcher="basic"
|
|
timeZone="EDT"
|
|
hour12={false}
|
|
weekday="short"
|
|
era="short"
|
|
year="2-digit"
|
|
month="2-digit"
|
|
day="2-digit"
|
|
hour="2-digit"
|
|
minute="2-digit"
|
|
second="2-digit"
|
|
timeZoneName="short" />
|
|
|
|
<FormattedNumber value={123}>
|
|
{(formattedNum: string) => (
|
|
<span className="number">{formattedNum}</span>
|
|
)}
|
|
</FormattedNumber>
|
|
</div>
|
|
}
|
|
}
|
|
|
|
const SomeComponentWithIntl = injectIntl(SomeComponent);
|
|
|
|
class TestApp extends React.Component<{}, {}> {
|
|
public render(): React.ReactElement<{}> {
|
|
const definedMessages = defineMessages({
|
|
"sup": {
|
|
id: "sup",
|
|
defaultMessage: "Hai mom"
|
|
}
|
|
});
|
|
|
|
const messages = {
|
|
"hello": "Hello, {name}!"
|
|
};
|
|
return (
|
|
<IntlProvider locale="en" formats={{}} messages={messages} defaultLocale="en" defaultFormats={messages}>
|
|
<SomeComponentWithIntl className="just-for-test" />
|
|
</IntlProvider>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default {
|
|
TestApp,
|
|
SomeComponent: SomeComponentWithIntl
|
|
}
|