@formatjs/intl 2.10.3 → 2.10.5

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.
@@ -1,11 +1,10 @@
1
- import { IntlMessageFormat, Formats, FormatXMLElementFn, FormatError, PrimitiveType, Options as IntlMessageFormatOptions } from 'intl-messageformat';
2
- import { DateTimeFormat } from '@formatjs/ecma402-abstract';
1
+ import { DateTimeFormat, NumberFormatOptions } from '@formatjs/ecma402-abstract';
3
2
  import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
4
- import IntlListFormat, { IntlListFormatOptions, Part } from '@formatjs/intl-listformat';
5
3
  import { DisplayNames, DisplayNamesOptions } from '@formatjs/intl-displaynames';
6
- import { MissingTranslationError, MessageFormatError, MissingDataError, InvalidConfigError, UnsupportedFormatterError } from './error';
4
+ import IntlListFormat, { IntlListFormatOptions, Part } from '@formatjs/intl-listformat';
5
+ import { FormatError, Formats, FormatXMLElementFn, IntlMessageFormat, Options as IntlMessageFormatOptions, PrimitiveType } from 'intl-messageformat';
6
+ import { InvalidConfigError, MessageFormatError, MissingDataError, MissingTranslationError, UnsupportedFormatterError } from './error';
7
7
  import { DEFAULT_INTL_CONFIG } from './utils';
8
- import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
9
8
  declare global {
10
9
  namespace FormatjsIntl {
11
10
  interface Message {
@@ -58,32 +57,32 @@ export type FormatDisplayNameOptions = Omit<DisplayNamesOptions, 'localeMatcher'
58
57
  * For example, with React, `TBase` should be `React.ReactNode`.
59
58
  */
60
59
  export interface IntlFormatters<TBase = unknown> {
61
- formatDateTimeRange(from: Parameters<DateTimeFormat['formatRange']>[0], to: Parameters<DateTimeFormat['formatRange']>[1], opts?: FormatDateOptions): string;
62
- formatDate(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
63
- formatTime(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
64
- formatDateToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
65
- formatTimeToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
66
- formatRelativeTime(value: Parameters<Intl.RelativeTimeFormat['format']>[0], unit?: Parameters<Intl.RelativeTimeFormat['format']>[1], opts?: FormatRelativeTimeOptions): string;
67
- formatNumber(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): string;
68
- formatNumberToParts(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
69
- formatPlural(value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>;
70
- formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
71
- formatMessage<T extends TBase>(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: IntlMessageFormatOptions): string | T | (T | string)[];
72
- $t(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
73
- $t<T extends TBase>(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: IntlMessageFormatOptions): string | T | (T | string)[];
74
- formatList(values: ReadonlyArray<string>, opts?: FormatListOptions): string;
75
- formatList<T extends TBase>(values: ReadonlyArray<string | T>, opts?: FormatListOptions): T | string | (string | T)[];
76
- formatListToParts<T extends TBase>(values: ReadonlyArray<string | T>, opts?: FormatListOptions): Part[];
77
- formatDisplayName(value: Parameters<DisplayNames['of']>[0], opts: FormatDisplayNameOptions): string | undefined;
60
+ formatDateTimeRange(this: void, from: Parameters<DateTimeFormat['formatRange']>[0], to: Parameters<DateTimeFormat['formatRange']>[1], opts?: FormatDateOptions): string;
61
+ formatDate(this: void, value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
62
+ formatTime(this: void, value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
63
+ formatDateToParts(this: void, value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
64
+ formatTimeToParts(this: void, value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
65
+ formatRelativeTime(this: void, value: Parameters<Intl.RelativeTimeFormat['format']>[0], unit?: Parameters<Intl.RelativeTimeFormat['format']>[1], opts?: FormatRelativeTimeOptions): string;
66
+ formatNumber(this: void, value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): string;
67
+ formatNumberToParts(this: void, value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
68
+ formatPlural(this: void, value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>;
69
+ formatMessage(this: void, descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
70
+ formatMessage<T extends TBase, TValue extends T | FormatXMLElementFn<T>>(this: void, descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | TValue>, opts?: IntlMessageFormatOptions): string | T | Array<string | T>;
71
+ $t(this: void, descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
72
+ $t<T extends TBase>(this: void, descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: IntlMessageFormatOptions): string | T | (T | string)[];
73
+ formatList(this: void, values: ReadonlyArray<string>, opts?: FormatListOptions): string;
74
+ formatList<T extends TBase>(this: void, values: ReadonlyArray<string | T>, opts?: FormatListOptions): T | string | (string | T)[];
75
+ formatListToParts<T extends TBase>(this: void, values: ReadonlyArray<string | T>, opts?: FormatListOptions): Part[];
76
+ formatDisplayName(this: void, value: Parameters<DisplayNames['of']>[0], opts: FormatDisplayNameOptions): string | undefined;
78
77
  }
79
78
  export interface Formatters {
80
- getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): DateTimeFormat;
81
- getNumberFormat(locales?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
82
- getMessageFormat(...args: ConstructorParameters<typeof IntlMessageFormat>): IntlMessageFormat;
83
- getRelativeTimeFormat(...args: ConstructorParameters<typeof Intl.RelativeTimeFormat>): Intl.RelativeTimeFormat;
84
- getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
85
- getListFormat(...args: ConstructorParameters<typeof IntlListFormat>): IntlListFormat;
86
- getDisplayNames(...args: ConstructorParameters<typeof DisplayNames>): DisplayNames;
79
+ getDateTimeFormat(this: void, ...args: ConstructorParameters<typeof Intl.DateTimeFormat>): DateTimeFormat;
80
+ getNumberFormat(this: void, locales?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
81
+ getMessageFormat(this: void, ...args: ConstructorParameters<typeof IntlMessageFormat>): IntlMessageFormat;
82
+ getRelativeTimeFormat(this: void, ...args: ConstructorParameters<typeof Intl.RelativeTimeFormat>): Intl.RelativeTimeFormat;
83
+ getPluralRules(this: void, ...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
84
+ getListFormat(this: void, ...args: ConstructorParameters<typeof IntlListFormat>): IntlListFormat;
85
+ getDisplayNames(this: void, ...args: ConstructorParameters<typeof DisplayNames>): DisplayNames;
87
86
  }
88
87
  export interface IntlShape<T = string> extends ResolvedIntlConfig<T>, IntlFormatters<T> {
89
88
  formatters: Formatters;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl",
3
- "version": "2.10.3",
3
+ "version": "2.10.5",
4
4
  "description": "Internationalize JS apps. This library provides an API to format dates, numbers, and strings, including pluralization and handling translations.",
5
5
  "keywords": [
6
6
  "intl",
@@ -30,16 +30,16 @@
30
30
  "sideEffects": false,
31
31
  "dependencies": {
32
32
  "tslib": "^2.4.0",
33
- "@formatjs/ecma402-abstract": "1.18.3",
34
- "@formatjs/icu-messageformat-parser": "2.7.7",
35
33
  "@formatjs/fast-memoize": "2.2.0",
36
- "@formatjs/intl-displaynames": "6.6.7",
37
- "@formatjs/intl-listformat": "7.5.6",
38
- "intl-messageformat": "10.5.13"
34
+ "@formatjs/intl-listformat": "7.5.7",
35
+ "@formatjs/ecma402-abstract": "2.0.0",
36
+ "@formatjs/icu-messageformat-parser": "2.7.8",
37
+ "@formatjs/intl-displaynames": "6.6.8",
38
+ "intl-messageformat": "10.5.14"
39
39
  },
40
40
  "devDependencies": {
41
- "@formatjs/intl-datetimeformat": "6.12.4",
42
- "@formatjs/intl-numberformat": "8.10.2"
41
+ "@formatjs/intl-datetimeformat": "6.12.5",
42
+ "@formatjs/intl-numberformat": "8.10.3"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "typescript": "^4.7 || 5"
package/src/types.d.ts CHANGED
@@ -1,11 +1,10 @@
1
- import { IntlMessageFormat, Formats, FormatXMLElementFn, FormatError, PrimitiveType, Options as IntlMessageFormatOptions } from 'intl-messageformat';
2
- import { DateTimeFormat } from '@formatjs/ecma402-abstract';
1
+ import { DateTimeFormat, NumberFormatOptions } from '@formatjs/ecma402-abstract';
3
2
  import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
4
- import IntlListFormat, { IntlListFormatOptions, Part } from '@formatjs/intl-listformat';
5
3
  import { DisplayNames, DisplayNamesOptions } from '@formatjs/intl-displaynames';
6
- import { MissingTranslationError, MessageFormatError, MissingDataError, InvalidConfigError, UnsupportedFormatterError } from './error';
4
+ import IntlListFormat, { IntlListFormatOptions, Part } from '@formatjs/intl-listformat';
5
+ import { FormatError, Formats, FormatXMLElementFn, IntlMessageFormat, Options as IntlMessageFormatOptions, PrimitiveType } from 'intl-messageformat';
6
+ import { InvalidConfigError, MessageFormatError, MissingDataError, MissingTranslationError, UnsupportedFormatterError } from './error';
7
7
  import { DEFAULT_INTL_CONFIG } from './utils';
8
- import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
9
8
  declare global {
10
9
  namespace FormatjsIntl {
11
10
  interface Message {
@@ -58,32 +57,32 @@ export type FormatDisplayNameOptions = Omit<DisplayNamesOptions, 'localeMatcher'
58
57
  * For example, with React, `TBase` should be `React.ReactNode`.
59
58
  */
60
59
  export interface IntlFormatters<TBase = unknown> {
61
- formatDateTimeRange(from: Parameters<DateTimeFormat['formatRange']>[0], to: Parameters<DateTimeFormat['formatRange']>[1], opts?: FormatDateOptions): string;
62
- formatDate(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
63
- formatTime(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
64
- formatDateToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
65
- formatTimeToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
66
- formatRelativeTime(value: Parameters<Intl.RelativeTimeFormat['format']>[0], unit?: Parameters<Intl.RelativeTimeFormat['format']>[1], opts?: FormatRelativeTimeOptions): string;
67
- formatNumber(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): string;
68
- formatNumberToParts(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
69
- formatPlural(value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>;
70
- formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
71
- formatMessage<T extends TBase>(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: IntlMessageFormatOptions): string | T | (T | string)[];
72
- $t(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
73
- $t<T extends TBase>(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: IntlMessageFormatOptions): string | T | (T | string)[];
74
- formatList(values: ReadonlyArray<string>, opts?: FormatListOptions): string;
75
- formatList<T extends TBase>(values: ReadonlyArray<string | T>, opts?: FormatListOptions): T | string | (string | T)[];
76
- formatListToParts<T extends TBase>(values: ReadonlyArray<string | T>, opts?: FormatListOptions): Part[];
77
- formatDisplayName(value: Parameters<DisplayNames['of']>[0], opts: FormatDisplayNameOptions): string | undefined;
60
+ formatDateTimeRange(this: void, from: Parameters<DateTimeFormat['formatRange']>[0], to: Parameters<DateTimeFormat['formatRange']>[1], opts?: FormatDateOptions): string;
61
+ formatDate(this: void, value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
62
+ formatTime(this: void, value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
63
+ formatDateToParts(this: void, value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
64
+ formatTimeToParts(this: void, value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
65
+ formatRelativeTime(this: void, value: Parameters<Intl.RelativeTimeFormat['format']>[0], unit?: Parameters<Intl.RelativeTimeFormat['format']>[1], opts?: FormatRelativeTimeOptions): string;
66
+ formatNumber(this: void, value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): string;
67
+ formatNumberToParts(this: void, value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
68
+ formatPlural(this: void, value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>;
69
+ formatMessage(this: void, descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
70
+ formatMessage<T extends TBase, TValue extends T | FormatXMLElementFn<T>>(this: void, descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | TValue>, opts?: IntlMessageFormatOptions): string | T | Array<string | T>;
71
+ $t(this: void, descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
72
+ $t<T extends TBase>(this: void, descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: IntlMessageFormatOptions): string | T | (T | string)[];
73
+ formatList(this: void, values: ReadonlyArray<string>, opts?: FormatListOptions): string;
74
+ formatList<T extends TBase>(this: void, values: ReadonlyArray<string | T>, opts?: FormatListOptions): T | string | (string | T)[];
75
+ formatListToParts<T extends TBase>(this: void, values: ReadonlyArray<string | T>, opts?: FormatListOptions): Part[];
76
+ formatDisplayName(this: void, value: Parameters<DisplayNames['of']>[0], opts: FormatDisplayNameOptions): string | undefined;
78
77
  }
79
78
  export interface Formatters {
80
- getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): DateTimeFormat;
81
- getNumberFormat(locales?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
82
- getMessageFormat(...args: ConstructorParameters<typeof IntlMessageFormat>): IntlMessageFormat;
83
- getRelativeTimeFormat(...args: ConstructorParameters<typeof Intl.RelativeTimeFormat>): Intl.RelativeTimeFormat;
84
- getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
85
- getListFormat(...args: ConstructorParameters<typeof IntlListFormat>): IntlListFormat;
86
- getDisplayNames(...args: ConstructorParameters<typeof DisplayNames>): DisplayNames;
79
+ getDateTimeFormat(this: void, ...args: ConstructorParameters<typeof Intl.DateTimeFormat>): DateTimeFormat;
80
+ getNumberFormat(this: void, locales?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
81
+ getMessageFormat(this: void, ...args: ConstructorParameters<typeof IntlMessageFormat>): IntlMessageFormat;
82
+ getRelativeTimeFormat(this: void, ...args: ConstructorParameters<typeof Intl.RelativeTimeFormat>): Intl.RelativeTimeFormat;
83
+ getPluralRules(this: void, ...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
84
+ getListFormat(this: void, ...args: ConstructorParameters<typeof IntlListFormat>): IntlListFormat;
85
+ getDisplayNames(this: void, ...args: ConstructorParameters<typeof DisplayNames>): DisplayNames;
87
86
  }
88
87
  export interface IntlShape<T = string> extends ResolvedIntlConfig<T>, IntlFormatters<T> {
89
88
  formatters: Formatters;