tsondb 0.21.0 → 0.21.1

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.
@@ -32,6 +32,10 @@ export type TypeScriptRendererOptions = {
32
32
  * @default "string"
33
33
  */
34
34
  defaultTranslationParameterType?: "string" | "StringableTranslationParameter";
35
+ /**
36
+ * New formatter types can be introduced to MF2 messages. This option allows you to specify a mapping of formatter names to their corresponding TypeScript types. For example, a list formatter could be defined as `{ list: "string[]" }`, which would infer the type of a translation parameter using the `list` formatter as `string[]`.
37
+ */
38
+ otherTypes?: Record<string, string>;
35
39
  };
36
40
  /**
37
41
  * The generated type to use for Date types. The data is always stored as a string, but Date can be helpful if you need to differenciate between a string and a date in code. Defaults to `string`.
@@ -90,6 +90,12 @@ const mapTypeNameToType = (options, typeName) => {
90
90
  return "Date";
91
91
  case null:
92
92
  default:
93
+ if (typeName !== null &&
94
+ options.inferTranslationParameters?.otherTypes !== undefined &&
95
+ typeName in options.inferTranslationParameters.otherTypes) {
96
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- already checked that the key exists
97
+ return options.inferTranslationParameters.otherTypes[typeName];
98
+ }
93
99
  return (options.inferTranslationParameters?.defaultTranslationParameterType ??
94
100
  defaultTranslationParameterType);
95
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsondb",
3
- "version": "0.21.0",
3
+ "version": "0.21.1",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Lukas Obermann",