@discord/intl-loader-core 0.1.0-rc.1 → 0.1.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/processing.js +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discord/intl-loader-core",
3
- "version": "0.1.0-rc.1",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "description": "Core utilities for writing loaders and transformers using @discord/intl",
6
6
  "author": "Jon Egeland",
@@ -19,7 +19,7 @@
19
19
  "chokidar": "^3.6.0",
20
20
  "debug": "^4.3.6",
21
21
  "fast-glob": "^3.3.2",
22
- "@discord/intl-message-database": "0.1.0-rc.1"
22
+ "@discord/intl-message-database": "0.1.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/debug": "^4.1.12"
package/src/processing.js CHANGED
@@ -137,18 +137,27 @@ function precompileFileForLocale(sourcePath, locale, options = {}) {
137
137
  * replaced by `.d.ts`. For example, a file like `SomeMessages.Other.messages.js` would become
138
138
  * `SomeMessages.Other.messages.d.ts`.
139
139
  *
140
+ * If `allowNullability` is set, the generated types for variables within messages will allow
141
+ * `null` and `undefined` for most value types, as well as looser restrictions on typing, such as
142
+ * allowing `string | number` for number variables.
143
+ *
140
144
  * Returns `true` if the types were successfully generated, or `false` otherwise, such as if the
141
145
  * source file is not already in the database.
142
146
  *
143
147
  * @param {string} sourcePath
144
148
  * @param {string=} outputFile
149
+ * @param {boolean=} allowNullability
145
150
  * @returns {boolean}
146
151
  */
147
- function generateTypeDefinitions(sourcePath, outputFile) {
152
+ function generateTypeDefinitions(sourcePath, outputFile, allowNullability = false) {
148
153
  const paths = database.getAllSourceFilePaths();
149
154
  if (!paths.includes(sourcePath)) return false;
150
155
 
151
- database.generateTypes(sourcePath, outputFile ?? sourcePath.replace(/\.[^.]+$/, '.d.ts'));
156
+ database.generateTypes(
157
+ sourcePath,
158
+ outputFile ?? sourcePath.replace(/\.[^.]+$/, '.d.ts'),
159
+ allowNullability,
160
+ );
152
161
  return true;
153
162
  }
154
163