intl-messageformat 8.3.1 → 8.3.2

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.3.2](https://github.com/formatjs/formatjs/compare/intl-messageformat@8.3.1...intl-messageformat@8.3.2) (2020-03-28)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **intl-messageformat:** add FormatXMLElementFn generic return type ([9b4516c](https://github.com/formatjs/formatjs/commit/9b4516cd1be9fcc1d98fecef31949caa415530c2))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [8.3.1](https://github.com/formatjs/formatjs/compare/intl-messageformat@8.3.0...intl-messageformat@8.3.1) (2020-03-26)
7
18
 
8
19
 
package/dist/core.d.ts CHANGED
@@ -12,8 +12,8 @@ export declare class IntlMessageFormat {
12
12
  private readonly message;
13
13
  private readonly formatterCache;
14
14
  constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options);
15
- format: <T = void>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T> | null | undefined> | undefined) => string | T | (string | T)[];
16
- formatToParts: <T>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T> | null | undefined> | undefined) => MessageFormatPart<T>[];
15
+ format: <T = void>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T, string | (string | T)[]> | null | undefined> | undefined) => string | T | (string | T)[];
16
+ formatToParts: <T>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T, string | (string | T)[]> | null | undefined> | undefined) => MessageFormatPart<T>[];
17
17
  resolvedOptions: () => {
18
18
  locale: string;
19
19
  };
@@ -29,4 +29,4 @@ export interface ObjectPart<T = any> {
29
29
  export declare type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
30
30
  export declare type PrimitiveType = string | number | boolean | null | undefined | Date;
31
31
  export declare function formatToParts<T>(els: MessageFormatElement[], locales: string | string[], formatters: Formatters, formats: Formats, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, currentPluralValue?: number, originalMessage?: string): MessageFormatPart<T>[];
32
- export declare type FormatXMLElementFn<T> = (...args: Array<string | T>) => string | Array<string | T>;
32
+ export declare type FormatXMLElementFn<T, R = string | Array<string | T>> = (...args: Array<string | T>) => R;
package/lib/core.d.ts CHANGED
@@ -12,8 +12,8 @@ export declare class IntlMessageFormat {
12
12
  private readonly message;
13
13
  private readonly formatterCache;
14
14
  constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options);
15
- format: <T = void>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T> | null | undefined> | undefined) => string | T | (string | T)[];
16
- formatToParts: <T>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T> | null | undefined> | undefined) => MessageFormatPart<T>[];
15
+ format: <T = void>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T, string | (string | T)[]> | null | undefined> | undefined) => string | T | (string | T)[];
16
+ formatToParts: <T>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T, string | (string | T)[]> | null | undefined> | undefined) => MessageFormatPart<T>[];
17
17
  resolvedOptions: () => {
18
18
  locale: string;
19
19
  };
@@ -29,4 +29,4 @@ export interface ObjectPart<T = any> {
29
29
  export declare type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
30
30
  export declare type PrimitiveType = string | number | boolean | null | undefined | Date;
31
31
  export declare function formatToParts<T>(els: MessageFormatElement[], locales: string | string[], formatters: Formatters, formats: Formats, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, currentPluralValue?: number, originalMessage?: string): MessageFormatPart<T>[];
32
- export declare type FormatXMLElementFn<T> = (...args: Array<string | T>) => string | Array<string | T>;
32
+ export declare type FormatXMLElementFn<T, R = string | Array<string | T>> = (...args: Array<string | T>) => R;
@@ -43,7 +43,7 @@ export declare interface Formatters {
43
43
 
44
44
  export declare function formatToParts<T>(els: MessageFormatElement[], locales: string | string[], formatters: Formatters, formats: Formats, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, currentPluralValue?: number, originalMessage?: string): MessageFormatPart<T>[];
45
45
 
46
- export declare type FormatXMLElementFn<T> = (...args: Array<string | T>) => string | Array<string | T>;
46
+ export declare type FormatXMLElementFn<T, R = string | Array<string | T>> = (...args: Array<string | T>) => R;
47
47
 
48
48
  declare class IntlMessageFormat {
49
49
  private readonly ast;
@@ -53,8 +53,8 @@ declare class IntlMessageFormat {
53
53
  private readonly message;
54
54
  private readonly formatterCache;
55
55
  constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options);
56
- format: <T = void>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T> | null | undefined> | undefined) => string | T | (string | T)[];
57
- formatToParts: <T>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T> | null | undefined> | undefined) => MessageFormatPart<T>[];
56
+ format: <T = void>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T, string | (string | T)[]> | null | undefined> | undefined) => string | T | (string | T)[];
57
+ formatToParts: <T>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T, string | (string | T)[]> | null | undefined> | undefined) => MessageFormatPart<T>[];
58
58
  resolvedOptions: () => {
59
59
  locale: string;
60
60
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-messageformat",
3
- "version": "8.3.1",
3
+ "version": "8.3.2",
4
4
  "description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -58,5 +58,5 @@
58
58
  "test": "tests"
59
59
  },
60
60
  "license": "BSD-3-Clause",
61
- "gitHead": "db3154a5a5e23ae2a81d6b240c00d878b8225a31"
61
+ "gitHead": "33528f6975bd231fdf8635726892c98499326109"
62
62
  }
package/src/formatters.ts CHANGED
@@ -285,6 +285,6 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
285
285
  return mergeLiteral(result);
286
286
  }
287
287
 
288
- export type FormatXMLElementFn<T> = (
288
+ export type FormatXMLElementFn<T, R = string | Array<string | T>> = (
289
289
  ...args: Array<string | T>
290
- ) => string | Array<string | T>;
290
+ ) => R;