typebox 1.1.5 → 1.1.6
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/type/types/base.d.mts +26 -1
- package/build/type/types/base.mjs +26 -1
- package/package.json +1 -1
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import { type TSchema } from './schema.mjs';
|
|
2
2
|
import { type XGuard, type XGuardInterface } from '../../schema/types/index.mjs';
|
|
3
3
|
export type StaticBase<Value extends unknown> = Value;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use Type.Refine() + Type.Unsafe() instead.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* **Reason:** It is noted that JavaScript class instances do not behave like
|
|
9
|
+
* plain objects during structural clone or when the TB compositor needs to
|
|
10
|
+
* assign dynamic modifier properties (such as '~optional').
|
|
11
|
+
*
|
|
12
|
+
* Because the TypeBox compositor needs to transform schematics via object clone /
|
|
13
|
+
* property spread, these operations can result in class instance types losing
|
|
14
|
+
* methods on the prototype (via clone), which can lead to unexpected structures being
|
|
15
|
+
* returned. This has led to special-case (non-clone) handling for Base which needs
|
|
16
|
+
* to be removed as it has proven orthogonal to the TypeBox 1.x design.
|
|
17
|
+
*
|
|
18
|
+
* The Base type was introduced in 1.x to try integrate / embed Standard Schema into JSON
|
|
19
|
+
* Schema; however, support for integrated Standard Schema embedding will not be continued
|
|
20
|
+
* in TypeBox. This type will be removed in the next minor revision of TypeBox.
|
|
21
|
+
*
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // (Deprecated)
|
|
24
|
+
* class DateType extends Type.Base<Date> { Check(value) { return value instanceof Date } }
|
|
25
|
+
*
|
|
26
|
+
* // (Future)
|
|
27
|
+
* const DateType = Type.Refine(Type.Unsafe<Date>({}), value => value instanceof Date)
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
5
30
|
export declare class Base<Value extends unknown = unknown> implements TSchema, XGuard<Value> {
|
|
6
31
|
readonly '~kind': 'Base';
|
|
7
32
|
readonly '~guard': XGuardInterface<Value>;
|
|
@@ -12,7 +12,32 @@ function BaseProperty(value) {
|
|
|
12
12
|
value
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use Type.Refine() + Type.Unsafe() instead.
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
* **Reason:** It is noted that JavaScript class instances do not behave like
|
|
20
|
+
* plain objects during structural clone or when the TB compositor needs to
|
|
21
|
+
* assign dynamic modifier properties (such as '~optional').
|
|
22
|
+
*
|
|
23
|
+
* Because the TypeBox compositor needs to transform schematics via object clone /
|
|
24
|
+
* property spread, these operations can result in class instance types losing
|
|
25
|
+
* methods on the prototype (via clone), which can lead to unexpected structures being
|
|
26
|
+
* returned. This has led to special-case (non-clone) handling for Base which needs
|
|
27
|
+
* to be removed as it has proven orthogonal to the TypeBox 1.x design.
|
|
28
|
+
*
|
|
29
|
+
* The Base type was introduced in 1.x to try integrate / embed Standard Schema into JSON
|
|
30
|
+
* Schema; however, support for integrated Standard Schema embedding will not be continued
|
|
31
|
+
* in TypeBox. This type will be removed in the next minor revision of TypeBox.
|
|
32
|
+
*
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // (Deprecated)
|
|
35
|
+
* class DateType extends Type.Base<Date> { Check(value) { return value instanceof Date } }
|
|
36
|
+
*
|
|
37
|
+
* // (Future)
|
|
38
|
+
* const DateType = Type.Refine(Type.Unsafe<Date>({}), value => value instanceof Date)
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
16
41
|
export class Base {
|
|
17
42
|
constructor() {
|
|
18
43
|
globalThis.Object.defineProperty(this, '~kind', BaseProperty('Base'));
|