typia 5.5.0-dev.20240302 → 5.5.0-dev.20240303
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/functional.d.ts +353 -0
- package/lib/functional.js +130 -0
- package/lib/functional.js.map +1 -0
- package/lib/module.d.ts +1 -0
- package/lib/module.js +2 -1
- package/lib/module.js.map +1 -1
- package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.d.ts +6 -0
- package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.js +33 -0
- package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.js.map +1 -0
- package/lib/programmers/functional/FunctionalAssertParametersProgrammer.d.ts +11 -0
- package/lib/programmers/functional/FunctionalAssertParametersProgrammer.js +58 -0
- package/lib/programmers/functional/FunctionalAssertParametersProgrammer.js.map +1 -0
- package/lib/programmers/functional/FunctionalAssertReturnProgrammer.d.ts +14 -0
- package/lib/programmers/functional/FunctionalAssertReturnProgrammer.js +67 -0
- package/lib/programmers/functional/FunctionalAssertReturnProgrammer.js.map +1 -0
- package/lib/transformers/CallExpressionTransformer.d.ts +1 -1
- package/lib/transformers/CallExpressionTransformer.js +49 -0
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/functional/FunctionalGenericTransformer.d.ts +10 -0
- package/lib/transformers/features/functional/FunctionalGenericTransformer.js +32 -0
- package/lib/transformers/features/functional/FunctionalGenericTransformer.js.map +1 -0
- package/package.json +1 -1
- package/src/functional.ts +561 -0
- package/src/module.ts +1 -0
- package/src/programmers/functional/FunctionalAssertFunctionProgrammer.ts +44 -0
- package/src/programmers/functional/FunctionalAssertParametersProgrammer.ts +100 -0
- package/src/programmers/functional/FunctionalAssertReturnProgrammer.ts +84 -0
- package/src/transformers/CallExpressionTransformer.ts +52 -5
- package/src/transformers/features/functional/FunctionalGenericTransformer.ts +41 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { IValidation } from "./IValidation";
|
|
2
|
+
import { TypeGuardError } from "./TypeGuardError";
|
|
3
|
+
/**
|
|
4
|
+
* Asserts a function.
|
|
5
|
+
*
|
|
6
|
+
* Asserts a function, by wrapping the function and checking its parameters and
|
|
7
|
+
* return value through {@link assert} function. If some parameter or return value
|
|
8
|
+
* does not match the expected type, it throws an {@link TypeGuardError} or a custom
|
|
9
|
+
* error generated by the *errorFactory* parameter.
|
|
10
|
+
*
|
|
11
|
+
* For reference, {@link TypeGuardError.path} would be a little bit different with
|
|
12
|
+
* individual {@link assert} function. If the {@link TypeGuardError} occurs from
|
|
13
|
+
* some parameter, the path would start from `$input.parameters[number]`. Otherwise
|
|
14
|
+
* the path would start from `$input.return`.
|
|
15
|
+
*
|
|
16
|
+
* - `$input.parameters[0].~`
|
|
17
|
+
* - `$input.return.~`
|
|
18
|
+
*
|
|
19
|
+
* By the way, if what you want is not just finding the 1st type error through
|
|
20
|
+
* assertion, but also finding every type errors, then use {@link validateFunction}
|
|
21
|
+
* instead. Otherwise, what you want is just asserting parameters or return value
|
|
22
|
+
* only, you can use {@link assertParameters} or {@link assertReturn} instead.
|
|
23
|
+
*
|
|
24
|
+
* On the other hand, if don't want to allow any superfluous properties, utilize
|
|
25
|
+
* {@link assertEqualsFunction} or {@link validateEqualsFunction} instead.
|
|
26
|
+
*
|
|
27
|
+
* @template T Target function type
|
|
28
|
+
* @param func Target function to assert
|
|
29
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
30
|
+
* @returns The wrapper function with type assertions
|
|
31
|
+
* @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
|
|
32
|
+
*
|
|
33
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
34
|
+
*/
|
|
35
|
+
declare function assertFunction<T extends (...args: unknown[]) => unknown>(func: T, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;
|
|
36
|
+
declare const assertFunctionPure: typeof assertFunction;
|
|
37
|
+
export { assertFunctionPure as assertFunction };
|
|
38
|
+
/**
|
|
39
|
+
* Asserts parameters.
|
|
40
|
+
*
|
|
41
|
+
* Asserts a function, by wrapping the function and checking its parameters through
|
|
42
|
+
* {@link assert} function. If some parameter does not match the expected type, it
|
|
43
|
+
* throws an {@link TypeGuardError} or a custom error generated by the *errorFactory*
|
|
44
|
+
* parameter.
|
|
45
|
+
*
|
|
46
|
+
* For reference, {@link TypeGuardError.path} would be a little bit different with
|
|
47
|
+
* individual {@link assert} function. If the {@link TypeGuardError} occurs from
|
|
48
|
+
* some parameter, the path would start from `$input.parameters[number]`.
|
|
49
|
+
*
|
|
50
|
+
* By the way, if what you want is not just finding the 1st type error through
|
|
51
|
+
* assertion, but also finding every type errors, then use {@link validateParameters}
|
|
52
|
+
* instead. Otherwise, what you want is not only asserting parameters, but also
|
|
53
|
+
* asserting return value, you can use {@link assertFunction} instead.
|
|
54
|
+
*
|
|
55
|
+
* On the other hand, if don't want to allow any superfluous properties, utilize
|
|
56
|
+
* {@link assertEqualsParameters} or {@link validateEqualsParameters} instead.
|
|
57
|
+
*
|
|
58
|
+
* @template T Target function type
|
|
59
|
+
* @param func Target function to assert
|
|
60
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
61
|
+
* @returns The wrapper function with type assertions
|
|
62
|
+
* @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
|
|
63
|
+
*
|
|
64
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
65
|
+
*/
|
|
66
|
+
declare function assertParameters<T extends (...args: unknown[]) => unknown>(func: T, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;
|
|
67
|
+
declare const assertParametersPure: typeof assertParameters;
|
|
68
|
+
export { assertParametersPure as assertParameters };
|
|
69
|
+
/**
|
|
70
|
+
* Asserts return value.
|
|
71
|
+
*
|
|
72
|
+
* Asserts a function, by wrapping the function and checking its return value through
|
|
73
|
+
* {@link assert} function. If the return value does not match the expected type, it
|
|
74
|
+
* throws an {@link TypeGuardError} or a custom error generated by the *errorFactory*
|
|
75
|
+
* parameter.
|
|
76
|
+
*
|
|
77
|
+
* For reference, {@link TypeGuardError.path} would be a little bit different with
|
|
78
|
+
* individual {@link assert} function. If the {@link TypeGuardError} occurs from
|
|
79
|
+
* the return value, the path would start from `$input.return`.
|
|
80
|
+
*
|
|
81
|
+
* By the way, if what you want is not just finding the 1st type error through
|
|
82
|
+
* assertion, but also finding every type errors, then use {@link validateReturn}
|
|
83
|
+
* instead. Otherwise, what you want is not only asserting return value, but also
|
|
84
|
+
* asserting parameters, you can use {@link assertFunction} instead.
|
|
85
|
+
*
|
|
86
|
+
* On the other hand, if don't want to allow any superfluous properties, utilize
|
|
87
|
+
* {@link assertEqualsReturn} or {@link validateEqualsReturn} instead.
|
|
88
|
+
*
|
|
89
|
+
* @template T Target function type
|
|
90
|
+
* @param func Target function to assert
|
|
91
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
92
|
+
* @returns The wrapper function with type assertions
|
|
93
|
+
* @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
|
|
94
|
+
*
|
|
95
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
96
|
+
*/
|
|
97
|
+
declare function assertReturn<T extends (...args: unknown[]) => unknown>(func: T, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;
|
|
98
|
+
declare const assertReturnPure: typeof assertReturn;
|
|
99
|
+
export { assertReturnPure as assertReturn };
|
|
100
|
+
/**
|
|
101
|
+
* Asserts a function with strict equality.
|
|
102
|
+
*
|
|
103
|
+
* Asserts a function with strict equality, by wrapping the function and checking
|
|
104
|
+
* its parameters and return value through {@link assertEquals} function. If some
|
|
105
|
+
* parameter or return value does not match the expected type, it throws an
|
|
106
|
+
* {@link TypeGuardError} or a custom error generated by the *errorFactory* parameter.
|
|
107
|
+
*
|
|
108
|
+
* For reference, {@link TypeGuardError.path} would be a little bit different with
|
|
109
|
+
* individual {@link assertEquals} function. If the {@link TypeGuardError} occurs from
|
|
110
|
+
* some parameter, the path would start from `$input.parameters[number]`. Otherwise
|
|
111
|
+
* the path would start from `$input.return`.
|
|
112
|
+
*
|
|
113
|
+
* - `$input.parameters[0].~`
|
|
114
|
+
* - `$input.return.~`
|
|
115
|
+
*
|
|
116
|
+
* By the way, if what you want is not just finding the 1st type error through
|
|
117
|
+
* assertion, but also finding every type errors, then use
|
|
118
|
+
* {@link validateEqualsFunction} instead. Otherwise, what you want is just asserting
|
|
119
|
+
* parameters or return value only, you can use {@link assertEqualsParameters} or
|
|
120
|
+
* {@link assertEqualsReturn} instead.
|
|
121
|
+
*
|
|
122
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
123
|
+
* {@link assertFunction} or {@link validateFunction} instead.
|
|
124
|
+
*
|
|
125
|
+
* @template T Target function type
|
|
126
|
+
* @param func Target function to assert
|
|
127
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
128
|
+
* @returns The wrapper function with type assertions
|
|
129
|
+
* @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
|
|
130
|
+
*
|
|
131
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
132
|
+
*/
|
|
133
|
+
declare function assertEqualsFunction<T extends (...args: unknown[]) => unknown>(func: T, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;
|
|
134
|
+
declare const assertEqualsFunctionPure: typeof assertEqualsFunction;
|
|
135
|
+
export { assertEqualsFunctionPure as assertEqualsFunction };
|
|
136
|
+
/**
|
|
137
|
+
* Asserts parameters with strict equality.
|
|
138
|
+
*
|
|
139
|
+
* Asserts a function, by wrapping the function and checking its parameters through
|
|
140
|
+
* {@link assertEquals} function. If some parameter does not match the expected type,
|
|
141
|
+
* it throws an {@link TypeGuardError} or a custom error generated by the *errorFactory*
|
|
142
|
+
* parameter.
|
|
143
|
+
*
|
|
144
|
+
* For reference, {@link TypeGuardError.path} would be a little bit different with
|
|
145
|
+
* individual {@link assertEquals} function. If the {@link TypeGuardError} occurs from
|
|
146
|
+
* some parameter, the path would start from `$input.parameters[number]`.
|
|
147
|
+
*
|
|
148
|
+
* By the way, if what you want is not just finding the 1st type error through
|
|
149
|
+
* assertion, but also finding every type errors, then use
|
|
150
|
+
* {@link validateEqualsParameters} instead. Otherwise, what you want is not only
|
|
151
|
+
* asserting parameters, but also asserting return value, you can use
|
|
152
|
+
* {@link assertEqualsFunction} instead.
|
|
153
|
+
*
|
|
154
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
155
|
+
* {@link assertParameters} or {@link validateParameters} instead.
|
|
156
|
+
*
|
|
157
|
+
* @template T Target function type
|
|
158
|
+
* @param func Target function to assert
|
|
159
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
160
|
+
* @returns The wrapper function with type assertions
|
|
161
|
+
* @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
|
|
162
|
+
*
|
|
163
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
164
|
+
*/
|
|
165
|
+
declare function assertEqualsParameters<T extends (...args: unknown[]) => unknown>(func: T, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;
|
|
166
|
+
declare const assertEqualsParametersPure: typeof assertEqualsParameters;
|
|
167
|
+
export { assertEqualsParametersPure as assertEqualsParameters };
|
|
168
|
+
/**
|
|
169
|
+
* Asserts return value with strict equality.
|
|
170
|
+
*
|
|
171
|
+
* Asserts a function, by wrapping the function and checking its return value through
|
|
172
|
+
* {@link assertEquals} function. If the return value does not match the expected type,
|
|
173
|
+
* it throws an {@link TypeGuardError} or a custom error generated by the *errorFactory*
|
|
174
|
+
* parameter.
|
|
175
|
+
*
|
|
176
|
+
* For reference, {@link TypeGuardError.path} would be a little bit different with
|
|
177
|
+
* individual {@link assertEquals} function. If the {@link TypeGuardError} occurs from
|
|
178
|
+
* the return value, the path would start from `$input.return`.
|
|
179
|
+
*
|
|
180
|
+
* By the way, if what you want is not just finding the 1st type error through
|
|
181
|
+
* assertion, but also finding every type errors, then use {@link validateEqualsReturn}
|
|
182
|
+
* instead. Otherwise, what you want is not only asserting return value, but also
|
|
183
|
+
* asserting parameters, you can use {@link assertEqualsFunction} instead.
|
|
184
|
+
*
|
|
185
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
186
|
+
* {@link assertReturn} or {@link validateReturn} instead.
|
|
187
|
+
*
|
|
188
|
+
* @template T Target function type
|
|
189
|
+
* @param func Target function to assert
|
|
190
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
191
|
+
* @returns The wrapper function with type assertions
|
|
192
|
+
* @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
|
|
193
|
+
*
|
|
194
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
195
|
+
*/
|
|
196
|
+
declare function assertEqualsReturn<T extends (...args: unknown[]) => unknown>(func: T, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;
|
|
197
|
+
declare const assertEqualsReturnPure: typeof assertEqualsReturn;
|
|
198
|
+
export { assertEqualsReturnPure as assertEqualsReturn };
|
|
199
|
+
/**
|
|
200
|
+
* Validates a function.
|
|
201
|
+
*
|
|
202
|
+
* Validates a function, by wrapping the function and checking its parameters and
|
|
203
|
+
* return value through {@link validate} function. If some parameter or return value
|
|
204
|
+
* does not match the expected type, it returns {@link IValidation.IError} typed
|
|
205
|
+
* object. Otherwise there's no type error, it returns {@link IValidation.ISuccess}
|
|
206
|
+
* typed object instead.
|
|
207
|
+
*
|
|
208
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
209
|
+
* individual {@link validate} function. If the {@link IValidation.IError} occurs from
|
|
210
|
+
* some parameter, the path would start from `$input.parameters[number]`. Otherwise
|
|
211
|
+
* the path would start from `$input.return`.
|
|
212
|
+
*
|
|
213
|
+
* - `$input.parameters[0].~`
|
|
214
|
+
* - `$input.return.~`
|
|
215
|
+
*
|
|
216
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
217
|
+
* the 1st type error, then use {@link assertFunction} instead. Otherwise, what you
|
|
218
|
+
* want is just validating parameters or return value only, you can use
|
|
219
|
+
* {@link validateParameters} or {@link validateReturn} instead.
|
|
220
|
+
*
|
|
221
|
+
* On the other hand, if you don't want to allow any superfluous properties, utilize
|
|
222
|
+
* {@link validateEqualsFunction} or {@link assertEqualsFunction} instead.
|
|
223
|
+
*
|
|
224
|
+
* @template T Target function type
|
|
225
|
+
* @param func Target function to validate
|
|
226
|
+
* @returns The wrapper function with type validations
|
|
227
|
+
*
|
|
228
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
229
|
+
*/
|
|
230
|
+
declare function validateFunction<T extends (...args: unknown[]) => unknown>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
231
|
+
declare const validateFunctionPure: typeof validateFunction;
|
|
232
|
+
export { validateFunctionPure as validateFunction };
|
|
233
|
+
/**
|
|
234
|
+
* Validates parameters.
|
|
235
|
+
*
|
|
236
|
+
* Validates a function, by wrapping the function and checking its parameters through
|
|
237
|
+
* {@link validate} function. If some parameter does not match the expected type, it
|
|
238
|
+
* returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
239
|
+
* it returns {@link IValidation.ISuccess} typed object instead.
|
|
240
|
+
*
|
|
241
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
242
|
+
* individual {@link validate} function. If the {@link IValidation.IError} occurs from
|
|
243
|
+
* some parameter, the path would start from `$input.parameters[number]`.
|
|
244
|
+
*
|
|
245
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
246
|
+
* the 1st type error, then use {@link assertParameters} instead. Otherwise, what you
|
|
247
|
+
* want is not only validating parameters, but also validating return value, you can
|
|
248
|
+
* use {@link validateFunction} instead.
|
|
249
|
+
*
|
|
250
|
+
* On the other hand, if you don't want to allow any superfluous properties, utilize
|
|
251
|
+
* {@link validateEqualsParameters} or {@link assertEqualsParameters} instead.
|
|
252
|
+
*
|
|
253
|
+
* @template T Target function type
|
|
254
|
+
* @param func Target function to validate
|
|
255
|
+
* @returns The wrapper function with type validations
|
|
256
|
+
*
|
|
257
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
258
|
+
*/
|
|
259
|
+
declare function validateReturn<T extends (...args: unknown[]) => unknown>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
260
|
+
declare const validateReturnPure: typeof validateReturn;
|
|
261
|
+
export { validateReturnPure as validateReturn };
|
|
262
|
+
/**
|
|
263
|
+
* Validates a function with strict equality.
|
|
264
|
+
*
|
|
265
|
+
* Validates a function with strict equality, by wrapping the function and checking
|
|
266
|
+
* its parameters and return value through {@link validateEquals} function. If some
|
|
267
|
+
* parameter or return value does not match the expected type, it returns
|
|
268
|
+
* {@link IValidation.IError} typed object. Otherwise there's no type error, it
|
|
269
|
+
* returns {@link IValidation.ISuccess} typed object instead.
|
|
270
|
+
*
|
|
271
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
272
|
+
* individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
|
|
273
|
+
* from some parameter, the path would start from `$input.parameters[number]`. Otherwise
|
|
274
|
+
* the path would start from `$input.return`.
|
|
275
|
+
*
|
|
276
|
+
* - `$input.parameters[0].~`
|
|
277
|
+
* - `$input.return.~`
|
|
278
|
+
*
|
|
279
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
280
|
+
* the 1st type error, then use {@link assertEqualsFunction} instead. Otherwise, what
|
|
281
|
+
* you want is just validating parameters or return value only, you can use
|
|
282
|
+
* {@link validateEqualsParameters} or {@link validateEqualsReturn} instead.
|
|
283
|
+
*
|
|
284
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
285
|
+
* {@link validateFunction} or {@link assertFunction} instead.
|
|
286
|
+
*
|
|
287
|
+
* @template T Target function type
|
|
288
|
+
* @param func Target function to validate
|
|
289
|
+
* @returns The wrapper function with type validations
|
|
290
|
+
*
|
|
291
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
292
|
+
*/
|
|
293
|
+
declare function validateEqualsFunction<T extends (...args: unknown[]) => unknown>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
294
|
+
declare const validateEqualsFunctionPure: typeof validateEqualsFunction;
|
|
295
|
+
export { validateEqualsFunctionPure as validateEqualsFunction };
|
|
296
|
+
/**
|
|
297
|
+
* Validates parameters with strict equality.
|
|
298
|
+
*
|
|
299
|
+
* Validates a function, by wrapping the function and checking its parameters through
|
|
300
|
+
* {@link validateEquals} function. If some parameter does not match the expected type,
|
|
301
|
+
* it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
302
|
+
* it returns {@link IValidation.ISuccess} typed object instead.
|
|
303
|
+
*
|
|
304
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
305
|
+
* individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
|
|
306
|
+
* from some parameter, the path would start from `$input.parameters[number]`.
|
|
307
|
+
*
|
|
308
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
309
|
+
* the 1st type error, then use {@link assertEqualsParameters} instead. Otherwise,
|
|
310
|
+
* what you want is not only validating parameters, but also validating return value,
|
|
311
|
+
* you can use {@link validateEqualsFunction} instead.
|
|
312
|
+
*
|
|
313
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
314
|
+
* {@link validateParameters} or {@link assertParameters} instead.
|
|
315
|
+
*
|
|
316
|
+
* @template T Target function type
|
|
317
|
+
* @param func Target function to validate
|
|
318
|
+
* @returns The wrapper function with type validations
|
|
319
|
+
*
|
|
320
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
321
|
+
*/
|
|
322
|
+
declare function validateEqualsParameters<T extends (...args: unknown[]) => unknown>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
323
|
+
declare const validateEqualsParametersPure: typeof validateEqualsParameters;
|
|
324
|
+
export { validateEqualsParametersPure as validateEqualsParameters };
|
|
325
|
+
/**
|
|
326
|
+
* Validates return value with strict equality.
|
|
327
|
+
*
|
|
328
|
+
* Validates a function, by wrapping the function and checking its return value through
|
|
329
|
+
* {@link validateEquals} function. If the return value does not match the expected type,
|
|
330
|
+
* it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
331
|
+
* it returns {@link IValidation.ISuccess} typed object instead.
|
|
332
|
+
*
|
|
333
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
334
|
+
* individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
|
|
335
|
+
* from the return value, the path would start from `$input.return`.
|
|
336
|
+
*
|
|
337
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
338
|
+
* the 1st type error, then use {@link assertEqualsReturn} instead. Otherwise, what you
|
|
339
|
+
* want is not only validating return value, but also validating parameters, you can use
|
|
340
|
+
* {@link validateEqualsFunction} instead.
|
|
341
|
+
*
|
|
342
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
343
|
+
* {@link validateReturn} or {@link assertReturn} instead.
|
|
344
|
+
*
|
|
345
|
+
* @template T Target function type
|
|
346
|
+
* @param func Target function to validate
|
|
347
|
+
* @returns The wrapper function with type validations
|
|
348
|
+
*
|
|
349
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
350
|
+
*/
|
|
351
|
+
declare function validateEqualsReturn<T extends (...args: unknown[]) => unknown>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
352
|
+
declare const validateEqualsReturnPure: typeof validateEqualsReturn;
|
|
353
|
+
export { validateEqualsReturnPure as validateEqualsReturn };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.validateEqualsReturn = exports.validateEqualsParameters = exports.validateEqualsFunction = exports.validateReturn = exports.validateFunction = exports.assertEqualsReturn = exports.assertEqualsParameters = exports.assertEqualsFunction = exports.assertReturn = exports.assertParameters = exports.assertFunction = void 0;
|
|
27
|
+
var Namespace = __importStar(require("./functional/Namespace"));
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
function assertFunction() {
|
|
32
|
+
halt("assertFunction");
|
|
33
|
+
}
|
|
34
|
+
var assertFunctionPure = /** @__PURE__ */ Object.assign(assertFunction,
|
|
35
|
+
/** @__PURE__ */ Namespace.assert("functional.assertFunction"));
|
|
36
|
+
exports.assertFunction = assertFunctionPure;
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
function assertParameters() {
|
|
41
|
+
halt("assertParameters");
|
|
42
|
+
}
|
|
43
|
+
var assertParametersPure = /** @__PURE__ */ Object.assign(assertParameters,
|
|
44
|
+
/** @__PURE__ */ Namespace.assert("functional.assertParameters"));
|
|
45
|
+
exports.assertParameters = assertParametersPure;
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
function assertReturn() {
|
|
50
|
+
halt("assertReturn");
|
|
51
|
+
}
|
|
52
|
+
var assertReturnPure = /** @__PURE__ */ Object.assign(assertReturn, /** @__PURE__ */ Namespace.assert("functional.assertReturn"));
|
|
53
|
+
exports.assertReturn = assertReturnPure;
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
function assertEqualsFunction() {
|
|
58
|
+
halt("assertEqualsFunction");
|
|
59
|
+
}
|
|
60
|
+
var assertEqualsFunctionPure = /** @__PURE__ */ Object.assign(assertEqualsFunction,
|
|
61
|
+
/** @__PURE__ */ Namespace.assert("functional.assertEqualsFunction"));
|
|
62
|
+
exports.assertEqualsFunction = assertEqualsFunctionPure;
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
function assertEqualsParameters() {
|
|
67
|
+
halt("assertEqualsParameters");
|
|
68
|
+
}
|
|
69
|
+
var assertEqualsParametersPure = /** @__PURE__ */ Object.assign(assertEqualsParameters,
|
|
70
|
+
/** @__PURE__ */ Namespace.assert("functional.assertEqualsParameters"));
|
|
71
|
+
exports.assertEqualsParameters = assertEqualsParametersPure;
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
function assertEqualsReturn() {
|
|
76
|
+
halt("assertEqualsReturn");
|
|
77
|
+
}
|
|
78
|
+
var assertEqualsReturnPure = /** @__PURE__ */ Object.assign(assertEqualsReturn,
|
|
79
|
+
/** @__PURE__ */ Namespace.assert("functional.assertEqualsReturn"));
|
|
80
|
+
exports.assertEqualsReturn = assertEqualsReturnPure;
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
function validateFunction() {
|
|
85
|
+
halt("validateFunction");
|
|
86
|
+
}
|
|
87
|
+
var validateFunctionPure = /** @__PURE__ */ Object.assign(validateFunction, /** @__PURE__ */ Namespace.validate());
|
|
88
|
+
exports.validateFunction = validateFunctionPure;
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
function validateReturn() {
|
|
93
|
+
halt("validateReturn");
|
|
94
|
+
}
|
|
95
|
+
var validateReturnPure = /** @__PURE__ */ Object.assign(validateReturn, /** @__PURE__ */ Namespace.validate());
|
|
96
|
+
exports.validateReturn = validateReturnPure;
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
function validateEqualsFunction() {
|
|
101
|
+
halt("validateEqualsFunction");
|
|
102
|
+
}
|
|
103
|
+
var validateEqualsFunctionPure = /** @__PURE__ */ Object.assign(validateEqualsFunction, /** @__PURE__ */ Namespace.validate());
|
|
104
|
+
exports.validateEqualsFunction = validateEqualsFunctionPure;
|
|
105
|
+
/**
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
function validateEqualsParameters() {
|
|
109
|
+
halt("validateEqualsParameters");
|
|
110
|
+
}
|
|
111
|
+
var validateEqualsParametersPure = /** @__PURE__ */ Object.assign(validateEqualsParameters, /** @__PURE__ */ Namespace.validate());
|
|
112
|
+
exports.validateEqualsParameters = validateEqualsParametersPure;
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
function validateEqualsReturn() {
|
|
117
|
+
halt("validateEqualsReturn");
|
|
118
|
+
}
|
|
119
|
+
var validateEqualsReturnPure = /** @__PURE__ */ Object.assign(validateEqualsReturn, /** @__PURE__ */ Namespace.validate());
|
|
120
|
+
exports.validateEqualsReturn = validateEqualsReturnPure;
|
|
121
|
+
/* -----------------------------------------------------------
|
|
122
|
+
HALTER
|
|
123
|
+
----------------------------------------------------------- */
|
|
124
|
+
/**
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
function halt(name) {
|
|
128
|
+
throw new Error("Error on typia.functional.".concat(name, "(): no transform has been configured. Read and follow https://typia.io/docs/setup please."));
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=functional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functional.js","sourceRoot":"","sources":["../src/functional.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAoD;AAiDpD;;GAEG;AACH,SAAS,cAAc;IACrB,IAAI,CAAC,gBAAgB,CAAC,CAAC;AACzB,CAAC;AACD,IAAM,kBAAkB,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAIvD,cAAc;AACd,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAC/D,CAAC;AAC6B,4CAAc;AAmC7C;;GAEG;AACH,SAAS,gBAAgB;IACvB,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAC3B,CAAC;AACD,IAAM,oBAAoB,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAIzD,gBAAgB;AAChB,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC,6BAA6B,CAAC,CACjE,CAAC;AAC+B,gDAAgB;AAmCjD;;GAEG;AACH,SAAS,YAAY;IACnB,IAAI,CAAC,cAAc,CAAC,CAAC;AACvB,CAAC;AACD,IAAM,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAGrD,YAAY,EAAE,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC;AACjD,wCAAY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;IAC7B,IAAI,CAAC,wBAAwB,CAAC,CAAC;AACjC,CAAC;AACD,IAAM,0BAA0B,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAG/D,sBAAsB,EAAE,gBAAgB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC1B,4DAAsB;AAoC7D;;GAEG;AACH,SAAS,wBAAwB;IAC/B,IAAI,CAAC,0BAA0B,CAAC,CAAC;AACnC,CAAC;AACD,IAAM,4BAA4B,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAGjE,wBAAwB,EAAE,gBAAgB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC1B,gEAAwB;AAoCjE;;GAEG;AACH,SAAS,oBAAoB;IAC3B,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAC/B,CAAC;AACD,IAAM,wBAAwB,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAG7D,oBAAoB,EAAE,gBAAgB,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC1B,wDAAoB;AAEzD;;8DAE8D;AAC9D;;GAEG;AACH,SAAS,IAAI,CAAC,IAAY;IACxB,MAAM,IAAI,KAAK,CACb,oCAA6B,IAAI,8FAA2F,CAC7H,CAAC;AACJ,CAAC"}
|
package/lib/module.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IRandomGenerator } from "./IRandomGenerator";
|
|
|
3
3
|
import { IValidation } from "./IValidation";
|
|
4
4
|
import { Resolved } from "./Resolved";
|
|
5
5
|
import { TypeGuardError } from "./TypeGuardError";
|
|
6
|
+
export * as functional from "./functional";
|
|
6
7
|
export * as http from "./http";
|
|
7
8
|
export * as json from "./json";
|
|
8
9
|
export * as misc from "./misc";
|
package/lib/module.js
CHANGED
|
@@ -26,8 +26,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createRandom = exports.createValidateEquals = exports.createEquals = exports.createAssertGuardEquals = exports.createAssertEquals = exports.createValidate = exports.createIs = exports.createAssertGuard = exports.createAssert = exports.random = exports.validateEquals = exports.equals = exports.assertGuardEquals = exports.assertEquals = exports.validate = exports.is = exports.assertGuard = exports.assert = exports.tags = exports.reflect = exports.protobuf = exports.notations = exports.misc = exports.json = exports.http = void 0;
|
|
29
|
+
exports.createRandom = exports.createValidateEquals = exports.createEquals = exports.createAssertGuardEquals = exports.createAssertEquals = exports.createValidate = exports.createIs = exports.createAssertGuard = exports.createAssert = exports.random = exports.validateEquals = exports.equals = exports.assertGuardEquals = exports.assertEquals = exports.validate = exports.is = exports.assertGuard = exports.assert = exports.tags = exports.reflect = exports.protobuf = exports.notations = exports.misc = exports.json = exports.http = exports.functional = void 0;
|
|
30
30
|
var Namespace = __importStar(require("./functional/Namespace"));
|
|
31
|
+
exports.functional = __importStar(require("./functional"));
|
|
31
32
|
exports.http = __importStar(require("./http"));
|
|
32
33
|
exports.json = __importStar(require("./json"));
|
|
33
34
|
exports.misc = __importStar(require("./misc"));
|
package/lib/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAoD;AAQpD,+CAA+B;AAC/B,+CAA+B;AAC/B,+CAA+B;AAC/B,yDAAyC;AACzC,uDAAuC;AACvC,qDAAqC;AACrC,+CAA+B;AAE/B,mEAAiD;AACjD,kEAAgD;AAChD,iEAA+C;AAC/C,6DAA2C;AAC3C,mDAAiC;AACjC,qDAAmC;AACnC,gDAA8B;AAC9B,mDAAiC;AAEjC,8CAA4B;AAC5B,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,8CAA4B;AA2D5B;;GA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AI,CAAC,yBAAyB,CAAC,CAAC;AAClC,CAAC;AACD,IAAM,2BAA2B,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAGhE,uBAAuB,EAAE,qBAAqB,CAAC,CAAC;AACV,8DAAuB;AAuB/D;;GAEG;AACH,SAAS,YAAY;IACnB,IAAI,CAAC,cAAc,CAAC,CAAC;AACvB,CAAC;AACD,IAAM,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAGrD,YAAY,EAAE,UAAU,CAAC,CAAC;AACC,wCAAY;AAuBzC;;GAEG;AACH,SAAS,oBAAoB;IAC3B,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAC/B,CAAC;AACD,IAAM,wBAAwB,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAG7D,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;AACP,wDAAoB;AA2BzD;;GAEG;AACH,SAAS,YAAY;IACnB,IAAI,CAAC,cAAc,CAAC,CAAC;AACvB,CAAC;AACD,IAAM,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAGrD,YAAY,EAAE,UAAU,CAAC,CAAC;AACC,wCAAY;AAEzC;;GAEG;AACH,SAAS,IAAI,CAAC,IAAY;IACxB,MAAM,IAAI,KAAK,CACb,yBAAkB,IAAI,8FAA2F,CAClH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="ts-expose-internals/typescript" />
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { IProject } from "../../transformers/IProject";
|
|
4
|
+
export declare namespace FunctionalAssertFunctionProgrammer {
|
|
5
|
+
const write: (project: IProject) => (modulo: ts.LeftHandSideExpression) => (equals: boolean) => (expression: ts.Expression, declaration: ts.FunctionDeclaration, init?: ts.Expression) => ts.FunctionDeclaration;
|
|
6
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FunctionalAssertFunctionProgrammer = void 0;
|
|
7
|
+
var typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
var FunctionalAssertParametersProgrammer_1 = require("./FunctionalAssertParametersProgrammer");
|
|
9
|
+
var FunctionalAssertReturnProgrammer_1 = require("./FunctionalAssertReturnProgrammer");
|
|
10
|
+
var FunctionalAssertFunctionProgrammer;
|
|
11
|
+
(function (FunctionalAssertFunctionProgrammer) {
|
|
12
|
+
FunctionalAssertFunctionProgrammer.write = function (project) {
|
|
13
|
+
return function (modulo) {
|
|
14
|
+
return function (equals) {
|
|
15
|
+
return function (expression, declaration, init) {
|
|
16
|
+
var params = FunctionalAssertParametersProgrammer_1.FunctionalAssertParametersProgrammer.prepare(project)(modulo)(equals)(declaration, init);
|
|
17
|
+
var output = FunctionalAssertReturnProgrammer_1.FunctionAssertReturnProgrammer.prepare(project)(modulo)(equals)(expression, declaration, init);
|
|
18
|
+
return typescript_1.default.factory.createFunctionDeclaration(output.async
|
|
19
|
+
? [typescript_1.default.factory.createModifier(typescript_1.default.SyntaxKind.AsyncKeyword)]
|
|
20
|
+
: undefined, undefined, undefined, undefined, declaration.parameters, declaration.type, typescript_1.default.factory.createBlock([
|
|
21
|
+
params.assert,
|
|
22
|
+
output.assert,
|
|
23
|
+
params.call,
|
|
24
|
+
output.variable,
|
|
25
|
+
output.call,
|
|
26
|
+
output.returns,
|
|
27
|
+
], true));
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
})(FunctionalAssertFunctionProgrammer || (exports.FunctionalAssertFunctionProgrammer = FunctionalAssertFunctionProgrammer = {}));
|
|
33
|
+
//# sourceMappingURL=FunctionalAssertFunctionProgrammer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionalAssertFunctionProgrammer.js","sourceRoot":"","sources":["../../../src/programmers/functional/FunctionalAssertFunctionProgrammer.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,+FAA8F;AAC9F,uFAAoF;AAEpF,IAAiB,kCAAkC,CAsClD;AAtCD,WAAiB,kCAAkC;IACpC,wCAAK,GAChB,UAAC,OAAiB;QAClB,OAAA,UAAC,MAAiC;YAClC,OAAA,UAAC,MAAe;gBAChB,OAAA,UACE,UAAyB,EACzB,WAAmC,EACnC,IAAoB;oBAEpB,IAAM,MAAM,GAAG,2EAAoC,CAAC,OAAO,CAAC,OAAO,CAAC,CAClE,MAAM,CACP,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;oBAC7B,IAAM,MAAM,GAAG,iEAA8B,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CACpE,MAAM,CACP,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;oBACjC,OAAO,oBAAE,CAAC,OAAO,CAAC,yBAAyB,CACzC,MAAM,CAAC,KAAK;wBACV,CAAC,CAAC,CAAC,oBAAE,CAAC,OAAO,CAAC,cAAc,CAAC,oBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;wBACzD,CAAC,CAAC,SAAS,EACb,SAAS,EACT,SAAS,EACT,SAAS,EACT,WAAW,CAAC,UAAU,EACtB,WAAW,CAAC,IAAI,EAChB,oBAAE,CAAC,OAAO,CAAC,WAAW,CACpB;wBACE,MAAM,CAAC,MAAM;wBACb,MAAM,CAAC,MAAM;wBACb,MAAM,CAAC,IAAI;wBACX,MAAM,CAAC,QAAQ;wBACf,MAAM,CAAC,IAAI;wBACX,MAAM,CAAC,OAAO;qBACf,EACD,IAAI,CACL,CACF,CAAC;gBACJ,CAAC;YAhCD,CAgCC;QAjCD,CAiCC;IAlCD,CAkCC,CAAC;AACN,CAAC,EAtCgB,kCAAkC,kDAAlC,kCAAkC,QAsClD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="ts-expose-internals/typescript" />
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { IProject } from "../../transformers/IProject";
|
|
4
|
+
export declare namespace FunctionalAssertParametersProgrammer {
|
|
5
|
+
const write: (project: IProject) => (modulo: ts.LeftHandSideExpression) => (equals: boolean) => (expression: ts.Expression, declaration: ts.FunctionDeclaration, init?: ts.Expression) => ts.FunctionDeclaration;
|
|
6
|
+
const prepare: (project: IProject) => (modulo: ts.LeftHandSideExpression) => (equals: boolean) => (declaration: ts.FunctionDeclaration, init?: ts.Expression) => {
|
|
7
|
+
assert: ts.VariableStatement;
|
|
8
|
+
call: ts.ExpressionStatement;
|
|
9
|
+
type: ts.Type;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FunctionalAssertParametersProgrammer = void 0;
|
|
7
|
+
var typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
var StatementFactory_1 = require("../../factories/StatementFactory");
|
|
9
|
+
var AssertProgrammer_1 = require("../AssertProgrammer");
|
|
10
|
+
var FunctionalAssertParametersProgrammer;
|
|
11
|
+
(function (FunctionalAssertParametersProgrammer) {
|
|
12
|
+
FunctionalAssertParametersProgrammer.write = function (project) {
|
|
13
|
+
return function (modulo) {
|
|
14
|
+
return function (equals) {
|
|
15
|
+
return function (expression, declaration, init) {
|
|
16
|
+
var _a = FunctionalAssertParametersProgrammer.prepare(project)(modulo)(equals)(declaration, init), assert = _a.assert, call = _a.call;
|
|
17
|
+
var async = (function () {
|
|
18
|
+
if (declaration.type === undefined)
|
|
19
|
+
return false;
|
|
20
|
+
var type = project.checker.getTypeFromTypeNode(declaration.type);
|
|
21
|
+
return type.isTypeParameter() && type.symbol.name === "Promise";
|
|
22
|
+
})();
|
|
23
|
+
return typescript_1.default.factory.createFunctionDeclaration(async
|
|
24
|
+
? [typescript_1.default.factory.createModifier(typescript_1.default.SyntaxKind.AsyncKeyword)]
|
|
25
|
+
: undefined, undefined, undefined, undefined, declaration.parameters, declaration.type, typescript_1.default.factory.createBlock([
|
|
26
|
+
assert,
|
|
27
|
+
call,
|
|
28
|
+
typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createCallExpression(expression, undefined, declaration.parameters.map(function (p) {
|
|
29
|
+
return typescript_1.default.factory.createIdentifier(p.name.getText());
|
|
30
|
+
}))),
|
|
31
|
+
], true));
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
FunctionalAssertParametersProgrammer.prepare = function (project) {
|
|
37
|
+
return function (modulo) {
|
|
38
|
+
return function (equals) {
|
|
39
|
+
return function (declaration, init) {
|
|
40
|
+
var typeNode = typescript_1.default.factory.createTypeLiteralNode([
|
|
41
|
+
typescript_1.default.factory.createPropertySignature(undefined, "parameters", undefined, typescript_1.default.factory.createTupleTypeNode(declaration.parameters.map(function (p) { return p.type; }))),
|
|
42
|
+
]);
|
|
43
|
+
var type = project.checker.getTypeFromTypeNode(typeNode);
|
|
44
|
+
var assert = StatementFactory_1.StatementFactory.constant("assert", AssertProgrammer_1.AssertProgrammer.write(project)(modulo)(equals)(type, undefined, init));
|
|
45
|
+
var call = typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("assert"), undefined, [
|
|
46
|
+
typescript_1.default.factory.createObjectLiteralExpression([
|
|
47
|
+
typescript_1.default.factory.createPropertyAssignment("parameters", typescript_1.default.factory.createArrayLiteralExpression(declaration.parameters.map(function (p) {
|
|
48
|
+
return typescript_1.default.factory.createIdentifier(p.name.getText());
|
|
49
|
+
}))),
|
|
50
|
+
], true),
|
|
51
|
+
]));
|
|
52
|
+
return { assert: assert, call: call, type: type };
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
})(FunctionalAssertParametersProgrammer || (exports.FunctionalAssertParametersProgrammer = FunctionalAssertParametersProgrammer = {}));
|
|
58
|
+
//# sourceMappingURL=FunctionalAssertParametersProgrammer.js.map
|