typebox 1.0.62 → 1.0.64
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/build/guard/emit.mjs +1 -1
- package/build/guard/guard.mjs +2 -1
- package/build/type/action/indexed.d.mts +1 -1
- package/build/type/action/omit.d.mts +1 -1
- package/build/type/action/pick.d.mts +1 -1
- package/build/value/default/from-object.mjs +1 -1
- package/package.json +1 -1
- package/readme.md +0 -12
package/build/guard/emit.mjs
CHANGED
|
@@ -125,7 +125,7 @@ export function Keys(value) {
|
|
|
125
125
|
return `Object.getOwnPropertyNames(${value})`;
|
|
126
126
|
}
|
|
127
127
|
export function HasPropertyKey(value, key) {
|
|
128
|
-
const isProtoField = G.IsEqual(key, '"__proto__"') || G.IsEqual(key, '"
|
|
128
|
+
const isProtoField = G.IsEqual(key, '"__proto__"') || G.IsEqual(key, '"constructor"');
|
|
129
129
|
return isProtoField ? `Object.prototype.hasOwnProperty.call(${value}, ${key})` : `${key} in ${value}`;
|
|
130
130
|
}
|
|
131
131
|
export function IsDeepEqual(left, right) {
|
package/build/guard/guard.mjs
CHANGED
|
@@ -156,7 +156,8 @@ export function EveryAll(value, offset, callback) {
|
|
|
156
156
|
// --------------------------------------------------------------------------
|
|
157
157
|
/** Returns true if this value has this property key */
|
|
158
158
|
export function HasPropertyKey(value, key) {
|
|
159
|
-
|
|
159
|
+
const isProtoField = IsEqual(key, '__proto__') || IsEqual(key, 'constructor');
|
|
160
|
+
return isProtoField ? Object.prototype.hasOwnProperty.call(value, key) : key in value;
|
|
160
161
|
}
|
|
161
162
|
/** Returns object entries as `[RegExp, Value][]` */
|
|
162
163
|
export function EntriesRegExp(value) {
|
|
@@ -9,6 +9,6 @@ export declare function IndexDeferred<Type extends TSchema, Indexer extends TSch
|
|
|
9
9
|
/** Applies a Index action using the given types. */
|
|
10
10
|
export type TIndex<Type extends TSchema, Indexer extends TSchema> = (TInstantiate<{}, TIndexDeferred<Type, Indexer>>);
|
|
11
11
|
/** Applies a Index action using the given types. */
|
|
12
|
-
export declare function Index<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: [...Indexer], options?: TSchemaOptions): TIndex<Type, TKeysToIndexer<Indexer>>;
|
|
12
|
+
export declare function Index<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: readonly [...Indexer], options?: TSchemaOptions): TIndex<Type, TKeysToIndexer<Indexer>>;
|
|
13
13
|
/** Applies a Index action using the given types. */
|
|
14
14
|
export declare function Index<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer, options?: TSchemaOptions): TIndex<Type, Indexer>;
|
|
@@ -9,6 +9,6 @@ export declare function OmitDeferred<Type extends TSchema, Indexer extends TSche
|
|
|
9
9
|
/** Applies a Omit action using the given types. */
|
|
10
10
|
export type TOmit<Type extends TSchema, Indexer extends TSchema> = (TInstantiate<{}, TOmitDeferred<Type, Indexer>>);
|
|
11
11
|
/** Applies a Omit action using the given types. */
|
|
12
|
-
export declare function Omit<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: [...Indexer], options?: TSchemaOptions): TOmit<Type, TKeysToIndexer<Indexer>>;
|
|
12
|
+
export declare function Omit<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: readonly [...Indexer], options?: TSchemaOptions): TOmit<Type, TKeysToIndexer<Indexer>>;
|
|
13
13
|
/** Applies a Omit action using the given types. */
|
|
14
14
|
export declare function Omit<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer, options?: TSchemaOptions): TOmit<Type, Indexer>;
|
|
@@ -9,6 +9,6 @@ export declare function PickDeferred<Type extends TSchema, Indexer extends TSche
|
|
|
9
9
|
/** Applies a Pick action using the given types. */
|
|
10
10
|
export type TPick<Type extends TSchema, Indexer extends TSchema> = (TInstantiate<{}, TPickDeferred<Type, Indexer>>);
|
|
11
11
|
/** Applies a Pick action using the given types. */
|
|
12
|
-
export declare function Pick<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: [...Indexer], options?: TSchemaOptions): TPick<Type, TKeysToIndexer<Indexer>>;
|
|
12
|
+
export declare function Pick<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: readonly [...Indexer], options?: TSchemaOptions): TPick<Type, TKeysToIndexer<Indexer>>;
|
|
13
13
|
/** Applies a Pick action using the given types. */
|
|
14
14
|
export declare function Pick<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer, options?: TSchemaOptions): TPick<Type, Indexer>;
|
|
@@ -20,7 +20,7 @@ export function FromObject(context, type, value) {
|
|
|
20
20
|
value[key] = FromType(context, type.properties[key], value[key]);
|
|
21
21
|
}
|
|
22
22
|
// return if not additional properties
|
|
23
|
-
if (!IsAdditionalProperties(type))
|
|
23
|
+
if (!IsAdditionalProperties(type) || Guard.IsBoolean(type.additionalProperties))
|
|
24
24
|
return value;
|
|
25
25
|
// AdditionalProperties
|
|
26
26
|
for (const key of Guard.Keys(value)) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -254,18 +254,6 @@ const A = C.Parse({ // const A: {
|
|
|
254
254
|
}) // } = ...
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
-
It can also be used to accelerate remote libraries via Json Schema translation.
|
|
258
|
-
|
|
259
|
-
```typescript
|
|
260
|
-
const C = Compile(x.toJsonSchema(x.object({
|
|
261
|
-
x: x.number(),
|
|
262
|
-
y: x.number(),
|
|
263
|
-
z: x.number()
|
|
264
|
-
})))
|
|
265
|
-
|
|
266
|
-
const A = C.Check(...) // high performance runtime checking
|
|
267
|
-
```
|
|
268
|
-
|
|
269
257
|
## Contribute
|
|
270
258
|
|
|
271
259
|
TypeBox is open to community contribution. Please ensure you submit an issue before submitting a pull request. The TypeBox project prefers open community discussion before accepting new features.
|