typia 5.2.5 → 5.2.6-dev.20231108
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/lib/factories/ExpressionFactory.d.ts +1 -0
- package/lib/factories/ExpressionFactory.js +5 -0
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.js +4 -4
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +16 -18
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +2 -1
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/RandomJoiner.js +4 -6
- package/lib/programmers/helpers/RandomJoiner.js.map +1 -1
- package/lib/programmers/helpers/RandomRanger.js +3 -2
- package/lib/programmers/helpers/RandomRanger.js.map +1 -1
- package/lib/programmers/http/HttpHeadersProgrammer.js +1 -1
- package/lib/programmers/http/HttpHeadersProgrammer.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_properties.js +4 -3
- package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/check_union_array_like.js +3 -2
- package/lib/programmers/internal/check_union_array_like.js.map +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.js +1 -3
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +1 -3
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscLiteralsProgrammer.js +1 -1
- package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js +1 -3
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js +1 -3
- package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +6 -6
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +2 -2
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/package.json +1 -1
- package/src/Primitive.ts +135 -135
- package/src/executable/TypiaSetupWizard.ts +142 -142
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/factories/ExpressionFactory.ts +8 -0
- package/src/factories/JsonMetadataFactory.ts +50 -50
- package/src/factories/MetadataCollection.ts +282 -282
- package/src/factories/internal/metadata/emplace_metadata_object.ts +178 -178
- package/src/functional/$stoll.ts +8 -8
- package/src/functional/Namespace.ts +168 -168
- package/src/programmers/AssertProgrammer.ts +322 -322
- package/src/programmers/CheckerProgrammer.ts +4 -4
- package/src/programmers/IsProgrammer.ts +258 -258
- package/src/programmers/RandomProgrammer.ts +16 -17
- package/src/programmers/ValidateProgrammer.ts +350 -349
- package/src/programmers/helpers/AtomicPredicator.ts +31 -31
- package/src/programmers/helpers/RandomJoiner.ts +4 -6
- package/src/programmers/helpers/RandomRanger.ts +4 -2
- package/src/programmers/http/HttpHeadersProgrammer.ts +1 -1
- package/src/programmers/internal/check_dynamic_key.ts +178 -178
- package/src/programmers/internal/check_dynamic_properties.ts +202 -201
- package/src/programmers/internal/check_object.ts +62 -62
- package/src/programmers/internal/check_union_array_like.ts +4 -3
- package/src/programmers/json/JsonStringifyProgrammer.ts +960 -964
- package/src/programmers/misc/MiscCloneProgrammer.ts +786 -790
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +1 -1
- package/src/programmers/misc/MiscPruneProgrammer.ts +548 -552
- package/src/programmers/notations/NotationGeneralProgrammer.ts +716 -720
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +7 -9
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +882 -882
- package/src/transform.ts +35 -35
|
@@ -1,201 +1,202 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(
|
|
20
|
-
(
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
(
|
|
106
|
-
(
|
|
107
|
-
(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
entry.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
undefined,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
undefined,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
undefined,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
undefined,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
ts.factory.createIdentifier("
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { ExpressionFactory } from "../../factories/ExpressionFactory";
|
|
4
|
+
import { IdentifierFactory } from "../../factories/IdentifierFactory";
|
|
5
|
+
import { StatementFactory } from "../../factories/StatementFactory";
|
|
6
|
+
|
|
7
|
+
import { IProject } from "../../transformers/IProject";
|
|
8
|
+
|
|
9
|
+
import { FunctionImporter } from "../helpers/FunctionImporeter";
|
|
10
|
+
import { IExpressionEntry } from "../helpers/IExpressionEntry";
|
|
11
|
+
import { check_dynamic_key } from "./check_dynamic_key";
|
|
12
|
+
import { check_everything } from "./check_everything";
|
|
13
|
+
import { check_object } from "./check_object";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export const check_dynamic_properties =
|
|
19
|
+
(props: check_object.IProps) =>
|
|
20
|
+
(project: IProject) =>
|
|
21
|
+
(importer: FunctionImporter) =>
|
|
22
|
+
(
|
|
23
|
+
input: ts.Expression,
|
|
24
|
+
regular: IExpressionEntry<ts.Expression>[],
|
|
25
|
+
dynamic: IExpressionEntry<ts.Expression>[],
|
|
26
|
+
): ts.Expression => {
|
|
27
|
+
const length = IdentifierFactory.access(
|
|
28
|
+
ts.factory.createCallExpression(
|
|
29
|
+
ts.factory.createIdentifier("Object.keys"),
|
|
30
|
+
undefined,
|
|
31
|
+
[input],
|
|
32
|
+
),
|
|
33
|
+
)("length");
|
|
34
|
+
const left: ts.Expression | null =
|
|
35
|
+
props.equals === true && dynamic.length === 0
|
|
36
|
+
? props.undefined === true ||
|
|
37
|
+
regular.every((r) => r.meta.isRequired())
|
|
38
|
+
? ts.factory.createStrictEquality(
|
|
39
|
+
ExpressionFactory.number(
|
|
40
|
+
regular.filter((r) => r.meta.isRequired()).length,
|
|
41
|
+
),
|
|
42
|
+
length,
|
|
43
|
+
)
|
|
44
|
+
: ts.factory.createCallExpression(
|
|
45
|
+
importer.use("is_between"),
|
|
46
|
+
[],
|
|
47
|
+
[
|
|
48
|
+
length,
|
|
49
|
+
ExpressionFactory.number(
|
|
50
|
+
regular.filter((r) => r.meta.isRequired())
|
|
51
|
+
.length,
|
|
52
|
+
),
|
|
53
|
+
ExpressionFactory.number(regular.length),
|
|
54
|
+
],
|
|
55
|
+
)
|
|
56
|
+
: null;
|
|
57
|
+
if (
|
|
58
|
+
props.undefined === false &&
|
|
59
|
+
left !== null &&
|
|
60
|
+
regular.every((r) => r.meta.isRequired())
|
|
61
|
+
)
|
|
62
|
+
return left;
|
|
63
|
+
|
|
64
|
+
const criteria = props.entries
|
|
65
|
+
? ts.factory.createCallExpression(props.entries, undefined, [
|
|
66
|
+
ts.factory.createCallExpression(
|
|
67
|
+
ts.factory.createIdentifier("Object.keys"),
|
|
68
|
+
undefined,
|
|
69
|
+
[input],
|
|
70
|
+
),
|
|
71
|
+
check_dynamic_property(props)(project)(importer)(
|
|
72
|
+
input,
|
|
73
|
+
regular,
|
|
74
|
+
dynamic,
|
|
75
|
+
),
|
|
76
|
+
])
|
|
77
|
+
: ts.factory.createCallExpression(
|
|
78
|
+
IdentifierFactory.access(
|
|
79
|
+
ts.factory.createCallExpression(
|
|
80
|
+
ts.factory.createIdentifier("Object.keys"),
|
|
81
|
+
undefined,
|
|
82
|
+
[input],
|
|
83
|
+
),
|
|
84
|
+
)(props.assert ? "every" : "map"),
|
|
85
|
+
undefined,
|
|
86
|
+
[
|
|
87
|
+
check_dynamic_property(props)(project)(importer)(
|
|
88
|
+
input,
|
|
89
|
+
regular,
|
|
90
|
+
dynamic,
|
|
91
|
+
),
|
|
92
|
+
],
|
|
93
|
+
);
|
|
94
|
+
const right: ts.Expression = (props.halt || ((elem) => elem))(
|
|
95
|
+
props.assert ? criteria : check_everything(criteria),
|
|
96
|
+
);
|
|
97
|
+
return left
|
|
98
|
+
? (props.undefined
|
|
99
|
+
? ts.factory.createLogicalOr
|
|
100
|
+
: ts.factory.createLogicalAnd)(left, right)
|
|
101
|
+
: right;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const check_dynamic_property =
|
|
105
|
+
(props: check_object.IProps) =>
|
|
106
|
+
(project: IProject) =>
|
|
107
|
+
(importer: FunctionImporter) =>
|
|
108
|
+
(
|
|
109
|
+
input: ts.Expression,
|
|
110
|
+
regular: IExpressionEntry<ts.Expression>[],
|
|
111
|
+
dynamic: IExpressionEntry<ts.Expression>[],
|
|
112
|
+
) => {
|
|
113
|
+
//----
|
|
114
|
+
// IF CONDITIONS
|
|
115
|
+
//----
|
|
116
|
+
// PREPARE ASSETS
|
|
117
|
+
const key = ts.factory.createIdentifier("key");
|
|
118
|
+
const value = ts.factory.createIdentifier("value");
|
|
119
|
+
|
|
120
|
+
const statements: ts.Statement[] = [];
|
|
121
|
+
const add = (exp: ts.Expression, output: ts.Expression) =>
|
|
122
|
+
statements.push(
|
|
123
|
+
ts.factory.createIfStatement(
|
|
124
|
+
exp,
|
|
125
|
+
ts.factory.createReturnStatement(output),
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// GATHER CONDITIONS
|
|
130
|
+
if (regular.length) add(is_regular_property(regular), props.positive);
|
|
131
|
+
statements.push(
|
|
132
|
+
StatementFactory.constant(
|
|
133
|
+
"value",
|
|
134
|
+
ts.factory.createElementAccessExpression(input, key),
|
|
135
|
+
),
|
|
136
|
+
);
|
|
137
|
+
if (props.undefined === true)
|
|
138
|
+
add(
|
|
139
|
+
ts.factory.createStrictEquality(
|
|
140
|
+
ts.factory.createIdentifier("undefined"),
|
|
141
|
+
value,
|
|
142
|
+
),
|
|
143
|
+
props.positive,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
for (const entry of dynamic)
|
|
147
|
+
add(
|
|
148
|
+
check_dynamic_key(project)(importer)(key, entry.key),
|
|
149
|
+
entry.expression,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
//----
|
|
153
|
+
// FUNCTION BODY
|
|
154
|
+
//----
|
|
155
|
+
// CLOSURE BLOCK
|
|
156
|
+
const block: ts.Block = ts.factory.createBlock(
|
|
157
|
+
[
|
|
158
|
+
...statements,
|
|
159
|
+
ts.factory.createReturnStatement(
|
|
160
|
+
props.equals === true
|
|
161
|
+
? props.superfluous(value)
|
|
162
|
+
: props.positive,
|
|
163
|
+
),
|
|
164
|
+
],
|
|
165
|
+
true,
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
// RETURNS
|
|
169
|
+
return ts.factory.createArrowFunction(
|
|
170
|
+
undefined,
|
|
171
|
+
undefined,
|
|
172
|
+
[IdentifierFactory.parameter("key")],
|
|
173
|
+
undefined,
|
|
174
|
+
undefined,
|
|
175
|
+
block,
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const is_regular_property = (regular: IExpressionEntry[]) =>
|
|
180
|
+
ts.factory.createCallExpression(
|
|
181
|
+
IdentifierFactory.access(
|
|
182
|
+
ts.factory.createArrayLiteralExpression(
|
|
183
|
+
regular.map((entry) =>
|
|
184
|
+
ts.factory.createStringLiteral(entry.key.getSoleLiteral()!),
|
|
185
|
+
),
|
|
186
|
+
),
|
|
187
|
+
)("some"),
|
|
188
|
+
undefined,
|
|
189
|
+
[
|
|
190
|
+
ts.factory.createArrowFunction(
|
|
191
|
+
undefined,
|
|
192
|
+
undefined,
|
|
193
|
+
[IdentifierFactory.parameter("prop")],
|
|
194
|
+
undefined,
|
|
195
|
+
undefined,
|
|
196
|
+
ts.factory.createStrictEquality(
|
|
197
|
+
ts.factory.createIdentifier("key"),
|
|
198
|
+
ts.factory.createIdentifier("prop"),
|
|
199
|
+
),
|
|
200
|
+
),
|
|
201
|
+
],
|
|
202
|
+
);
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { IProject } from "../../transformers/IProject";
|
|
4
|
-
|
|
5
|
-
import { FunctionImporter } from "../helpers/FunctionImporeter";
|
|
6
|
-
import { IExpressionEntry } from "../helpers/IExpressionEntry";
|
|
7
|
-
import { check_dynamic_properties } from "./check_dynamic_properties";
|
|
8
|
-
import { check_everything } from "./check_everything";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export const check_object =
|
|
14
|
-
(props: check_object.IProps) =>
|
|
15
|
-
(project: IProject) =>
|
|
16
|
-
(importer: FunctionImporter) =>
|
|
17
|
-
(input: ts.Expression, entries: IExpressionEntry<ts.Expression>[]) => {
|
|
18
|
-
// PREPARE ASSETS
|
|
19
|
-
const regular = entries.filter((entry) => entry.key.isSoleLiteral());
|
|
20
|
-
const dynamic = entries.filter((entry) => !entry.key.isSoleLiteral());
|
|
21
|
-
const flags: ts.Expression[] = regular.map((entry) => entry.expression);
|
|
22
|
-
|
|
23
|
-
// REGULAR WITHOUT DYNAMIC PROPERTIES
|
|
24
|
-
if (props.equals === false && dynamic.length === 0)
|
|
25
|
-
return regular.length === 0 ? props.positive : reduce(props)(flags);
|
|
26
|
-
|
|
27
|
-
// CHECK DYNAMIC PROPERTIES
|
|
28
|
-
flags.push(
|
|
29
|
-
check_dynamic_properties(props)(project)(importer)(
|
|
30
|
-
input,
|
|
31
|
-
regular,
|
|
32
|
-
dynamic,
|
|
33
|
-
),
|
|
34
|
-
);
|
|
35
|
-
return reduce(props)(flags);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
export namespace check_object {
|
|
42
|
-
export interface IProps {
|
|
43
|
-
equals: boolean;
|
|
44
|
-
assert: boolean;
|
|
45
|
-
undefined: boolean;
|
|
46
|
-
halt?: undefined | ((exp: ts.Expression) => ts.Expression);
|
|
47
|
-
reduce: (a: ts.Expression, b: ts.Expression) => ts.Expression;
|
|
48
|
-
positive: ts.Expression;
|
|
49
|
-
superfluous: (value: ts.Expression) => ts.Expression;
|
|
50
|
-
entries?: undefined | ts.Identifier;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @internal
|
|
56
|
-
*/
|
|
57
|
-
const reduce = (props: check_object.IProps) => (expressions: ts.Expression[]) =>
|
|
58
|
-
props.assert
|
|
59
|
-
? expressions.reduce(props.reduce)
|
|
60
|
-
: check_everything(
|
|
61
|
-
ts.factory.createArrayLiteralExpression(expressions),
|
|
62
|
-
);
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IProject } from "../../transformers/IProject";
|
|
4
|
+
|
|
5
|
+
import { FunctionImporter } from "../helpers/FunctionImporeter";
|
|
6
|
+
import { IExpressionEntry } from "../helpers/IExpressionEntry";
|
|
7
|
+
import { check_dynamic_properties } from "./check_dynamic_properties";
|
|
8
|
+
import { check_everything } from "./check_everything";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export const check_object =
|
|
14
|
+
(props: check_object.IProps) =>
|
|
15
|
+
(project: IProject) =>
|
|
16
|
+
(importer: FunctionImporter) =>
|
|
17
|
+
(input: ts.Expression, entries: IExpressionEntry<ts.Expression>[]) => {
|
|
18
|
+
// PREPARE ASSETS
|
|
19
|
+
const regular = entries.filter((entry) => entry.key.isSoleLiteral());
|
|
20
|
+
const dynamic = entries.filter((entry) => !entry.key.isSoleLiteral());
|
|
21
|
+
const flags: ts.Expression[] = regular.map((entry) => entry.expression);
|
|
22
|
+
|
|
23
|
+
// REGULAR WITHOUT DYNAMIC PROPERTIES
|
|
24
|
+
if (props.equals === false && dynamic.length === 0)
|
|
25
|
+
return regular.length === 0 ? props.positive : reduce(props)(flags);
|
|
26
|
+
|
|
27
|
+
// CHECK DYNAMIC PROPERTIES
|
|
28
|
+
flags.push(
|
|
29
|
+
check_dynamic_properties(props)(project)(importer)(
|
|
30
|
+
input,
|
|
31
|
+
regular,
|
|
32
|
+
dynamic,
|
|
33
|
+
),
|
|
34
|
+
);
|
|
35
|
+
return reduce(props)(flags);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export namespace check_object {
|
|
42
|
+
export interface IProps {
|
|
43
|
+
equals: boolean;
|
|
44
|
+
assert: boolean;
|
|
45
|
+
undefined: boolean;
|
|
46
|
+
halt?: undefined | ((exp: ts.Expression) => ts.Expression);
|
|
47
|
+
reduce: (a: ts.Expression, b: ts.Expression) => ts.Expression;
|
|
48
|
+
positive: ts.Expression;
|
|
49
|
+
superfluous: (value: ts.Expression) => ts.Expression;
|
|
50
|
+
entries?: undefined | ts.Identifier;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
const reduce = (props: check_object.IProps) => (expressions: ts.Expression[]) =>
|
|
58
|
+
props.assert
|
|
59
|
+
? expressions.reduce(props.reduce)
|
|
60
|
+
: check_everything(
|
|
61
|
+
ts.factory.createArrayLiteralExpression(expressions),
|
|
62
|
+
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
|
|
3
|
+
import { ExpressionFactory } from "../../factories/ExpressionFactory";
|
|
3
4
|
import { IdentifierFactory } from "../../factories/IdentifierFactory";
|
|
4
5
|
import { StatementFactory } from "../../factories/StatementFactory";
|
|
5
6
|
import { TypeFactory } from "../../factories/TypeFactory";
|
|
@@ -159,7 +160,7 @@ export const check_union_array_like =
|
|
|
159
160
|
StatementFactory.constant("top", accessor.front(input)),
|
|
160
161
|
ts.factory.createIfStatement(
|
|
161
162
|
ts.factory.createStrictEquality(
|
|
162
|
-
|
|
163
|
+
ExpressionFactory.number(0),
|
|
163
164
|
accessor.size(input),
|
|
164
165
|
),
|
|
165
166
|
ts.isReturnStatement(props.empty)
|
|
@@ -198,7 +199,7 @@ export const check_union_array_like =
|
|
|
198
199
|
),
|
|
199
200
|
ts.factory.createIfStatement(
|
|
200
201
|
ts.factory.createStrictEquality(
|
|
201
|
-
|
|
202
|
+
ExpressionFactory.number(1),
|
|
202
203
|
ts.factory.createIdentifier("passed.length"),
|
|
203
204
|
),
|
|
204
205
|
ts.factory.createReturnStatement(
|
|
@@ -215,7 +216,7 @@ export const check_union_array_like =
|
|
|
215
216
|
),
|
|
216
217
|
ts.factory.createIfStatement(
|
|
217
218
|
ts.factory.createLessThan(
|
|
218
|
-
|
|
219
|
+
ExpressionFactory.number(1),
|
|
219
220
|
ts.factory.createIdentifier("passed.length"),
|
|
220
221
|
),
|
|
221
222
|
iterate("pred")(ts.factory.createIdentifier("passed"))(
|