typebox 1.3.20 → 1.3.21

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.
@@ -7,7 +7,19 @@ import { UnicodeRegExp } from './_regexp.mjs';
7
7
  import { EmitGuard as E, Guard as G } from '../../guard/index.mjs';
8
8
  import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from './schema.mjs';
9
9
  // ------------------------------------------------------------------
10
- // Common: GetPropertiesPattern
10
+ // Optimization: IsAdditionalPropertiesIgnored
11
+ //
12
+ // We can ignore additionalProperties if the schema is true-like and
13
+ // we are not in an unevaluated context, noting that additional
14
+ // properties are considered tracked, evaluated keys.
15
+ // ------------------------------------------------------------------
16
+ function IsAdditionalPropertiesIgnored(context, additionalProperties) {
17
+ return !context.UseUnevaluated() &&
18
+ (G.IsEqual(additionalProperties, true) ||
19
+ (G.IsObject(additionalProperties) && G.IsEqual(G.Keys(additionalProperties).length, 0)));
20
+ }
21
+ // ------------------------------------------------------------------
22
+ // Optimization: GetPropertiesPattern
11
23
  //
12
24
  // Constructs a regular expression that matches all property keys
13
25
  // and pattern properties defined in a schema. This approach unifies
@@ -71,6 +83,8 @@ export function BuildAdditionalPropertiesStandard(stack, context, schema, value)
71
83
  // Build
72
84
  // ------------------------------------------------------------------
73
85
  export function BuildAdditionalProperties(stack, context, schema, value) {
86
+ if (IsAdditionalPropertiesIgnored(context, schema.additionalProperties))
87
+ return E.Constant(true);
74
88
  return CanAdditionalPropertiesFast(context, schema, value)
75
89
  ? BuildAdditionalPropertiesFast(context, schema, value)
76
90
  : BuildAdditionalPropertiesStandard(stack, context, schema, value);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.3.20",
4
+ "version": "1.3.21",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"