typebox 1.2.19 → 1.3.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.
- package/build/compile/validator.d.mts +2 -7
- package/build/compile/validator.mjs +6 -36
- package/build/error/errors.d.mts +1 -7
- package/build/format/_idna.mjs +11 -3
- package/build/guard/emit.d.mts +0 -4
- package/build/guard/emit.mjs +0 -8
- package/build/guard/guard.d.mts +0 -4
- package/build/guard/guard.mjs +0 -8
- package/build/schema/engine/index.d.mts +0 -1
- package/build/schema/engine/index.mjs +0 -1
- package/build/schema/engine/schema.mjs +0 -5
- package/build/schema/engine/type.mjs +14 -18
- package/build/schema/types/index.d.mts +0 -1
- package/build/schema/types/index.mjs +0 -1
- package/build/system/locale/ar_001.mjs +0 -1
- package/build/system/locale/bn_BD.mjs +0 -1
- package/build/system/locale/cs_CZ.mjs +0 -1
- package/build/system/locale/de_DE.mjs +0 -1
- package/build/system/locale/el_GR.mjs +0 -1
- package/build/system/locale/en_US.mjs +0 -1
- package/build/system/locale/es_419.mjs +0 -1
- package/build/system/locale/es_AR.mjs +0 -1
- package/build/system/locale/es_ES.mjs +0 -1
- package/build/system/locale/es_MX.mjs +0 -1
- package/build/system/locale/fa_IR.mjs +0 -1
- package/build/system/locale/fil_PH.mjs +0 -1
- package/build/system/locale/fr_CA.mjs +0 -1
- package/build/system/locale/fr_FR.mjs +0 -1
- package/build/system/locale/ha_NG.mjs +0 -1
- package/build/system/locale/hi_IN.mjs +0 -1
- package/build/system/locale/hu_HU.mjs +0 -1
- package/build/system/locale/id_ID.mjs +0 -1
- package/build/system/locale/it_IT.mjs +0 -1
- package/build/system/locale/ja_JP.mjs +0 -1
- package/build/system/locale/ko_KR.mjs +0 -1
- package/build/system/locale/ms_MY.mjs +0 -1
- package/build/system/locale/nl_NL.mjs +0 -1
- package/build/system/locale/pl_PL.mjs +0 -1
- package/build/system/locale/pt_BR.mjs +0 -1
- package/build/system/locale/pt_PT.mjs +0 -1
- package/build/system/locale/ro_RO.mjs +0 -1
- package/build/system/locale/ru_RU.mjs +0 -1
- package/build/system/locale/sv_SE.mjs +0 -1
- package/build/system/locale/sw_TZ.mjs +0 -1
- package/build/system/locale/th_TH.mjs +0 -1
- package/build/system/locale/tr_TR.mjs +0 -1
- package/build/system/locale/uk_UA.mjs +0 -1
- package/build/system/locale/ur_PK.mjs +0 -1
- package/build/system/locale/vi_VN.mjs +0 -1
- package/build/system/locale/yo_NG.mjs +0 -1
- package/build/system/locale/zh_Hans.mjs +0 -1
- package/build/system/locale/zh_Hant.mjs +0 -1
- package/build/system/memory/clone.d.mts +2 -3
- package/build/system/memory/clone.mjs +73 -26
- package/build/type/action/index.d.mts +0 -1
- package/build/type/action/index.mjs +0 -1
- package/build/type/action/readonly_object.d.mts +0 -5
- package/build/type/action/readonly_object.mjs +0 -5
- package/build/type/action/with.d.mts +0 -10
- package/build/type/action/with.mjs +0 -8
- package/build/type/engine/cyclic/check.d.mts +1 -4
- package/build/type/engine/cyclic/check.mjs +9 -15
- package/build/type/engine/cyclic/dependencies.d.mts +1 -4
- package/build/type/engine/cyclic/dependencies.mjs +9 -15
- package/build/type/engine/cyclic/extends.d.mts +1 -4
- package/build/type/engine/cyclic/extends.mjs +8 -14
- package/build/type/engine/index.d.mts +0 -1
- package/build/type/engine/index.mjs +0 -1
- package/build/type/engine/instantiate.d.mts +1 -8
- package/build/type/engine/instantiate.mjs +38 -46
- package/build/type/engine/this/expand_this.d.mts +1 -4
- package/build/type/engine/this/expand_this.mjs +7 -13
- package/build/type/extends/extends_left.d.mts +1 -7
- package/build/type/extends/extends_left.mjs +23 -32
- package/build/type/script/mapping.d.mts +0 -12
- package/build/type/script/mapping.mjs +21 -25
- package/build/type/types/_refine.d.mts +0 -2
- package/build/type/types/_refine.mjs +1 -2
- package/build/type/types/index.d.mts +0 -4
- package/build/type/types/index.mjs +0 -4
- package/build/type/types/static.d.mts +1 -5
- package/build/typebox.d.mts +2 -7
- package/build/typebox.mjs +2 -7
- package/build/value/clean/from_type.mjs +8 -10
- package/build/value/clone/clone.mjs +1 -86
- package/build/value/convert/from_type.mjs +19 -21
- package/build/value/create/from_type.mjs +23 -31
- package/build/value/default/from_type.mjs +8 -10
- package/build/value/index.d.mts +0 -1
- package/build/value/index.mjs +0 -1
- package/build/value/repair/from_type.mjs +2 -12
- package/build/value/value.d.mts +0 -1
- package/build/value/value.mjs +0 -1
- package/package.json +1 -1
- package/readme.md +8 -5
- package/build/schema/engine/_guard.d.mts +0 -6
- package/build/schema/engine/_guard.mjs +0 -26
- package/build/schema/types/_guard.d.mts +0 -10
- package/build/schema/types/_guard.mjs +0 -16
- package/build/type/action/awaited.d.mts +0 -15
- package/build/type/action/awaited.mjs +0 -15
- package/build/type/engine/awaited/index.d.mts +0 -1
- package/build/type/engine/awaited/index.mjs +0 -1
- package/build/type/engine/awaited/instantiate.d.mts +0 -11
- package/build/type/engine/awaited/instantiate.mjs +0 -20
- package/build/type/extends/async_iterator.d.mts +0 -7
- package/build/type/extends/async_iterator.mjs +0 -9
- package/build/type/extends/iterator.d.mts +0 -7
- package/build/type/extends/iterator.mjs +0 -9
- package/build/type/extends/promise.d.mts +0 -7
- package/build/type/extends/promise.mjs +0 -9
- package/build/type/types/async_iterator.d.mts +0 -20
- package/build/type/types/async_iterator.mjs +0 -28
- package/build/type/types/base.d.mts +0 -50
- package/build/type/types/base.mjs +0 -84
- package/build/type/types/iterator.d.mts +0 -20
- package/build/type/types/iterator.mjs +0 -28
- package/build/type/types/promise.d.mts +0 -21
- package/build/type/types/promise.mjs +0 -29
- package/build/value/clean/from_base.d.mts +0 -2
- package/build/value/clean/from_base.mjs +0 -4
- package/build/value/convert/from_base.d.mts +0 -2
- package/build/value/convert/from_base.mjs +0 -4
- package/build/value/create/from_async_iterator.d.mts +0 -2
- package/build/value/create/from_async_iterator.mjs +0 -5
- package/build/value/create/from_base.d.mts +0 -2
- package/build/value/create/from_base.mjs +0 -4
- package/build/value/create/from_iterator.d.mts +0 -2
- package/build/value/create/from_iterator.mjs +0 -5
- package/build/value/create/from_promise.d.mts +0 -2
- package/build/value/create/from_promise.mjs +0 -5
- package/build/value/default/from_base.d.mts +0 -2
- package/build/value/default/from_base.mjs +0 -5
- package/build/value/mutate/error.d.mts +0 -3
- package/build/value/mutate/error.mjs +0 -6
- package/build/value/mutate/from_array.d.mts +0 -2
- package/build/value/mutate/from_array.mjs +0 -16
- package/build/value/mutate/from_object.d.mts +0 -2
- package/build/value/mutate/from_object.mjs +0 -40
- package/build/value/mutate/from_unknown.d.mts +0 -2
- package/build/value/mutate/from_unknown.mjs +0 -7
- package/build/value/mutate/from_value.d.mts +0 -2
- package/build/value/mutate/from_value.mjs +0 -12
- package/build/value/mutate/index.d.mts +0 -1
- package/build/value/mutate/index.mjs +0 -1
- package/build/value/mutate/mutate.d.mts +0 -11
- package/build/value/mutate/mutate.mjs +0 -41
- package/build/value/repair/from_base.d.mts +0 -2
- package/build/value/repair/from_base.mjs +0 -8
|
@@ -33,7 +33,6 @@ export function th_TH(error) {
|
|
|
33
33
|
case 'unevaluatedItems': return 'ต้องไม่มีรายการที่ยังไม่ได้ประเมิน';
|
|
34
34
|
case 'unevaluatedProperties': return 'ต้องไม่มีคุณสมบัติที่ยังไม่ได้ประเมิน';
|
|
35
35
|
case 'uniqueItems': return `ต้องไม่มีรายการที่ซ้ำกัน`;
|
|
36
|
-
case '~guard': return `ต้องตรงกับฟังก์ชันตรวจสอบ`;
|
|
37
36
|
case '~refine': return error.params.message;
|
|
38
37
|
default: return 'เกิดข้อผิดพลาดในการตรวจสอบที่ไม่รู้จัก';
|
|
39
38
|
}
|
|
@@ -33,7 +33,6 @@ export function tr_TR(error) {
|
|
|
33
33
|
case 'unevaluatedItems': return 'değerlendirilmemiş öğelere sahip olmamalıdır';
|
|
34
34
|
case 'unevaluatedProperties': return 'değerlendirilmemiş özelliklere sahip olmamalıdır';
|
|
35
35
|
case 'uniqueItems': return `yinelenen öğelere sahip olmamalıdır`;
|
|
36
|
-
case '~guard': return `kontrol fonksiyonuyla eşleşmelidir`;
|
|
37
36
|
case '~refine': return error.params.message;
|
|
38
37
|
default: return 'bilinmeyen bir doğrulama hatası oluştu';
|
|
39
38
|
}
|
|
@@ -33,7 +33,6 @@ export function uk_UA(error) {
|
|
|
33
33
|
case 'unevaluatedItems': return 'не повинно мати неперевірених елементів';
|
|
34
34
|
case 'unevaluatedProperties': return 'не повинно мати неперевірених властивостей';
|
|
35
35
|
case 'uniqueItems': return `не повинно мати повторюваних елементів`;
|
|
36
|
-
case '~guard': return `повинно відповідати функції перевірки`;
|
|
37
36
|
case '~refine': return error.params.message;
|
|
38
37
|
default: return 'виникла невідома помилка валідації';
|
|
39
38
|
}
|
|
@@ -33,7 +33,6 @@ export function ur_PK(error) {
|
|
|
33
33
|
case 'unevaluatedItems': return 'غیر تشخیص شدہ آئٹمز نہیں ہونے چاہئیں';
|
|
34
34
|
case 'unevaluatedProperties': return 'غیر تشخیص شدہ خصوصیات نہیں ہونی چاہئیں';
|
|
35
35
|
case 'uniqueItems': return `ڈپلیکیٹ آئٹمز نہیں ہونے چاہئیں`;
|
|
36
|
-
case '~guard': return `چیک فنکشن سے مطابقت ہونی چاہیے`;
|
|
37
36
|
case '~refine': return error.params.message;
|
|
38
37
|
default: return 'تصدیق میں ایک نامعلوم خرابی پیش آئی';
|
|
39
38
|
}
|
|
@@ -33,7 +33,6 @@ export function vi_VN(error) {
|
|
|
33
33
|
case 'unevaluatedItems': return 'không được có các mục chưa được đánh giá';
|
|
34
34
|
case 'unevaluatedProperties': return 'không được có các thuộc tính chưa được đánh giá';
|
|
35
35
|
case 'uniqueItems': return `không được có các mục trùng lặp`;
|
|
36
|
-
case '~guard': return `phải khớp với hàm kiểm tra`;
|
|
37
36
|
case '~refine': return error.params.message;
|
|
38
37
|
default: return 'đã xảy ra lỗi xác thực không xác định';
|
|
39
38
|
}
|
|
@@ -33,7 +33,6 @@ export function yo_NG(error) {
|
|
|
33
33
|
case 'unevaluatedItems': return 'ko gbọdọ ni awọn ohun ti ko ṣe iṣiro';
|
|
34
34
|
case 'unevaluatedProperties': return 'ko gbọdọ ni awọn ohun-ini ti ko ṣe iṣiro';
|
|
35
35
|
case 'uniqueItems': return `ko gbọdọ ni awọn ohun elo ẹda`;
|
|
36
|
-
case '~guard': return `gbogbo yẹ ki o ba iṣẹ́ ṣàyẹ̀wò mu`;
|
|
37
36
|
case '~refine': return error.params.message;
|
|
38
37
|
default: return 'aṣiṣe ijẹrisi aimọ waye';
|
|
39
38
|
}
|
|
@@ -33,7 +33,6 @@ export function zh_Hans(error) {
|
|
|
33
33
|
case 'unevaluatedItems': return '不得有未评估的项';
|
|
34
34
|
case 'unevaluatedProperties': return '不得有未评估的属性';
|
|
35
35
|
case 'uniqueItems': return `不得有重复项`;
|
|
36
|
-
case '~guard': return `必须与检查函数匹配`;
|
|
37
36
|
case '~refine': return error.params.message;
|
|
38
37
|
default: return '发生未知验证错误';
|
|
39
38
|
}
|
|
@@ -33,7 +33,6 @@ export function zh_Hant(error) {
|
|
|
33
33
|
case 'unevaluatedItems': return '不得有未評估的項目';
|
|
34
34
|
case 'unevaluatedProperties': return '不得有未評估的屬性';
|
|
35
35
|
case 'uniqueItems': return `不得有重複項目`;
|
|
36
|
-
case '~guard': return `必須與檢查函數匹配`;
|
|
37
36
|
case '~refine': return error.params.message;
|
|
38
37
|
default: return '發生未知驗證錯誤';
|
|
39
38
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* hidden properties.
|
|
2
|
+
* Returns a Clone of the given value. This function is similar to structuredClone()
|
|
3
|
+
* but also supports deep cloning instances of Map, Set and TypeArray.
|
|
5
4
|
*/
|
|
6
5
|
export declare function Clone<Value extends unknown = unknown>(value: Value): Value;
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import { Guard } from '../../guard/index.mjs';
|
|
2
|
+
import { Guard, GlobalsGuard } from '../../guard/index.mjs';
|
|
3
3
|
import { Metrics } from './metrics.mjs';
|
|
4
4
|
// ------------------------------------------------------------------
|
|
5
|
-
//
|
|
5
|
+
// ClassInstance
|
|
6
|
+
//
|
|
7
|
+
// TypeBox does not clone arbitrary class instances. Class instances
|
|
8
|
+
// cannot be safely cloned without potentially breaking private
|
|
9
|
+
// members of the instance.
|
|
10
|
+
//
|
|
6
11
|
// ------------------------------------------------------------------
|
|
7
|
-
function
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
function FromGuard(value) {
|
|
11
|
-
return value; // non-clonable
|
|
12
|
+
function FromClassInstance(value) {
|
|
13
|
+
return value; // atomic
|
|
12
14
|
}
|
|
13
15
|
// ------------------------------------------------------------------
|
|
14
|
-
//
|
|
16
|
+
// TypeObject
|
|
17
|
+
//
|
|
18
|
+
// Types have non-enumerable properties that MUST be preserved on Clone.
|
|
19
|
+
// The following is the optimal path for TypeBox types.
|
|
15
20
|
// ------------------------------------------------------------------
|
|
16
|
-
function
|
|
17
|
-
return
|
|
21
|
+
function IsTypeObject(value) {
|
|
22
|
+
return (Guard.HasPropertyKey(value, '~kind') ||
|
|
23
|
+
Guard.HasPropertyKey(value, '~unsafe'));
|
|
18
24
|
}
|
|
19
|
-
|
|
20
|
-
// Object
|
|
21
|
-
// ------------------------------------------------------------------
|
|
22
|
-
function FromObject(value) {
|
|
25
|
+
function FromTypeObject(value) {
|
|
23
26
|
const result = {};
|
|
24
27
|
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
25
28
|
for (const key of Object.keys(descriptors)) {
|
|
29
|
+
if (Guard.IsUnsafePropertyKey(key))
|
|
30
|
+
continue; // (ignore: prototype-pollution)
|
|
26
31
|
const descriptor = descriptors[key];
|
|
27
32
|
if (Guard.HasPropertyKey(descriptor, 'value')) {
|
|
28
33
|
Object.defineProperty(result, key, { ...descriptor, value: FromValue(descriptor.value) });
|
|
@@ -31,31 +36,73 @@ function FromObject(value) {
|
|
|
31
36
|
return result;
|
|
32
37
|
}
|
|
33
38
|
// ------------------------------------------------------------------
|
|
39
|
+
// PlainObject
|
|
40
|
+
// ------------------------------------------------------------------
|
|
41
|
+
function FromPlainObject(value) {
|
|
42
|
+
const result = {};
|
|
43
|
+
for (const key of Guard.Keys(value)) {
|
|
44
|
+
if (Guard.IsUnsafePropertyKey(key))
|
|
45
|
+
continue; // (ignore: prototype-pollution)
|
|
46
|
+
result[key] = FromValue(value[key]);
|
|
47
|
+
}
|
|
48
|
+
for (const key of Guard.Symbols(value)) {
|
|
49
|
+
result[key] = FromValue(value[key]);
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
// ------------------------------------------------------------------
|
|
54
|
+
// Object
|
|
55
|
+
// ------------------------------------------------------------------
|
|
56
|
+
function FromObject(value) {
|
|
57
|
+
return (Guard.IsClassInstance(value) ? FromClassInstance(value) :
|
|
58
|
+
IsTypeObject(value) ? FromTypeObject(value) :
|
|
59
|
+
FromPlainObject(value));
|
|
60
|
+
}
|
|
61
|
+
// ------------------------------------------------------------------
|
|
62
|
+
// Array
|
|
63
|
+
// ------------------------------------------------------------------
|
|
64
|
+
function FromArray(value) {
|
|
65
|
+
return value.map((element) => FromValue(element));
|
|
66
|
+
}
|
|
67
|
+
// ------------------------------------------------------------------
|
|
68
|
+
// TypeArray
|
|
69
|
+
// ------------------------------------------------------------------
|
|
70
|
+
function FromTypedArray(value) {
|
|
71
|
+
return value.slice();
|
|
72
|
+
}
|
|
73
|
+
// ------------------------------------------------------------------
|
|
34
74
|
// RegExp
|
|
35
75
|
// ------------------------------------------------------------------
|
|
36
76
|
function FromRegExp(value) {
|
|
37
77
|
return new RegExp(value.source, value.flags);
|
|
38
78
|
}
|
|
39
79
|
// ------------------------------------------------------------------
|
|
40
|
-
//
|
|
80
|
+
// Map
|
|
41
81
|
// ------------------------------------------------------------------
|
|
42
|
-
function
|
|
43
|
-
return value;
|
|
82
|
+
function FromMap(value) {
|
|
83
|
+
return new Map(FromValue([...value.entries()]));
|
|
44
84
|
}
|
|
45
85
|
// ------------------------------------------------------------------
|
|
46
|
-
//
|
|
86
|
+
// Set
|
|
47
87
|
// ------------------------------------------------------------------
|
|
88
|
+
function FromSet(value) {
|
|
89
|
+
return new Set(FromValue([...value.values()]));
|
|
90
|
+
}
|
|
48
91
|
function FromValue(value) {
|
|
49
|
-
return (value
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
92
|
+
return (GlobalsGuard.IsTypeArray(value) ? FromTypedArray(value) :
|
|
93
|
+
GlobalsGuard.IsRegExp(value) ? FromRegExp(value) :
|
|
94
|
+
GlobalsGuard.IsMap(value) ? FromMap(value) :
|
|
95
|
+
GlobalsGuard.IsSet(value) ? FromSet(value) :
|
|
96
|
+
Guard.IsArray(value) ? FromArray(value) :
|
|
97
|
+
Guard.IsObject(value) ? FromObject(value) :
|
|
98
|
+
value);
|
|
54
99
|
}
|
|
100
|
+
// ------------------------------------------------------------------
|
|
101
|
+
// Clone
|
|
102
|
+
// ------------------------------------------------------------------
|
|
55
103
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* hidden properties.
|
|
104
|
+
* Returns a Clone of the given value. This function is similar to structuredClone()
|
|
105
|
+
* but also supports deep cloning instances of Map, Set and TypeArray.
|
|
59
106
|
*/
|
|
60
107
|
export function Clone(value) {
|
|
61
108
|
Metrics.clone += 1;
|
|
@@ -4,7 +4,6 @@ export * from './_add_optional.mjs';
|
|
|
4
4
|
export * from './_remove_immutable.mjs';
|
|
5
5
|
export * from './_remove_readonly.mjs';
|
|
6
6
|
export * from './_remove_optional.mjs';
|
|
7
|
-
export * from './awaited.mjs';
|
|
8
7
|
export * from './capitalize.mjs';
|
|
9
8
|
export * from './conditional.mjs';
|
|
10
9
|
export * from './constructor_parameters.mjs';
|
|
@@ -4,7 +4,6 @@ export * from './_add_optional.mjs';
|
|
|
4
4
|
export * from './_remove_immutable.mjs';
|
|
5
5
|
export * from './_remove_readonly.mjs';
|
|
6
6
|
export * from './_remove_optional.mjs';
|
|
7
|
-
export * from './awaited.mjs';
|
|
8
7
|
export * from './capitalize.mjs';
|
|
9
8
|
export * from './conditional.mjs';
|
|
10
9
|
export * from './constructor_parameters.mjs';
|
|
@@ -9,8 +9,3 @@ export declare function ReadonlyObjectDeferred<Type extends TSchema>(type: Type,
|
|
|
9
9
|
export type TReadonlyObject<Type extends TSchema> = (TReadonlyObjectAction<Type>);
|
|
10
10
|
/** This type is an alias for TypeScript's `Readonly<T>` utility type. It will make all properties of a TObject readonly or marks an TArray or TTuple as immutable `readonly T[]`. */
|
|
11
11
|
export declare function ReadonlyObject<Type extends TSchema>(type: Type, options?: TSchemaOptions): TReadonlyObject<Type>;
|
|
12
|
-
/**
|
|
13
|
-
* This type has been renamed to ReadonlyObject.
|
|
14
|
-
* @deprecated
|
|
15
|
-
*/
|
|
16
|
-
export declare const ReadonlyType: typeof ReadonlyObject;
|
|
@@ -9,8 +9,3 @@ export function ReadonlyObjectDeferred(type, options = {}) {
|
|
|
9
9
|
export function ReadonlyObject(type, options = {}) {
|
|
10
10
|
return ReadonlyObjectAction(type, options);
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* This type has been renamed to ReadonlyObject.
|
|
14
|
-
* @deprecated
|
|
15
|
-
*/
|
|
16
|
-
export const ReadonlyType = ReadonlyObject;
|
|
@@ -9,13 +9,3 @@ export declare function WithDeferred<Type extends TSchema, Options extends TSche
|
|
|
9
9
|
export type TWith<Type extends TSchema, Options extends TSchema> = (Type & Options);
|
|
10
10
|
/** Applies annotation options to the given type. */
|
|
11
11
|
export declare function With<Type extends TSchema, const Options extends TSchema>(type: Type, options: Options): TWithAction<Type, Options>;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Type.TOptions\<T\> has been renamed to Type.TWith\<T\>. This type will be removed in the
|
|
14
|
-
* next version of TypeBox.
|
|
15
|
-
*/
|
|
16
|
-
export type TOptions<Type extends TSchema, Options extends TSchema> = TWith<Type, Options>;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Type.Options\<T\> has been renamed to Type.With\<T\>. This type will be removed in the
|
|
19
|
-
* next version of TypeBox.
|
|
20
|
-
*/
|
|
21
|
-
export declare function Options<Type extends TSchema, const Options extends TSchema>(type: Type, options: Options): TOptions<Type, Options>;
|
|
@@ -9,11 +9,3 @@ export function WithDeferred(type, options) {
|
|
|
9
9
|
export function With(type, options) {
|
|
10
10
|
return WithAction(type, options);
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Type.Options\<T\> has been renamed to Type.With\<T\>. This type will be removed in the
|
|
14
|
-
* next version of TypeBox.
|
|
15
|
-
*/
|
|
16
|
-
export function Options(type, options) {
|
|
17
|
-
return With(type, options);
|
|
18
|
-
}
|
|
19
|
-
// deno-coverage-ignore-stop
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TArray } from '../../types/array.mjs';
|
|
3
|
-
import { type TAsyncIterator } from '../../types/async_iterator.mjs';
|
|
4
3
|
import { type TConstructor } from '../../types/constructor.mjs';
|
|
5
4
|
import { type TFunction } from '../../types/function.mjs';
|
|
6
5
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
7
|
-
import { type TIterator } from '../../types/iterator.mjs';
|
|
8
6
|
import { type TObject } from '../../types/object.mjs';
|
|
9
|
-
import { type TPromise } from '../../types/promise.mjs';
|
|
10
7
|
import { type TProperties, type TPropertyValues } from '../../types/properties.mjs';
|
|
11
8
|
import { type TRecord } from '../../types/record.mjs';
|
|
12
9
|
import { type TTuple } from '../../types/tuple.mjs';
|
|
@@ -16,7 +13,7 @@ import { type TInterfaceDeferred } from '../../action/interface.mjs';
|
|
|
16
13
|
type TFromRef<Stack extends (keyof Context)[], Context extends TProperties, Ref extends (keyof Context)> = Ref extends Stack[number] ? true : TFromType<[...Stack, Ref], Context, Context[Ref]>;
|
|
17
14
|
type TFromProperties<Stack extends (keyof Context)[], Context extends TProperties, Properties extends TProperties, Types extends TSchema[] = TPropertyValues<Properties>> = TFromTypes<Stack, Context, Types>;
|
|
18
15
|
type TFromTypes<Stack extends (keyof Context)[], Context extends TProperties, Types extends TSchema[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromType<Stack, Context, Left> extends true ? true : TFromTypes<Stack, Context, Right> : false;
|
|
19
|
-
type TFromType<Stack extends (keyof Context)[], Context extends TProperties, Type extends TSchema> = (Type extends TRef<infer Ref extends string> ? TFromRef<Stack, Context, Ref> : Type extends TArray<infer Type extends TSchema> ? TFromType<Stack, Context, Type> : Type extends
|
|
16
|
+
type TFromType<Stack extends (keyof Context)[], Context extends TProperties, Type extends TSchema> = (Type extends TRef<infer Ref extends string> ? TFromRef<Stack, Context, Ref> : Type extends TArray<infer Type extends TSchema> ? TFromType<Stack, Context, Type> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromTypes<Stack, Context, [...Parameters, InstanceType]> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromTypes<Stack, Context, [...Parameters, ReturnType]> : Type extends TInterfaceDeferred<TSchema[], infer Properties extends TProperties> ? TFromProperties<Stack, Context, Properties> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromTypes<Stack, Context, Types> : Type extends TObject<infer Properties extends TProperties> ? TFromProperties<Stack, Context, Properties> : Type extends TUnion<infer Types extends TSchema[]> ? TFromTypes<Stack, Context, Types> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTypes<Stack, Context, Types> : Type extends TRecord<string, infer Type extends TSchema> ? TFromType<Stack, Context, Type> : false);
|
|
20
17
|
/** Performs a cyclic check on the given type. Initial key stack can be empty, but faster if specified */
|
|
21
18
|
export type TCyclicCheck<Stack extends (keyof Context)[], Context extends TProperties, Type extends TSchema, Result extends boolean = TFromType<Stack, Context, Type>> = Result;
|
|
22
19
|
/** Performs a cyclic check on the given type. Initial key stack can be empty, but faster if specified */
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { IsArray } from '../../types/array.mjs';
|
|
4
|
-
import { IsAsyncIterator } from '../../types/async_iterator.mjs';
|
|
5
4
|
import { IsConstructor } from '../../types/constructor.mjs';
|
|
6
5
|
import { IsFunction } from '../../types/function.mjs';
|
|
7
6
|
import { IsIntersect } from '../../types/intersect.mjs';
|
|
8
|
-
import { IsIterator } from '../../types/iterator.mjs';
|
|
9
7
|
import { IsObject } from '../../types/object.mjs';
|
|
10
|
-
import { IsPromise } from '../../types/promise.mjs';
|
|
11
8
|
import { PropertyValues } from '../../types/properties.mjs';
|
|
12
9
|
import { IsRecord, RecordValue } from '../../types/record.mjs';
|
|
13
10
|
import { IsTuple } from '../../types/tuple.mjs';
|
|
@@ -31,18 +28,15 @@ function FromTypes(stack, context, types) {
|
|
|
31
28
|
function FromType(stack, context, type) {
|
|
32
29
|
return (IsRef(type) ? FromRef(stack, context, type.$ref) :
|
|
33
30
|
IsArray(type) ? FromType(stack, context, type.items) :
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
IsTuple(type) ? FromTypes(stack, context, type.items) :
|
|
44
|
-
IsRecord(type) ? FromType(stack, context, RecordValue(type)) :
|
|
45
|
-
false);
|
|
31
|
+
IsConstructor(type) ? FromTypes(stack, context, [...type.parameters, type.instanceType]) :
|
|
32
|
+
IsFunction(type) ? FromTypes(stack, context, [...type.parameters, type.returnType]) :
|
|
33
|
+
IsInterfaceDeferred(type) ? FromProperties(stack, context, type.parameters[1]) :
|
|
34
|
+
IsIntersect(type) ? FromTypes(stack, context, type.allOf) :
|
|
35
|
+
IsObject(type) ? FromProperties(stack, context, type.properties) :
|
|
36
|
+
IsUnion(type) ? FromTypes(stack, context, type.anyOf) :
|
|
37
|
+
IsTuple(type) ? FromTypes(stack, context, type.items) :
|
|
38
|
+
IsRecord(type) ? FromType(stack, context, RecordValue(type)) :
|
|
39
|
+
false);
|
|
46
40
|
}
|
|
47
41
|
/** Performs a cyclic check on the given type. Initial key stack can be empty, but faster if specified */
|
|
48
42
|
export function CyclicCheck(stack, context, type) {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { type TUnreachable } from '../../../system/unreachable/index.mjs';
|
|
2
2
|
import { type TSchema } from '../../types/schema.mjs';
|
|
3
3
|
import { type TArray } from '../../types/array.mjs';
|
|
4
|
-
import { type TAsyncIterator } from '../../types/async_iterator.mjs';
|
|
5
4
|
import { type TConstructor } from '../../types/constructor.mjs';
|
|
6
5
|
import { type TFunction } from '../../types/function.mjs';
|
|
7
6
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
8
|
-
import { type TIterator } from '../../types/iterator.mjs';
|
|
9
7
|
import { type TObject } from '../../types/object.mjs';
|
|
10
|
-
import { type TPromise } from '../../types/promise.mjs';
|
|
11
8
|
import { type TProperties, type TPropertyValues } from '../../types/properties.mjs';
|
|
12
9
|
import { type TRecord } from '../../types/record.mjs';
|
|
13
10
|
import { type TTuple } from '../../types/tuple.mjs';
|
|
@@ -17,7 +14,7 @@ import { type TInterfaceDeferred } from '../../action/interface.mjs';
|
|
|
17
14
|
type TFromRef<Context extends TProperties, Ref extends string, Dependencies extends string[]> = Ref extends Dependencies[number] ? Dependencies : Ref extends keyof Context ? TFromType<Context, Context[Ref], [...Dependencies, Ref]> : TUnreachable;
|
|
18
15
|
type TFromProperties<Context extends TProperties, Properties extends TProperties, Dependencies extends string[], Types extends TSchema[] = TPropertyValues<Properties>> = TFromTypes<Context, Types, Dependencies>;
|
|
19
16
|
type TFromTypes<Context extends TProperties, Types extends TSchema[], Dependencies extends string[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromTypes<Context, Right, TFromType<Context, Left, Dependencies>> : Dependencies;
|
|
20
|
-
type TFromType<Context extends TProperties, Type extends TSchema, Result extends string[]> = (Type extends TRef<infer Ref extends string> ? TFromRef<Context, Ref, Result> : Type extends TArray<infer Type extends TSchema> ? TFromType<Context, Type, Result> : Type extends
|
|
17
|
+
type TFromType<Context extends TProperties, Type extends TSchema, Result extends string[]> = (Type extends TRef<infer Ref extends string> ? TFromRef<Context, Ref, Result> : Type extends TArray<infer Type extends TSchema> ? TFromType<Context, Type, Result> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromTypes<Context, [...Parameters, InstanceType], Result> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromTypes<Context, [...Parameters, ReturnType], Result> : Type extends TInterfaceDeferred<TSchema[], infer Properties extends TProperties> ? TFromProperties<Context, Properties, Result> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromTypes<Context, Types, Result> : Type extends TObject<infer Properties extends TProperties> ? TFromProperties<Context, Properties, Result> : Type extends TUnion<infer Types extends TSchema[]> ? TFromTypes<Context, Types, Result> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTypes<Context, Types, Result> : Type extends TRecord<string, infer Type extends TSchema> ? TFromType<Context, Type, Result> : Result);
|
|
21
18
|
/** Returns dependent cyclic keys for the given type. This function is used to dead-type-eliminate (DTE) for initializing TCyclic types. */
|
|
22
19
|
export type TCyclicDependencies<Context extends TProperties, Key extends string, Type extends TSchema, Result extends string[] = TFromType<Context, Type, [Key]>> = Result;
|
|
23
20
|
/** Returns dependent cyclic keys for the given type. This function is used to dead-type-eliminate (DTE) for initializing TCyclic types. */
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Unreachable } from '../../../system/unreachable/index.mjs';
|
|
3
3
|
import { IsArray } from '../../types/array.mjs';
|
|
4
|
-
import { IsAsyncIterator } from '../../types/async_iterator.mjs';
|
|
5
4
|
import { IsConstructor } from '../../types/constructor.mjs';
|
|
6
5
|
import { IsFunction } from '../../types/function.mjs';
|
|
7
6
|
import { IsIntersect } from '../../types/intersect.mjs';
|
|
8
|
-
import { IsIterator } from '../../types/iterator.mjs';
|
|
9
7
|
import { IsObject } from '../../types/object.mjs';
|
|
10
|
-
import { IsPromise } from '../../types/promise.mjs';
|
|
11
8
|
import { PropertyValues } from '../../types/properties.mjs';
|
|
12
9
|
import { IsRecord, RecordValue } from '../../types/record.mjs';
|
|
13
10
|
import { IsTuple } from '../../types/tuple.mjs';
|
|
@@ -33,18 +30,15 @@ function FromTypes(context, types, result) {
|
|
|
33
30
|
function FromType(context, type, result) {
|
|
34
31
|
return (IsRef(type) ? FromRef(context, type.$ref, result) :
|
|
35
32
|
IsArray(type) ? FromType(context, type.items, result) :
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
IsTuple(type) ? FromTypes(context, type.items, result) :
|
|
46
|
-
IsRecord(type) ? FromType(context, RecordValue(type), result) :
|
|
47
|
-
result);
|
|
33
|
+
IsConstructor(type) ? FromTypes(context, [...type.parameters, type.instanceType], result) :
|
|
34
|
+
IsFunction(type) ? FromTypes(context, [...type.parameters, type.returnType], result) :
|
|
35
|
+
IsInterfaceDeferred(type) ? FromProperties(context, type.parameters[1], result) :
|
|
36
|
+
IsIntersect(type) ? FromTypes(context, type.allOf, result) :
|
|
37
|
+
IsObject(type) ? FromProperties(context, type.properties, result) :
|
|
38
|
+
IsUnion(type) ? FromTypes(context, type.anyOf, result) :
|
|
39
|
+
IsTuple(type) ? FromTypes(context, type.items, result) :
|
|
40
|
+
IsRecord(type) ? FromType(context, RecordValue(type), result) :
|
|
41
|
+
result);
|
|
48
42
|
}
|
|
49
43
|
/** Returns dependent cyclic keys for the given type. This function is used to dead-type-eliminate (DTE) for initializing TCyclic types. */
|
|
50
44
|
export function CyclicDependencies(context, key, type) {
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TAny } from '../../types/any.mjs';
|
|
3
3
|
import { type TArray } from '../../types/array.mjs';
|
|
4
|
-
import { type TAsyncIterator } from '../../types/async_iterator.mjs';
|
|
5
4
|
import { type TConstructor } from '../../types/constructor.mjs';
|
|
6
5
|
import { type TCyclic } from '../../types/cyclic.mjs';
|
|
7
6
|
import { type TFunction } from '../../types/function.mjs';
|
|
8
7
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
9
|
-
import { type TIterator } from '../../types/iterator.mjs';
|
|
10
8
|
import { type TObject } from '../../types/object.mjs';
|
|
11
|
-
import { type TPromise } from '../../types/promise.mjs';
|
|
12
9
|
import { type TProperties } from '../../types/properties.mjs';
|
|
13
10
|
import { type TRecord } from '../../types/record.mjs';
|
|
14
11
|
import { type TRef } from '../../types/ref.mjs';
|
|
@@ -22,7 +19,7 @@ type TFromProperties<Properties extends TProperties, Result extends TProperties
|
|
|
22
19
|
[Key in keyof Result]: Result[Key];
|
|
23
20
|
};
|
|
24
21
|
type TFromTypes<Types extends TSchema[], Result extends TSchema[] = []> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromTypes<Right, [...Result, TFromType<Left>]> : Result;
|
|
25
|
-
type TFromType<Type extends TSchema> = (Type extends TRef<infer Ref extends string> ? TFromRef<Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TFromType<Type>> : Type extends
|
|
22
|
+
type TFromType<Type extends TSchema> = (Type extends TRef<infer Ref extends string> ? TFromRef<Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TFromType<Type>> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFunction<TFromTypes<Parameters>, TFromType<InstanceType>> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TFromTypes<Parameters>, TFromType<ReturnType>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromTypes<Types>> : Type extends TObject<infer Properties extends TProperties> ? TObject<TFromProperties<Properties>> : Type extends TRecord<infer Pattern extends string, infer Value extends TSchema> ? TRecord<Pattern, TFromType<Value>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromTypes<Types>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TFromTypes<Types>> : Type);
|
|
26
23
|
type TCyclicAnyFromParameters<Defs extends TProperties, Ref extends string> = (Ref extends keyof Defs ? TFromType<Defs[Ref]> : TUnknown);
|
|
27
24
|
/** Transforms TCyclic TRef's into TAny's. This function is used prior to TExtends checks to enable cyclics to be structurally checked and terminated (with TAny) at first point of recursion, what would otherwise be a recursive TRef.*/
|
|
28
25
|
export type TCyclicExtends<Type extends TCyclic, Result extends TSchema = TCyclicAnyFromParameters<Type['$defs'], Type['$ref']>> = Result;
|
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { Any } from '../../types/any.mjs';
|
|
4
4
|
import { Array as _Array_, IsArray, ArrayOptions } from '../../types/array.mjs';
|
|
5
|
-
import { AsyncIterator, IsAsyncIterator } from '../../types/async_iterator.mjs';
|
|
6
5
|
import { Constructor, IsConstructor } from '../../types/constructor.mjs';
|
|
7
6
|
import { Function as _Function_, IsFunction } from '../../types/function.mjs';
|
|
8
7
|
import { Intersect, IsIntersect } from '../../types/intersect.mjs';
|
|
9
|
-
import { Iterator, IsIterator } from '../../types/iterator.mjs';
|
|
10
8
|
import { Object, IsObject } from '../../types/object.mjs';
|
|
11
|
-
import { Promise, IsPromise } from '../../types/promise.mjs';
|
|
12
9
|
import { IsRecord, Record, RecordKey, RecordValue } from '../../types/record.mjs';
|
|
13
10
|
import { IsRef } from '../../types/ref.mjs';
|
|
14
11
|
import { Tuple, IsTuple } from '../../types/tuple.mjs';
|
|
@@ -30,17 +27,14 @@ function FromTypes(types) {
|
|
|
30
27
|
function FromType(type) {
|
|
31
28
|
return (IsRef(type) ? FromRef(type.$ref) :
|
|
32
29
|
IsArray(type) ? _Array_(FromType(type.items), ArrayOptions(type)) :
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
IsUnion(type) ? Union(FromTypes(type.anyOf)) :
|
|
42
|
-
IsTuple(type) ? Tuple(FromTypes(type.items)) :
|
|
43
|
-
type);
|
|
30
|
+
IsConstructor(type) ? Constructor(FromTypes(type.parameters), FromType(type.instanceType)) :
|
|
31
|
+
IsFunction(type) ? _Function_(FromTypes(type.parameters), FromType(type.returnType)) :
|
|
32
|
+
IsIntersect(type) ? Intersect(FromTypes(type.allOf)) :
|
|
33
|
+
IsObject(type) ? Object(FromProperties(type.properties)) :
|
|
34
|
+
IsRecord(type) ? Record(RecordKey(type), FromType(RecordValue(type))) :
|
|
35
|
+
IsUnion(type) ? Union(FromTypes(type.anyOf)) :
|
|
36
|
+
IsTuple(type) ? Tuple(FromTypes(type.items)) :
|
|
37
|
+
type);
|
|
44
38
|
}
|
|
45
39
|
function CyclicAnyFromParameters(defs, ref) {
|
|
46
40
|
return (ref in defs
|
|
@@ -5,7 +5,6 @@ export { Instantiate } from './instantiate.mjs';
|
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
6
|
// Engine: Internals
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
|
-
export * from './awaited/index.mjs';
|
|
9
8
|
export * from './conditional/index.mjs';
|
|
10
9
|
export * from './constructor_parameters/index.mjs';
|
|
11
10
|
export * from './cyclic/index.mjs';
|
|
@@ -3,7 +3,6 @@ import { type TAddReadonlyAction } from './readonly/instantiate_add.mjs';
|
|
|
3
3
|
import { type TAddOptionalAction } from './optional/instantiate_add.mjs';
|
|
4
4
|
import { type TSchema } from '../types/schema.mjs';
|
|
5
5
|
import { type TArray } from '../types/array.mjs';
|
|
6
|
-
import { type TAsyncIterator } from '../types/async_iterator.mjs';
|
|
7
6
|
import { type TConstructor } from '../types/constructor.mjs';
|
|
8
7
|
import { type TDeferred } from '../types/deferred.mjs';
|
|
9
8
|
import { type TFunction } from '../types/function.mjs';
|
|
@@ -11,9 +10,7 @@ import { type TCall } from '../types/call.mjs';
|
|
|
11
10
|
import { type TIdentifier } from '../types/identifier.mjs';
|
|
12
11
|
import { type TDependent } from '../types/dependent.mjs';
|
|
13
12
|
import { type TIntersect } from '../types/intersect.mjs';
|
|
14
|
-
import { type TIterator } from '../types/iterator.mjs';
|
|
15
13
|
import { type TObject } from '../types/object.mjs';
|
|
16
|
-
import { type TPromise } from '../types/promise.mjs';
|
|
17
14
|
import { type TProperties } from '../types/properties.mjs';
|
|
18
15
|
import { type TRecord } from '../types/record.mjs';
|
|
19
16
|
import { type TTuple } from '../types/tuple.mjs';
|
|
@@ -29,7 +26,6 @@ import { type TRemoveOptionalInstantiate } from './optional/instantiate_remove.m
|
|
|
29
26
|
import { type TOptional } from '../types/_optional.mjs';
|
|
30
27
|
import { type TImmutable } from '../types/_immutable.mjs';
|
|
31
28
|
import { type TReadonly } from '../types/_readonly.mjs';
|
|
32
|
-
import { type TAwaitedInstantiate } from './awaited/instantiate.mjs';
|
|
33
29
|
import { type TCallInstantiate } from './call/instantiate.mjs';
|
|
34
30
|
import { type TCapitalizeInstantiate } from './intrinsics/instantiate.mjs';
|
|
35
31
|
import { type TConditionalInstantiate } from './conditional/index.mjs';
|
|
@@ -96,9 +92,6 @@ type TInstantiateDeferred<Context extends TProperties, State extends TState, Act
|
|
|
96
92
|
] extends ['RemoveOptional', [infer Type extends TSchema]] ? TRemoveOptionalInstantiate<Context, State, Type> : [
|
|
97
93
|
Action,
|
|
98
94
|
Parameters
|
|
99
|
-
] extends ['Awaited', [infer Type extends TSchema]] ? TAwaitedInstantiate<Context, State, Type> : [
|
|
100
|
-
Action,
|
|
101
|
-
Parameters
|
|
102
95
|
] extends ['Capitalize', [infer Type extends TSchema]] ? TCapitalizeInstantiate<Context, State, Type> : [
|
|
103
96
|
Action,
|
|
104
97
|
Parameters
|
|
@@ -175,7 +168,7 @@ type TInstantiateDeferred<Context extends TProperties, State extends TState, Act
|
|
|
175
168
|
Action,
|
|
176
169
|
Parameters
|
|
177
170
|
] extends ['With', [infer Type extends TSchema, infer Options extends TSchema]] ? TWithInstantiate<Context, State, Type, Options> : TDeferred<Action, Parameters>);
|
|
178
|
-
type TInstantiateImmediate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = (Type extends TRef<infer Ref extends string> ? TRefInstantiate<Context, State, Type, Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TInstantiateType<Context, State, Type>> : Type extends
|
|
171
|
+
type TInstantiateImmediate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = (Type extends TRef<infer Ref extends string> ? TRefInstantiate<Context, State, Type, Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TInstantiateType<Context, State, Type>> : Type extends TCall<infer Target extends TSchema, infer Parameters extends TSchema[]> ? TCallInstantiate<Context, State, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, InstanceType>> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, ReturnType>> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TDependent<TInstantiateType<Context, State, If>, TInstantiateType<Context, State, Then>, TInstantiateType<Context, State, Else>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TInstantiateTypes<Context, State, Types>> : Type extends TObject<infer Properties extends TProperties> ? TObject<TInstantiateProperties<Context, State, Properties>> : Type extends TRecord<infer Key extends string, infer Type extends TSchema> ? TRecord<Key, TInstantiateType<Context, State, Type>> : Type extends TRest<infer Type extends TSchema> ? TRest<TInstantiateType<Context, State, Type>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TInstantiateElements<Context, State, Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TInstantiateTypes<Context, State, Types>> : Type), WithModifiers extends TSchema = TWithModifiers<Type, InstantiatedType>> = WithModifiers;
|
|
179
172
|
export type TInstantiateType<Context extends TProperties, State extends TState, Type extends TSchema, Result extends TSchema = Type extends TDeferred<infer Action extends string, infer Types extends TSchema[]> ? TInstantiateDeferred<Context, State, Action, Types> : TInstantiateImmediate<Context, State, Type>> = Result;
|
|
180
173
|
export declare function InstantiateType<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type): TInstantiateImmediate<Context, State, Type>;
|
|
181
174
|
/** Instantiates computed schematics using the given context and type. */
|