react-intl 4.4.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,7 +51,9 @@ export function createFormattedDateTimePartsComponent(name) {
51
51
  export function createFormattedComponent(name) {
52
52
  const Component = props => (React.createElement(Context.Consumer, null, (intl) => {
53
53
  invariantIntlContext(intl);
54
- const { value, children } = props, formatProps = __rest(props, ["value", "children"]);
54
+ const { value, children } = props, formatProps = __rest(props
55
+ // TODO: fix TS type definition for localeMatcher upstream
56
+ , ["value", "children"]);
55
57
  // TODO: fix TS type definition for localeMatcher upstream
56
58
  const formattedValue = intl[name](value, formatProps);
57
59
  if (typeof children === 'function') {
package/lib/error.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MessageDescriptor } from "./types";
1
+ import { MessageDescriptor } from './types';
2
2
  export declare const enum ReactIntlErrorCode {
3
3
  FORMAT_ERROR = "FORMAT_ERROR",
4
4
  UNSUPPORTED_FORMATTER = "UNSUPPORTED_FORMATTER",
@@ -1,10 +1,7 @@
1
1
  import { getNamedFormat, filterProps } from '../utils';
2
2
  import { FormatError } from 'intl-messageformat';
3
3
  import { ReactIntlError } from '../error';
4
- const RELATIVE_TIME_FORMAT_OPTIONS = [
5
- 'numeric',
6
- 'style',
7
- ];
4
+ const RELATIVE_TIME_FORMAT_OPTIONS = ['numeric', 'style'];
8
5
  function getFormatter({ locale, formats, onError, }, getRelativeTimeFormat, options = {}) {
9
6
  const { format } = options;
10
7
  const defaults = (!!format && getNamedFormat(formats, 'relative', format, onError)) || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intl",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.",
5
5
  "keywords": [
6
6
  "intl",
@@ -131,7 +131,7 @@
131
131
  "types": "./lib/react-intl.d.ts",
132
132
  "sideEffects": false,
133
133
  "dependencies": {
134
- "@formatjs/intl-displaynames": "^1.2.4",
134
+ "@formatjs/intl-displaynames": "^1.2.5",
135
135
  "@formatjs/intl-listformat": "^1.4.4",
136
136
  "@formatjs/intl-relativetimeformat": "^4.5.12",
137
137
  "@formatjs/intl-unified-numberformat": "^3.3.3",
@@ -140,8 +140,8 @@
140
140
  "@types/invariant": "^2.2.31",
141
141
  "hoist-non-react-statics": "^3.3.2",
142
142
  "intl-format-cache": "^4.2.24",
143
- "intl-messageformat": "^8.3.6",
144
- "intl-messageformat-parser": "^4.1.4",
143
+ "intl-messageformat": "^8.3.7",
144
+ "intl-messageformat-parser": "^5.0.0",
145
145
  "shallow-equal": "^1.2.1"
146
146
  },
147
147
  "peerDependencies": {
@@ -163,26 +163,22 @@
163
163
  "@types/prop-types": "^15.7.3",
164
164
  "@types/react": "^16.9.34",
165
165
  "@types/react-dom": "^16.9.6",
166
- "@typescript-eslint/eslint-plugin": "^2.28.0",
167
- "@typescript-eslint/parser": "^2.28.0",
168
- "babel-jest": "^25.3.0",
166
+ "babel-jest": "^25.4.0",
169
167
  "benchmark": "^2.1.4",
170
168
  "core-js": "^3.6.5",
171
169
  "cross-env": "^7.0.2",
172
170
  "enzyme": "^3.11.0",
173
171
  "enzyme-adapter-react-16": "^1.15.2",
174
172
  "enzyme-to-json": "^3.4.4",
175
- "eslint": "^6.8.0",
176
- "eslint-plugin-react": "^7.19.0",
177
173
  "fs-extra": "^9.0.0",
178
174
  "full-icu": "^1.3.1",
179
175
  "glob": "^7.1.6",
180
- "jest": "^25.3.0",
176
+ "jest": "^25.4.0",
181
177
  "markdown-toc": "^1.2.0",
182
178
  "mkdirp": "^1.0.4",
183
179
  "parcel": "^1.12.4",
184
180
  "pre-commit": "^1.2.2",
185
- "prettier": "^1.19.1",
181
+ "prettier": "^2.0.0",
186
182
  "react": "^16.13.1",
187
183
  "react-dom": "^16.13.1",
188
184
  "rimraf": "^3.0.2",
@@ -191,10 +187,10 @@
191
187
  "rollup-plugin-commonjs": "^10.1.0",
192
188
  "rollup-plugin-node-resolve": "^5.2.0",
193
189
  "rollup-plugin-replace": "^2.2.0",
194
- "rollup-plugin-typescript2": "^0.26.0",
190
+ "rollup-plugin-typescript2": "^0.27.0",
195
191
  "rollup-plugin-uglify": "^6.0.4",
196
192
  "standard-version": "^7.1.0",
197
- "ts-jest": "^25.3.1",
193
+ "ts-jest": "^25.4.0",
198
194
  "ts-node": "^8.8.2",
199
195
  "tslib": "^1.11.1",
200
196
  "typescript": "3.8"
@@ -209,14 +205,12 @@
209
205
  "build": "npm run build:lib && npm run build:dts && npm run build:dist",
210
206
  "clean": "rimraf coverage/ dist/ lib/ core.js core.d.ts",
211
207
  "example": "parcel examples/index.html",
212
- "format:fix": "prettier --write {src,scripts,test,docs,examples}/**/*.{js,md,jsx,ts,tsx}",
213
- "format": "npm run format:fix -- --check",
214
- "lint:fix": "eslint src --ext .ts,.tsx --fix",
215
- "lint": "eslint src --ext .ts,.tsx",
216
- "postchangelog": "npm run toc && npm run format:fix",
208
+ "prettier": "prettier --write \"{src,scripts,test,docs,examples}/**/*\"",
209
+ "prettier:check": "prettier \"{src,scripts,test,docs,examples}/**/*\" --check",
210
+ "postchangelog": "npm run toc && npm run prettier",
217
211
  "prerelease": "npm run clean && npm run build && npm run test:all",
218
212
  "release": "standard-version",
219
- "test:all": "npm run lint && npm run format && npm run test",
213
+ "test:all": "npm run prettier:check && npm run test",
220
214
  "test:perf": "cross-env NODE_ENV=production babel-node test/perf",
221
215
  "test:watch": "cross-env NODE_ICU_DATA=./node_modules/full-icu jest --watch",
222
216
  "test": "cross-env TZ=UTC NODE_ICU_DATA=./node_modules/full-icu jest --coverage --verbose",
@@ -224,8 +218,7 @@
224
218
  },
225
219
  "pre-commit": [
226
220
  "toc",
227
- "format:fix",
228
- "lint:fix"
221
+ "prettier"
229
222
  ],
230
223
  "browserslist": [
231
224
  "ie 11"
@@ -1,13 +1,13 @@
1
- import * as React from 'react';
2
- import {invariantIntlContext} from '../utils';
1
+ import * as React from 'react'
2
+ import {invariantIntlContext} from '../utils'
3
3
  import {
4
4
  IntlShape,
5
5
  FormatDateOptions,
6
6
  FormatNumberOptions,
7
7
  FormatListOptions,
8
8
  FormatDisplayNameOptions,
9
- } from '../types';
10
- import {Context} from './injectIntl';
9
+ } from '../types'
10
+ import {Context} from './injectIntl'
11
11
 
12
12
  enum DisplayName {
13
13
  formatDate = 'FormattedDate',
@@ -27,27 +27,29 @@ enum DisplayNameParts {
27
27
  }
28
28
 
29
29
  type Formatter = {
30
- formatDate: FormatDateOptions;
31
- formatTime: FormatDateOptions;
32
- formatNumber: FormatNumberOptions;
33
- formatList: FormatListOptions;
34
- formatDisplayName: FormatDisplayNameOptions;
35
- };
30
+ formatDate: FormatDateOptions
31
+ formatTime: FormatDateOptions
32
+ formatNumber: FormatNumberOptions
33
+ formatList: FormatListOptions
34
+ formatDisplayName: FormatDisplayNameOptions
35
+ }
36
36
 
37
- export const FormattedNumberParts: React.FC<Formatter['formatNumber'] & {
38
- value: Parameters<IntlShape['formatNumber']>[0];
37
+ export const FormattedNumberParts: React.FC<
38
+ Formatter['formatNumber'] & {
39
+ value: Parameters<IntlShape['formatNumber']>[0]
39
40
 
40
- children(val: Intl.NumberFormatPart[]): React.ReactElement | null;
41
- }> = props => (
41
+ children(val: Intl.NumberFormatPart[]): React.ReactElement | null
42
+ }
43
+ > = props => (
42
44
  <Context.Consumer>
43
45
  {(intl): React.ReactElement | null => {
44
- invariantIntlContext(intl);
45
- const {value, children, ...formatProps} = props;
46
- return children(intl.formatNumberToParts(value, formatProps));
46
+ invariantIntlContext(intl)
47
+ const {value, children, ...formatProps} = props
48
+ return children(intl.formatNumberToParts(value, formatProps))
47
49
  }}
48
50
  </Context.Consumer>
49
- );
50
- FormattedNumberParts.displayName = 'FormattedNumberParts';
51
+ )
52
+ FormattedNumberParts.displayName = 'FormattedNumberParts'
51
53
 
52
54
  export function createFormattedDateTimePartsComponent<
53
55
  Name extends 'formatDate' | 'formatTime'
@@ -55,65 +57,65 @@ export function createFormattedDateTimePartsComponent<
55
57
  name: Name
56
58
  ): React.FC<
57
59
  Formatter[Name] & {
58
- value: Parameters<IntlShape[Name]>[0];
59
- children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
60
+ value: Parameters<IntlShape[Name]>[0]
61
+ children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null
60
62
  }
61
63
  > {
62
- type FormatFn = IntlShape[Name];
64
+ type FormatFn = IntlShape[Name]
63
65
  type Props = Formatter[Name] & {
64
- value: Parameters<FormatFn>[0];
65
- children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
66
- };
66
+ value: Parameters<FormatFn>[0]
67
+ children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null
68
+ }
67
69
 
68
70
  const ComponentParts: React.FC<Props> = props => (
69
71
  <Context.Consumer>
70
72
  {(intl): React.ReactElement | null => {
71
- invariantIntlContext(intl);
72
- const {value, children, ...formatProps} = props;
73
- const date = typeof value === 'string' ? new Date(value || 0) : value;
73
+ invariantIntlContext(intl)
74
+ const {value, children, ...formatProps} = props
75
+ const date = typeof value === 'string' ? new Date(value || 0) : value
74
76
  const formattedParts: Intl.DateTimeFormatPart[] =
75
77
  name === 'formatDate'
76
78
  ? intl.formatDateToParts(date, formatProps)
77
- : intl.formatTimeToParts(date, formatProps);
79
+ : intl.formatTimeToParts(date, formatProps)
78
80
 
79
- return children(formattedParts);
81
+ return children(formattedParts)
80
82
  }}
81
83
  </Context.Consumer>
82
- );
83
- ComponentParts.displayName = DisplayNameParts[name];
84
- return ComponentParts;
84
+ )
85
+ ComponentParts.displayName = DisplayNameParts[name]
86
+ return ComponentParts
85
87
  }
86
88
 
87
89
  export function createFormattedComponent<Name extends keyof Formatter>(
88
90
  name: Name
89
91
  ): React.FC<
90
92
  Formatter[Name] & {
91
- value: Parameters<IntlShape[Name]>[0];
92
- children?(val: string): React.ReactElement | null;
93
+ value: Parameters<IntlShape[Name]>[0]
94
+ children?(val: string): React.ReactElement | null
93
95
  }
94
96
  > {
95
- type FormatFn = IntlShape[Name];
97
+ type FormatFn = IntlShape[Name]
96
98
  type Props = Formatter[Name] & {
97
- value: Parameters<FormatFn>[0];
98
- children?(val: string): React.ReactElement | null;
99
- };
99
+ value: Parameters<FormatFn>[0]
100
+ children?(val: string): React.ReactElement | null
101
+ }
100
102
 
101
103
  const Component: React.FC<Props> = props => (
102
104
  <Context.Consumer>
103
105
  {(intl): JSX.Element | null => {
104
- invariantIntlContext(intl);
105
- const {value, children, ...formatProps} = props;
106
+ invariantIntlContext(intl)
107
+ const {value, children, ...formatProps} = props
106
108
  // TODO: fix TS type definition for localeMatcher upstream
107
- const formattedValue = intl[name](value as any, formatProps as any);
109
+ const formattedValue = intl[name](value as any, formatProps as any)
108
110
 
109
111
  if (typeof children === 'function') {
110
- return children(formattedValue as any);
112
+ return children(formattedValue as any)
111
113
  }
112
- const Text = intl.textComponent || React.Fragment;
113
- return <Text>{formattedValue}</Text>;
114
+ const Text = intl.textComponent || React.Fragment
115
+ return <Text>{formattedValue}</Text>
114
116
  }}
115
117
  </Context.Consumer>
116
- );
117
- Component.displayName = DisplayName[name];
118
- return Component;
118
+ )
119
+ Component.displayName = DisplayName[name]
120
+ return Component
119
121
  }
@@ -1,41 +1,41 @@
1
- import * as React from 'react';
2
- import * as hoistNonReactStatics_ from 'hoist-non-react-statics';
1
+ import * as React from 'react'
2
+ import * as hoistNonReactStatics_ from 'hoist-non-react-statics'
3
3
  // Since rollup cannot deal with namespace being a function,
4
4
  // this is to interop with TypeScript since `invariant`
5
5
  // does not export a default
6
6
  // https://github.com/rollup/rollup/issues/1267
7
7
  const hoistNonReactStatics: typeof hoistNonReactStatics_ =
8
- (hoistNonReactStatics_ as any).default || hoistNonReactStatics_;
9
- import {invariantIntlContext} from '../utils';
10
- import {IntlShape, Omit} from '../types';
8
+ (hoistNonReactStatics_ as any).default || hoistNonReactStatics_
9
+ import {invariantIntlContext} from '../utils'
10
+ import {IntlShape, Omit} from '../types'
11
11
 
12
12
  function getDisplayName(Component: React.ComponentType<any>): string {
13
- return Component.displayName || Component.name || 'Component';
13
+ return Component.displayName || Component.name || 'Component'
14
14
  }
15
15
 
16
16
  // TODO: We should provide initial value here
17
- const IntlContext = React.createContext<IntlShape>(null as any);
18
- const {Consumer: IntlConsumer, Provider: IntlProvider} = IntlContext;
17
+ const IntlContext = React.createContext<IntlShape>(null as any)
18
+ const {Consumer: IntlConsumer, Provider: IntlProvider} = IntlContext
19
19
 
20
- export const Provider = IntlProvider;
21
- export const Context = IntlContext;
20
+ export const Provider = IntlProvider
21
+ export const Context = IntlContext
22
22
 
23
23
  export interface Opts<
24
24
  IntlPropName extends string = 'intl',
25
25
  ForwardRef extends boolean = false
26
26
  > {
27
- intlPropName?: IntlPropName;
28
- forwardRef?: ForwardRef;
29
- enforceContext?: boolean;
27
+ intlPropName?: IntlPropName
28
+ forwardRef?: ForwardRef
29
+ enforceContext?: boolean
30
30
  }
31
31
 
32
32
  export type WrappedComponentProps<IntlPropName extends string = 'intl'> = {
33
- [k in IntlPropName]: IntlShape;
34
- };
33
+ [k in IntlPropName]: IntlShape
34
+ }
35
35
 
36
36
  export type WithIntlProps<P> = Omit<P, keyof WrappedComponentProps> & {
37
- forwardedRef?: React.Ref<any>;
38
- };
37
+ forwardedRef?: React.Ref<any>
38
+ }
39
39
 
40
40
  export default function injectIntl<
41
41
  IntlPropName extends string,
@@ -44,8 +44,8 @@ export default function injectIntl<
44
44
  WrappedComponent: React.ComponentType<P>,
45
45
  options?: Opts<IntlPropName, false>
46
46
  ): React.FC<WithIntlProps<P>> & {
47
- WrappedComponent: React.ComponentType<P>;
48
- };
47
+ WrappedComponent: React.ComponentType<P>
48
+ }
49
49
  export default function injectIntl<
50
50
  IntlPropName extends string = 'intl',
51
51
  P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>,
@@ -56,8 +56,8 @@ export default function injectIntl<
56
56
  ): React.ForwardRefExoticComponent<
57
57
  React.PropsWithoutRef<WithIntlProps<P>> & React.RefAttributes<T>
58
58
  > & {
59
- WrappedComponent: React.ComponentType<P>;
60
- };
59
+ WrappedComponent: React.ComponentType<P>
60
+ }
61
61
  export default function injectIntl<
62
62
  IntlPropName extends string = 'intl',
63
63
  P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>,
@@ -69,20 +69,20 @@ export default function injectIntl<
69
69
  ): React.ForwardRefExoticComponent<
70
70
  React.PropsWithoutRef<WithIntlProps<P>> & React.RefAttributes<T>
71
71
  > & {
72
- WrappedComponent: React.ComponentType<P>;
72
+ WrappedComponent: React.ComponentType<P>
73
73
  } {
74
74
  const {intlPropName = 'intl', forwardRef = false, enforceContext = true} =
75
- options || {};
75
+ options || {}
76
76
 
77
77
  const WithIntl: React.FC<P & {forwardedRef?: React.Ref<any>}> & {
78
- WrappedComponent: React.ComponentType<P>;
78
+ WrappedComponent: React.ComponentType<P>
79
79
  } = props => (
80
80
  <IntlConsumer>
81
81
  {(intl): React.ReactNode => {
82
82
  if (enforceContext) {
83
- invariantIntlContext(intl);
83
+ invariantIntlContext(intl)
84
84
  }
85
- const intlProp = {[intlPropName]: intl};
85
+ const intlProp = {[intlPropName]: intl}
86
86
 
87
87
  return (
88
88
  <WrappedComponent
@@ -90,12 +90,12 @@ export default function injectIntl<
90
90
  {...intlProp}
91
91
  ref={forwardRef ? props.forwardedRef : null}
92
92
  />
93
- );
93
+ )
94
94
  }}
95
95
  </IntlConsumer>
96
- );
97
- WithIntl.displayName = `injectIntl(${getDisplayName(WrappedComponent)})`;
98
- WithIntl.WrappedComponent = WrappedComponent;
96
+ )
97
+ WithIntl.displayName = `injectIntl(${getDisplayName(WrappedComponent)})`
98
+ WithIntl.WrappedComponent = WrappedComponent
99
99
 
100
100
  if (forwardRef) {
101
101
  return hoistNonReactStatics(
@@ -103,8 +103,8 @@ export default function injectIntl<
103
103
  <WithIntl {...props} forwardedRef={ref} />
104
104
  )),
105
105
  WrappedComponent
106
- ) as any;
106
+ ) as any
107
107
  }
108
108
 
109
- return hoistNonReactStatics(WithIntl, WrappedComponent) as any;
109
+ return hoistNonReactStatics(WithIntl, WrappedComponent) as any
110
110
  }
@@ -4,19 +4,19 @@
4
4
  * See the accompanying LICENSE file for terms.
5
5
  */
6
6
 
7
- import * as React from 'react';
8
- import {PrimitiveType, FormatXMLElementFn} from 'intl-messageformat';
9
- import {Context} from './injectIntl';
10
- import {MessageDescriptor} from '../types';
11
- import {formatMessage} from '../formatters/message';
7
+ import * as React from 'react'
8
+ import {PrimitiveType, FormatXMLElementFn} from 'intl-messageformat'
9
+ import {Context} from './injectIntl'
10
+ import {MessageDescriptor} from '../types'
11
+ import {formatMessage} from '../formatters/message'
12
12
  import {
13
13
  invariantIntlContext,
14
14
  DEFAULT_INTL_CONFIG,
15
15
  createFormatters,
16
- } from '../utils';
17
- import * as shallowEquals_ from 'shallow-equal/objects';
16
+ } from '../utils'
17
+ import * as shallowEquals_ from 'shallow-equal/objects'
18
18
  const shallowEquals: typeof shallowEquals_ =
19
- (shallowEquals_ as any).default || shallowEquals_;
19
+ (shallowEquals_ as any).default || shallowEquals_
20
20
 
21
21
  function defaultFormatMessage<T = React.ReactNode>(
22
22
  descriptor: MessageDescriptor,
@@ -28,7 +28,7 @@ function defaultFormatMessage<T = React.ReactNode>(
28
28
  if (process.env.NODE_ENV !== 'production') {
29
29
  console.error(
30
30
  '[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry. Using default message as fallback.'
31
- );
31
+ )
32
32
  }
33
33
 
34
34
  return formatMessage(
@@ -39,15 +39,15 @@ function defaultFormatMessage<T = React.ReactNode>(
39
39
  createFormatters(),
40
40
  descriptor,
41
41
  values as any
42
- );
42
+ )
43
43
  }
44
44
 
45
45
  export interface Props<
46
46
  V extends Record<string, any> = Record<string, React.ReactNode>
47
47
  > extends MessageDescriptor {
48
- values?: V;
49
- tagName?: React.ElementType<any>;
50
- children?(...nodes: React.ReactNodeArray): React.ReactNode;
48
+ values?: V
49
+ tagName?: React.ElementType<any>
50
+ children?(...nodes: React.ReactNodeArray): React.ReactNode
51
51
  }
52
52
 
53
53
  class FormattedMessage<
@@ -58,18 +58,18 @@ class FormattedMessage<
58
58
  | FormatXMLElementFn<React.ReactNode, React.ReactNode>
59
59
  >
60
60
  > extends React.Component<Props<V>> {
61
- static displayName = 'FormattedMessage';
61
+ static displayName = 'FormattedMessage'
62
62
  static defaultProps = {
63
63
  values: {},
64
- };
64
+ }
65
65
 
66
66
  shouldComponentUpdate(nextProps: Props<V>): boolean {
67
- const {values, ...otherProps} = this.props;
68
- const {values: nextValues, ...nextOtherProps} = nextProps;
67
+ const {values, ...otherProps} = this.props
68
+ const {values: nextValues, ...nextOtherProps} = nextProps
69
69
  return (
70
70
  !shallowEquals(nextValues, values) ||
71
71
  !shallowEquals(otherProps, nextOtherProps)
72
- );
72
+ )
73
73
  }
74
74
 
75
75
  render(): JSX.Element {
@@ -77,13 +77,13 @@ class FormattedMessage<
77
77
  <Context.Consumer>
78
78
  {(intl): React.ReactNode => {
79
79
  if (!this.props.defaultMessage) {
80
- invariantIntlContext(intl);
80
+ invariantIntlContext(intl)
81
81
  }
82
82
 
83
83
  const {
84
84
  formatMessage = defaultFormatMessage,
85
85
  textComponent: Text = React.Fragment,
86
- } = intl || {};
86
+ } = intl || {}
87
87
  const {
88
88
  id,
89
89
  description,
@@ -91,32 +91,32 @@ class FormattedMessage<
91
91
  values,
92
92
  children,
93
93
  tagName: Component = Text,
94
- } = this.props;
94
+ } = this.props
95
95
 
96
- const descriptor = {id, description, defaultMessage};
96
+ const descriptor = {id, description, defaultMessage}
97
97
  let nodes: string | React.ReactNodeArray = formatMessage(
98
98
  descriptor,
99
99
  values
100
- );
100
+ )
101
101
 
102
102
  if (!Array.isArray(nodes)) {
103
- nodes = [nodes];
103
+ nodes = [nodes]
104
104
  }
105
105
 
106
106
  if (typeof children === 'function') {
107
- return children(...nodes);
107
+ return children(...nodes)
108
108
  }
109
109
 
110
110
  if (Component) {
111
111
  // Needs to use `createElement()` instead of JSX, otherwise React will
112
112
  // warn about a missing `key` prop with rich-text message formatting.
113
- return React.createElement(Component, null, ...nodes);
113
+ return React.createElement(Component, null, ...nodes)
114
114
  }
115
- return nodes;
115
+ return nodes
116
116
  }}
117
117
  </Context.Consumer>
118
- );
118
+ )
119
119
  }
120
120
  }
121
121
 
122
- export default FormattedMessage;
122
+ export default FormattedMessage
@@ -4,20 +4,20 @@
4
4
  * See the accompanying LICENSE file for terms.
5
5
  */
6
6
 
7
- import * as React from 'react';
8
- import withIntl from './injectIntl';
9
- import {IntlShape, FormatPluralOptions} from '../types';
7
+ import * as React from 'react'
8
+ import withIntl from './injectIntl'
9
+ import {IntlShape, FormatPluralOptions} from '../types'
10
10
 
11
11
  interface Props extends FormatPluralOptions {
12
- value: number;
13
- intl: IntlShape;
14
- other: React.ReactNode;
15
- zero?: React.ReactNode;
16
- one?: React.ReactNode;
17
- two?: React.ReactNode;
18
- few?: React.ReactNode;
19
- many?: React.ReactNode;
20
- children?(value: React.ReactNode): React.ReactElement | null;
12
+ value: number
13
+ intl: IntlShape
14
+ other: React.ReactNode
15
+ zero?: React.ReactNode
16
+ one?: React.ReactNode
17
+ two?: React.ReactNode
18
+ few?: React.ReactNode
19
+ many?: React.ReactNode
20
+ children?(value: React.ReactNode): React.ReactElement | null
21
21
  }
22
22
 
23
23
  const FormattedPlural: React.FC<Props> = props => {
@@ -26,25 +26,25 @@ const FormattedPlural: React.FC<Props> = props => {
26
26
  other,
27
27
  children,
28
28
  intl: {formatPlural, textComponent: Text},
29
- } = props;
29
+ } = props
30
30
 
31
- const pluralCategory = formatPlural(value, props);
32
- const formattedPlural = props[pluralCategory as 'one'] || other;
31
+ const pluralCategory = formatPlural(value, props)
32
+ const formattedPlural = props[pluralCategory as 'one'] || other
33
33
 
34
34
  if (typeof children === 'function') {
35
- return children(formattedPlural);
35
+ return children(formattedPlural)
36
36
  }
37
37
  if (Text) {
38
- return <Text>{formattedPlural}</Text>;
38
+ return <Text>{formattedPlural}</Text>
39
39
  }
40
40
  // Work around @types/react where React.FC cannot return string
41
- return formattedPlural as any;
42
- };
41
+ return formattedPlural as any
42
+ }
43
43
 
44
44
  FormattedPlural.defaultProps = {
45
45
  type: 'cardinal',
46
- };
46
+ }
47
47
 
48
- FormattedPlural.displayName = 'FormattedPlural';
48
+ FormattedPlural.displayName = 'FormattedPlural'
49
49
 
50
- export default withIntl(FormattedPlural);
50
+ export default withIntl(FormattedPlural)