@naturalcycles/nodejs-lib 15.74.0 → 15.74.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.
|
@@ -157,6 +157,7 @@ export class JsonSchemaTerminal {
|
|
|
157
157
|
* Same as if it would be JSON.stringified.
|
|
158
158
|
*/
|
|
159
159
|
build() {
|
|
160
|
+
_assert(!(this.schema.optionalField && this.schema.default !== undefined), '.optional() and .default() should not be used together - the default value makes .optional() redundant and causes incorrect type inference');
|
|
160
161
|
const jsonSchema = _sortObject(JSON.parse(JSON.stringify(this.schema)), JSON_SCHEMA_ORDER);
|
|
161
162
|
delete jsonSchema.optionalField;
|
|
162
163
|
return jsonSchema;
|
package/package.json
CHANGED
|
@@ -247,6 +247,11 @@ export class JsonSchemaTerminal<IN, OUT, Opt> {
|
|
|
247
247
|
* Same as if it would be JSON.stringified.
|
|
248
248
|
*/
|
|
249
249
|
build(): JsonSchema<IN, OUT> {
|
|
250
|
+
_assert(
|
|
251
|
+
!(this.schema.optionalField && this.schema.default !== undefined),
|
|
252
|
+
'.optional() and .default() should not be used together - the default value makes .optional() redundant and causes incorrect type inference',
|
|
253
|
+
)
|
|
254
|
+
|
|
250
255
|
const jsonSchema = _sortObject(
|
|
251
256
|
JSON.parse(JSON.stringify(this.schema)),
|
|
252
257
|
JSON_SCHEMA_ORDER,
|