@glutinum/cli 1.0.0-beta.7 → 1.0.0-beta.8

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.
@@ -1,1623 +1,25 @@
1
1
 
2
- import { Union } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
3
- import { union_type, class_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
4
- import { contains as contains_2, item as item_4 } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
5
- import { tryReadLiteral, resolvedBaseTypeArguments, resolveValueAlias, declaredName, isFromEsLib, isFromEs5Lib, crossesNamespace, modulePathForSymbol, knownExternalTypeNames, isExternalToPackages, importedName, typeLiteralId, readTypeArguments, getFullNameOrEmpty, defaultTypeArguments, isTupleType, withInProgress, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, primitiveOfFlags, entityNameText, mainDeclaration, resolveAlias, symbolAtLocation, identifierText, $007CHasTypeFlags$007C_$007C, enclosingDeclarationOf, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags } from "./Utils.js";
6
- import { Report_readerError_Z19516DCE } from "./Report.js";
7
- import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
8
- import { forAll as forAll_1, concat as concat_1, head, tail, item as item_5, contains, filter as filter_1, map as map_1, ofArray, length, truncate, isEmpty, exists as exists_1, choose, cons, collect as collect_1, singleton, tryFind, fold, append, reverse, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
9
- import { GlueConstructSignature, GlueConditionalType, GlueTypeParameter, GlueThisType, GlueFunctionType, GlueTypeReference, GlueReadonly, GlueRecord, GlueUtilityType, GlueInterface, GlueSubstitution_substituteMember, GlueSubstitution_mentionedTypeParameters, GlueTypeLiteral, GlueTypeUnion, GlueLiteral, GlueClassDeclaration, GluePrimitive, GlueType, GlueMethod, GlueMethodSignature, GlueMember, GlueProperty, GlueAccessor } from "../GlueAST.js";
10
- import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
11
- import { unwrap, orElse, toArray, defaultArg, value as value_6 } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
12
- import { sortByDescending, contains as contains_1, choose as choose_1, ofList as ofList_1, forAll, tryHead, tryFindIndex, collect as collect_2, empty as empty_3, singleton as singleton_1, append as append_1, delay, filter, map, exists, toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
13
- import { FSharpMap__get_IsEmpty, ofList, FSharpMap__get_Count, FSharpMap__get_Values, FSharpMap__TryFind, empty as empty_1, FSharpMap__ContainsKey, FSharpMap__Add } from "../../fable_modules/fable-library-js.5.17.2/Map.js";
14
- import { Exception, structuralHash, disposeSafe, stringHash, safeHash, equals, comparePrimitives } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
15
- import { ts } from "@ts-morph/bootstrap";
16
- import { empty as empty_2, FSharpSet__Add, FSharpSet__Contains } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
17
- import { List_distinctBy, List_distinct } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
18
- import { sanitizeTypeName } from "../Utils/Naming.js";
19
- import { readTypeQueryNode } from "./TypeQueryNode.js";
20
- import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
21
-
22
- class IntersectionTypePropertyResult extends Union {
23
- constructor(tag, fields) {
24
- super();
25
- this.tag = tag;
26
- this.fields = fields;
27
- }
28
- cases() {
29
- return ["Single", "WithoutDeclaration", "ForceAny"];
30
- }
31
- static ForceAny = new IntersectionTypePropertyResult(2, []);
32
- }
33
-
34
- function IntersectionTypePropertyResult_$reflection() {
35
- return union_type("Glutinum.Converter.Reader.TypeNode.IntersectionTypePropertyResult", [], IntersectionTypePropertyResult, () => [[["Item1", class_type("TypeScript.Ts.Symbol")], ["Item2", class_type("TypeScript.Ts.Declaration")]], [["Item", class_type("TypeScript.Ts.Symbol")]], []]);
36
- }
37
-
38
- function landingOf(reader, node) {
39
- if (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing.length === 0) {
40
- return node;
41
- }
42
- else {
43
- return item_4(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing.length - 1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing);
44
- }
45
- }
46
-
47
- function readPropertyWithoutDeclaration(reader, contextNode, property) {
48
- let matchValue_1;
49
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeOfSymbol(property);
50
- const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
51
- if (matchValue == null) {
52
- const item = Report_readerError_Z19516DCE("type node", concat("Could not resolve the type of the property \'", property.name, "\'"), contextNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 59);
53
- const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
54
- void (objectArg.push(item));
55
- return undefined;
56
- }
57
- else {
58
- const typeNode = matchValue;
59
- const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
60
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](contextNode);
61
- let propertyType;
62
- try {
63
- propertyType = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
64
- }
65
- finally {
66
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
67
- }
68
- return new GlueMember(/* Property */ 1, [new GlueProperty(property.name, empty(), propertyType, false, (matchValue_1 = property.flags, $007CHasSymbolFlags$007C_$007C(16777216, matchValue_1) != null), GlueAccessor.ReadWrite, false)]);
69
- }
70
- }
71
-
72
- function readInstantiatedMember(reader, contextNode, property, declaration) {
73
- const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
74
- const instantiatedType = checker.getTypeOfSymbol(property);
75
- const isInstantiated = !Operators_IsNull(declaration.symbol) && !(instantiatedType === checker.getTypeOfSymbol(declaration.symbol));
76
- const declaredMember = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration);
77
- if (!isInstantiated) {
78
- return declaredMember;
79
- }
80
- else {
81
- const matchValue = checker.typeToTypeNode(instantiatedType, enclosingDeclarationOf(contextNode), typeNodeBuilderFlags);
82
- if (matchValue != null) {
83
- const typeNode = matchValue;
84
- const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
85
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](contextNode);
86
- let instantiatedMember;
87
- try {
88
- instantiatedMember = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
89
- }
90
- finally {
91
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
92
- }
93
- let matchResult, info, typ, functionType, info_1, functionType_1, info_2, declaredMember_1;
94
- switch (declaredMember.tag) {
95
- case 1: {
96
- matchResult = 0;
97
- info = declaredMember.fields[0];
98
- typ = instantiatedMember;
99
- break;
100
- }
101
- case 6: {
102
- if (instantiatedMember.tag === 15) {
103
- matchResult = 1;
104
- functionType = instantiatedMember.fields[0];
105
- info_1 = declaredMember.fields[0];
106
- }
107
- else {
108
- matchResult = 3;
109
- declaredMember_1 = declaredMember;
110
- }
111
- break;
112
- }
113
- case 0: {
114
- if (instantiatedMember.tag === 15) {
115
- matchResult = 2;
116
- functionType_1 = instantiatedMember.fields[0];
117
- info_2 = declaredMember.fields[0];
118
- }
119
- else {
120
- matchResult = 3;
121
- declaredMember_1 = declaredMember;
122
- }
123
- break;
124
- }
125
- default: {
126
- matchResult = 3;
127
- declaredMember_1 = declaredMember;
128
- }
129
- }
130
- switch (matchResult) {
131
- case 0:
132
- return new GlueMember(/* Property */ 1, [new GlueProperty(info.Name, info.Documentation, typ, info.IsStatic, info.IsOptional, info.Accessor, info.IsPrivate)]);
133
- case 1:
134
- return new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature(info_1.Name, info_1.Documentation, info_1.TypeParameters, functionType.Parameters, functionType.Type, info_1.IsOptional)]);
135
- case 2:
136
- return new GlueMember(/* Method */ 0, [new GlueMethod(info_2.Name, info_2.Documentation, info_2.TypeParameters, functionType_1.Parameters, functionType_1.Type, info_2.IsOptional, info_2.IsStatic)]);
137
- default:
138
- return declaredMember_1;
139
- }
140
- }
141
- else {
142
- return declaredMember;
143
- }
144
- }
145
- }
146
-
147
- function isLibraryName(reader, name) {
148
- const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
149
- if (matchValue == null) {
150
- return false;
151
- }
152
- else {
153
- return matchValue.IsLibraryName(name);
154
- }
155
- }
156
-
157
- function isDeferredConditional(typ) {
158
- const matchValue = typ.flags;
159
- if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
160
- return true;
161
- }
162
- else {
163
- return false;
164
- }
165
- }
166
-
167
- function isParseTreeNode(node) {
168
- return (node.flags & 16) === 0;
169
- }
170
-
171
- function typeParametersInScope(reader, typeNode) {
172
- const collect = (node_mut, acc_mut) => {
173
- collect:
174
- while (true) {
175
- const node = node_mut, acc = acc_mut;
176
- let option_1;
177
- if (Operators_IsNull(node)) {
178
- return reverse(acc);
179
- }
180
- else if (((Operators_IsNull(node.parent) && (node.pos < 0)) && (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]() != null)) && !(node === value_6(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]()))) {
181
- node_mut = value_6(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]());
182
- acc_mut = acc;
183
- continue collect;
184
- }
185
- else if (node.kind === 266) {
186
- return reverse(acc);
187
- }
188
- else {
189
- const own_1 = defaultArg((option_1 = (isParseTreeNode(node) ? node.typeParameters : undefined), (option_1 != null) ? toList(option_1) : undefined), empty());
190
- node_mut = node.parent;
191
- acc_mut = append(reverse(own_1), acc);
192
- continue collect;
193
- }
194
- break;
195
- }
196
- };
197
- return collect(typeNode.parent, empty());
198
- }
199
-
200
- function isDeclaredByType(typeParameter) {
201
- const parent = typeParameter.parent;
202
- if (!Operators_IsNull(parent)) {
203
- const matchValue = parent.kind;
204
- switch (matchValue) {
205
- case 232:
206
- case 264:
207
- case 265:
208
- return true;
209
- default:
210
- return false;
211
- }
212
- }
213
- else {
214
- return false;
215
- }
216
- }
217
-
218
- function boundTypeParameters(reader, typeNode) {
219
- return fold((bound, typeParameter) => {
220
- let constraint_, default_;
221
- const name = identifierText(typeParameter.name);
222
- let binding;
223
- const matchValue = typeParameter.default;
224
- const matchValue_1 = typeParameter.constraint;
225
- let matchResult, default__1, constraint__1;
226
- if (matchValue == null) {
227
- if (matchValue_1 != null) {
228
- if ((constraint_ = matchValue_1, constraint_.kind !== 199)) {
229
- matchResult = 2;
230
- constraint__1 = matchValue_1;
231
- }
232
- else {
233
- matchResult = 3;
234
- }
235
- }
236
- else {
237
- matchResult = 3;
238
- }
239
- }
240
- else if ((default_ = matchValue, isDeclaredByType(typeParameter) && (default_.kind !== 133))) {
241
- matchResult = 0;
242
- default__1 = matchValue;
243
- }
244
- else {
245
- matchResult = 1;
246
- }
247
- switch (matchResult) {
248
- case 0: {
249
- binding = default__1;
250
- break;
251
- }
252
- case 1: {
253
- binding = undefined;
254
- break;
255
- }
256
- case 2: {
257
- binding = constraint__1;
258
- break;
259
- }
260
- default:
261
- binding = undefined;
262
- }
263
- let matchResult_1, binding_2;
264
- if (binding != null) {
265
- if (!FSharpMap__ContainsKey(bound, name)) {
266
- matchResult_1 = 0;
267
- binding_2 = binding;
268
- }
269
- else {
270
- matchResult_1 = 1;
271
- }
272
- }
273
- else {
274
- matchResult_1 = 1;
275
- }
276
- switch (matchResult_1) {
277
- case 0:
278
- return FSharpMap__Add(bound, name, binding_2);
279
- default:
280
- return bound;
281
- }
282
- }, empty_1({
283
- Compare: (x, y) => (comparePrimitives(x, y) | 0),
284
- }), typeParametersInScope(reader, typeNode));
285
- }
286
-
287
- function isAnyTypeParameter(reader, typeNode) {
288
- let option_1, _arg;
289
- if (typeNode.kind === 184) {
290
- const typeName = typeNode.typeName;
291
- if (typeName.kind === 80) {
292
- return exists((default_) => (default_.kind === 133), toArray((option_1 = tryFind((typeParameter) => (identifierText(typeParameter.name) === identifierText(typeName)), typeParametersInScope(reader, typeNode)), (option_1 != null) ? ((_arg = option_1, _arg.default)) : undefined)));
293
- }
294
- else {
295
- return false;
296
- }
297
- }
298
- else {
299
- return false;
300
- }
301
- }
302
-
303
- function mentionsBoundTypeParameter(bindings, typeNode) {
304
- let option_1;
305
- const mentions = (typeNode_1) => mentionsBoundTypeParameter(bindings, typeNode_1);
306
- const matchValue = typeNode.kind;
307
- switch (matchValue) {
308
- case 184: {
309
- const typeReferenceNode = typeNode;
310
- const typeName = typeReferenceNode.typeName;
311
- if ((typeName.kind === 80) && FSharpMap__ContainsKey(bindings, identifierText(typeName))) {
312
- return true;
313
- }
314
- else {
315
- return defaultArg((option_1 = typeReferenceNode.typeArguments, (option_1 != null) ? exists(mentions, option_1) : undefined), false);
316
- }
317
- }
318
- case 189:
319
- return mentions(typeNode.elementType);
320
- case 193:
321
- return exists(mentions, typeNode.types);
322
- case 195: {
323
- const conditionalTypeNode = typeNode;
324
- if ((mentions(conditionalTypeNode.checkType) ? true : mentions(conditionalTypeNode.extendsType)) ? true : mentions(conditionalTypeNode.trueType)) {
325
- return true;
326
- }
327
- else {
328
- return mentions(conditionalTypeNode.falseType);
329
- }
330
- }
331
- case 200: {
332
- const indexedAccessTypeNode = typeNode;
333
- if (mentions(indexedAccessTypeNode.objectType)) {
334
- return true;
335
- }
336
- else {
337
- return mentions(indexedAccessTypeNode.indexType);
338
- }
339
- }
340
- default:
341
- return false;
342
- }
343
- }
344
-
345
- function substituteBoundTypeParameters(bindings, typeNode) {
346
- const substitute = (typeNode_1) => substituteBoundTypeParameters(bindings, typeNode_1);
347
- const adopt = (synthesized) => ((function (ts, node, like, flag) {
348
- Object.assign(node, { flags: node.flags & ~flag, pos: like.pos, end: like.end, parent: like.parent });
349
- ts.forEachChild(node, function (child) {
350
- if ((child.flags & flag) !== 0 && !child.parent) {
351
- Object.assign(child, { flags: child.flags & ~flag, pos: like.pos, end: like.end, parent: node });
352
- }
353
- });
354
- return node;
355
- })(ts, synthesized, typeNode, 16));
356
- const matchValue = typeNode.kind;
357
- switch (matchValue) {
358
- case 184: {
359
- const typeReferenceNode = typeNode;
360
- const typeName = typeReferenceNode.typeName;
361
- const matchValue_1 = typeReferenceNode.typeArguments;
362
- if (matchValue_1 != null) {
363
- const typeArguments = matchValue_1;
364
- return adopt((ts.factory).createTypeReferenceNode(typeReferenceNode.typeName, Array.from(map(substitute, typeArguments))));
365
- }
366
- else if (typeName.kind === 80) {
367
- return defaultArg(FSharpMap__TryFind(bindings, identifierText(typeName)), typeNode);
368
- }
369
- else {
370
- return typeNode;
371
- }
372
- }
373
- case 189:
374
- return adopt((ts.factory).createArrayTypeNode(substitute(typeNode.elementType)));
375
- case 193:
376
- return adopt((ts.factory).createUnionTypeNode(Array.from(map(substitute, typeNode.types))));
377
- case 195: {
378
- const conditionalTypeNode = typeNode;
379
- return adopt((ts.factory).createConditionalTypeNode(substitute(conditionalTypeNode.checkType), substitute(conditionalTypeNode.extendsType), substitute(conditionalTypeNode.trueType), substitute(conditionalTypeNode.falseType)));
380
- }
381
- case 200: {
382
- const indexedAccessTypeNode = typeNode;
383
- return adopt((ts.factory).createIndexedAccessTypeNode(substitute(indexedAccessTypeNode.objectType), substitute(indexedAccessTypeNode.indexType)));
384
- }
385
- default:
386
- return typeNode;
387
- }
388
- }
389
-
390
- function deferredConditionals(checker, depth, typ) {
391
- let depth_1;
392
- const matchValue = typ.flags;
393
- if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
394
- return singleton(typ);
395
- }
396
- else {
397
- let matchResult;
398
- if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
399
- matchResult = 0;
400
- }
401
- else if ($007CHasTypeFlags$007C_$007C(268435456, matchValue) != null) {
402
- matchResult = 0;
403
- }
404
- else {
405
- matchResult = 1;
406
- }
407
- switch (matchResult) {
408
- case 0:
409
- return collect_1((typ_1) => deferredConditionals(checker, depth, typ_1), toList(typ.types));
410
- default: {
411
- let matchResult_1;
412
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
413
- if ((depth < 8) && ((typ.objectFlags & 4) !== 0)) {
414
- matchResult_1 = 0;
415
- }
416
- else {
417
- matchResult_1 = 1;
418
- }
419
- }
420
- else {
421
- matchResult_1 = 1;
422
- }
423
- switch (matchResult_1) {
424
- case 0:
425
- return collect_1((depth_1 = ((depth + 1) | 0), (typ_2) => deferredConditionals(checker, depth_1, typ_2)), toList(checker.getTypeArguments(typ)));
426
- default:
427
- return empty();
428
- }
429
- }
430
- }
431
- }
432
- }
433
-
434
- function mentionedTypes(checker, depth, typ) {
435
- let option_1, matchValue, indexedAccess, conditional;
436
- let mentioned;
437
- const depth_1 = (depth + 1) | 0;
438
- mentioned = ((typ_1) => mentionedTypes(checker, depth_1, typ_1));
439
- if (depth > 8) {
440
- return empty();
441
- }
442
- else {
443
- return append(cons(typ, defaultArg((option_1 = typ.aliasTypeArguments, (option_1 != null) ? collect_1(mentioned, toList(option_1)) : undefined), empty())), (matchValue = typ.flags, ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) ? collect_1(mentioned, toList(typ.types)) : (($007CHasTypeFlags$007C_$007C(268435456, matchValue) != null) ? collect_1(mentioned, toList(typ.types)) : (($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) ? (((typ.objectFlags & 4) !== 0) ? collect_1(mentioned, toList(checker.getTypeArguments(typ))) : (($007CHasTypeFlags$007C_$007C(2097152, matchValue) != null) ? mentioned(typ.type) : (($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) ? ((indexedAccess = typ, append(mentioned(indexedAccess.objectType), mentioned(indexedAccess.indexType)))) : (($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) ? ((conditional = typ, append(mentioned(conditional.checkType), mentioned(conditional.extendsType)))) : empty())))) : (($007CHasTypeFlags$007C_$007C(2097152, matchValue) != null) ? mentioned(typ.type) : (($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) ? ((indexedAccess = typ, append(mentioned(indexedAccess.objectType), mentioned(indexedAccess.indexType)))) : (($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) ? ((conditional = typ, append(mentioned(conditional.checkType), mentioned(conditional.extendsType)))) : empty())))))));
444
- }
445
- }
446
-
447
- function typeParameterNamesOf(checker, typ) {
448
- return choose((mentioned) => {
449
- const matchValue = mentioned.flags;
450
- if ($007CHasTypeFlags$007C_$007C(524288, matchValue) != null) {
451
- return mentioned.symbol.name;
452
- }
453
- else {
454
- return undefined;
455
- }
456
- }, mentionedTypes(checker, 0, typ));
457
- }
458
-
459
- function isStillBound(checker, bound, typ) {
460
- const substitutes = toList(map((node_1) => checker.getTypeFromTypeNode(node_1), filter((node) => (node.kind === 184), FSharpMap__get_Values(bound))));
461
- const mentioned = mentionedTypes(checker, 0, typ);
462
- return exists_1((substitute) => exists_1((typ_1) => (typ_1 === substitute), mentioned), substitutes);
463
- }
464
-
465
- function resolveWithBindings(checker_mut, typeNode_mut, bindings_mut, bound_mut, typ_mut) {
466
- resolveWithBindings:
467
- while (true) {
468
- const checker = checker_mut, typeNode = typeNode_mut, bindings = bindings_mut, bound = bound_mut, typ = typ_mut;
469
- const conditionals = deferredConditionals(checker, 0, typ);
470
- if (isEmpty(conditionals)) {
471
- if (isStillBound(checker, bound, typ)) {
472
- return undefined;
473
- }
474
- else {
475
- return typ;
476
- }
477
- }
478
- else {
479
- const alreadyBound = FSharpMap__get_Count(bound) | 0;
480
- const bound_3 = fold((bound_1, conditional) => fold((bound_2, name) => {
481
- const matchValue = FSharpMap__TryFind(bindings, name);
482
- let matchResult, binding_1;
483
- if (matchValue != null) {
484
- if (!FSharpMap__ContainsKey(bound_2, name)) {
485
- matchResult = 0;
486
- binding_1 = matchValue;
487
- }
488
- else {
489
- matchResult = 1;
490
- }
491
- }
492
- else {
493
- matchResult = 1;
494
- }
495
- switch (matchResult) {
496
- case 0:
497
- return FSharpMap__Add(bound_2, name, binding_1);
498
- default:
499
- return bound_2;
500
- }
501
- }, bound_1, append(typeParameterNamesOf(checker, conditional.checkType), typeParameterNamesOf(checker, conditional.extendsType))), bound, conditionals);
502
- if ((FSharpMap__get_Count(bound_3) === alreadyBound) ? true : !mentionsBoundTypeParameter(bound_3, typeNode)) {
503
- return undefined;
504
- }
505
- else {
506
- checker_mut = checker;
507
- typeNode_mut = typeNode;
508
- bindings_mut = bindings;
509
- bound_mut = bound_3;
510
- typ_mut = checker.getTypeFromTypeNode(substituteBoundTypeParameters(bound_3, typeNode));
511
- continue resolveWithBindings;
512
- }
513
- }
514
- break;
515
- }
516
- }
517
-
518
- function standsForConditional(checker_mut, visited_mut, node_mut) {
519
- standsForConditional:
520
- while (true) {
521
- const checker = checker_mut, visited = visited_mut, node = node_mut;
522
- let option_3;
523
- const matchValue = node.kind;
524
- switch (matchValue) {
525
- case 184: {
526
- const typeReferenceNode = node;
527
- let matchValue_1;
528
- const option_1 = symbolAtLocation(checker, typeReferenceNode.typeName);
529
- matchValue_1 = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
530
- if (matchValue_1 == null) {
531
- return false;
532
- }
533
- else {
534
- const symbol_1 = matchValue_1;
535
- const key = checker.getFullyQualifiedName(symbol_1);
536
- if (!FSharpSet__Contains(visited, key)) {
537
- return defaultArg((option_3 = symbol_1.declarations, (option_3 != null) ? exists((declaration) => {
538
- if (declaration.kind === 266) {
539
- return standsForConditional(checker, FSharpSet__Add(visited, key), declaration.type);
540
- }
541
- else {
542
- return false;
543
- }
544
- }, option_3) : undefined), false);
545
- }
546
- else {
547
- return false;
548
- }
549
- }
550
- }
551
- case 195:
552
- return true;
553
- case 197: {
554
- checker_mut = checker;
555
- visited_mut = visited;
556
- node_mut = node.type;
557
- continue standsForConditional;
558
- }
559
- default:
560
- return false;
561
- }
562
- break;
563
- }
564
- }
565
-
566
- function isWithinConstraint(node_mut) {
567
- isWithinConstraint:
568
- while (true) {
569
- const node = node_mut;
570
- if (Operators_IsNull(node) ? true : Operators_IsNull(node.parent)) {
571
- return false;
572
- }
573
- else if (node.parent.kind === 169) {
574
- const matchValue = node.parent.constraint;
575
- if (matchValue == null) {
576
- return false;
577
- }
578
- else {
579
- return matchValue === node;
580
- }
581
- }
582
- else {
583
- node_mut = node.parent;
584
- continue isWithinConstraint;
585
- }
586
- break;
587
- }
588
- }
589
-
590
- function tryResolveDeferred(reader, typeNode) {
591
- let resolvedNode, previousContext;
592
- const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
593
- const bindings = boundTypeParameters(reader, typeNode);
594
- if (((!isParseTreeNode(typeNode) ? true : !standsForConditional(checker, empty_2({
595
- Compare: (x, y) => (comparePrimitives(x, y) | 0),
596
- }), typeNode)) ? true : isWithinConstraint(typeNode)) ? true : !mentionsBoundTypeParameter(bindings, typeNode)) {
597
- return undefined;
598
- }
599
- else {
600
- const typ = checker.getTypeAtLocation(typeNode);
601
- if (isEmpty(deferredConditionals(checker, 0, typ))) {
602
- return undefined;
603
- }
604
- else {
605
- let option_3;
606
- const option_1 = resolveWithBindings(checker, typeNode, bindings, empty_1({
607
- Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
608
- }), typ);
609
- if (option_1 != null) {
610
- const resolved = option_1;
611
- option_3 = checker.typeToTypeNode(resolved, enclosingDeclarationOf(typeNode), typeNodeBuilderFlags);
612
- }
613
- else {
614
- option_3 = undefined;
615
- }
616
- if (option_3 != null) {
617
- return (resolvedNode = option_3, (previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"](), (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](typeNode), (() => {
618
- try {
619
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](resolvedNode);
620
- }
621
- finally {
622
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
623
- }
624
- })())));
625
- }
626
- else {
627
- return undefined;
628
- }
629
- }
630
- }
631
- }
632
-
633
- function inferTypeNodes(node) {
634
- return toList(delay(() => append_1((node.kind === 196) ? singleton_1(node) : empty_3(), delay(() => collect_2(inferTypeNodes, node.getChildren())))));
635
- }
636
-
637
- function inferredConstraint(reader, inferTypeNode) {
638
- const matchValue_1 = inferTypeNode.typeParameter.constraint;
639
- if (matchValue_1 == null) {
640
- let atPosition;
641
- if (inferTypeNode.parent.kind === 184) {
642
- const typeReferenceNode = inferTypeNode.parent;
643
- let position;
644
- const option_1 = typeReferenceNode.typeArguments;
645
- position = ((option_1 != null) ? tryFindIndex((typeArgument) => (typeArgument === inferTypeNode), option_1) : undefined);
646
- let option_13;
647
- let option_9;
648
- let option_7;
649
- let option_5;
650
- const option_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(typeReferenceNode.typeName);
651
- let binder_2;
652
- const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
653
- binder_2 = ((symbol) => resolveAlias(checker, symbol));
654
- const option_3 = option_2;
655
- option_5 = ((option_3 != null) ? binder_2(option_3) : undefined);
656
- if (option_5 != null) {
657
- const symbol_1 = option_5;
658
- option_7 = symbol_1.declarations;
659
- }
660
- else {
661
- option_7 = undefined;
662
- }
663
- option_9 = ((option_7 != null) ? tryHead(option_7) : undefined);
664
- if (option_9 != null) {
665
- const declaration = option_9;
666
- const matchValue = declaration.kind;
667
- option_13 = ((matchValue === 264) ? declaration.typeParameters : ((matchValue === 265) ? declaration.typeParameters : ((matchValue === 266) ? declaration.typeParameters : undefined)));
668
- }
669
- else {
670
- option_13 = undefined;
671
- }
672
- if (option_13 != null) {
673
- const typeParameters = option_13;
674
- const option_11 = position;
675
- if (option_11 != null) {
676
- const position_1 = option_11 | 0;
677
- atPosition = ((position_1 < ~~typeParameters.length) ? (typeParameters[position_1]).constraint : undefined);
678
- }
679
- else {
680
- atPosition = undefined;
681
- }
682
- }
683
- else {
684
- atPosition = undefined;
685
- }
686
- }
687
- else {
688
- atPosition = undefined;
689
- }
690
- if (atPosition == null) {
691
- return GlueType.Unknown;
692
- }
693
- else {
694
- const constraintNode_1 = atPosition;
695
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constraintNode_1);
696
- }
697
- }
698
- else {
699
- const constraintNode = matchValue_1;
700
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constraintNode);
701
- }
702
- }
703
-
704
- function truncateToDeclaredArity(reader, symbolOpt, typeArguments) {
705
- let option_5, _arg;
706
- let declaredArity;
707
- let option_8;
708
- let option_2;
709
- let binder;
710
- const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
711
- binder = ((symbol) => resolveAlias(checker, symbol));
712
- const option_1 = symbolOpt;
713
- option_2 = ((option_1 != null) ? binder(option_1) : undefined);
714
- let binder_2;
715
- const packageContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
716
- binder_2 = ((symbol_1) => mainDeclaration(packageContext, symbol_1));
717
- const option_3 = option_2;
718
- option_8 = ((option_3 != null) ? binder_2(option_3) : undefined);
719
- if (option_8 != null) {
720
- const declaration = option_8;
721
- const matchValue = declaration.kind;
722
- switch (matchValue) {
723
- case 264:
724
- case 265:
725
- case 266: {
726
- declaredArity = defaultArg((option_5 = declaration.typeParameters, (option_5 != null) ? ((_arg = option_5, ~~_arg.length)) : undefined), 0);
727
- break;
728
- }
729
- default:
730
- declaredArity = undefined;
731
- }
732
- }
733
- else {
734
- declaredArity = undefined;
735
- }
736
- let matchResult, arity_1;
737
- if (declaredArity != null) {
738
- if (declaredArity < length(typeArguments)) {
739
- matchResult = 0;
740
- arity_1 = declaredArity;
741
- }
742
- else {
743
- matchResult = 1;
744
- }
745
- }
746
- else {
747
- matchResult = 1;
748
- }
749
- switch (matchResult) {
750
- case 0:
751
- return truncate(arity_1, typeArguments);
752
- default:
753
- return typeArguments;
754
- }
755
- }
756
-
757
- function isGlobalThisQuery(typeNode) {
758
- if (typeNode.kind === 187) {
759
- return entityNameText(typeNode.exprName) === "globalThis";
760
- }
761
- else {
762
- return false;
763
- }
764
- }
765
-
766
- function readTypeUsingFlags(reader, typ) {
767
- let declarations;
768
- const matchValue = typ.flags;
769
- let matchResult;
770
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
771
- if (Operators_IsNull(typ.symbol)) {
772
- matchResult = 0;
773
- }
774
- else {
775
- matchResult = 1;
776
- }
777
- }
778
- else {
779
- matchResult = 1;
780
- }
781
- switch (matchResult) {
782
- case 0:
783
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
784
- default:
785
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
786
- const matchValue_1 = typ.symbol.declarations;
787
- let matchResult_1, declarations_1;
788
- if (matchValue_1 != null) {
789
- if ((declarations = matchValue_1, declarations.length > 0)) {
790
- matchResult_1 = 0;
791
- declarations_1 = matchValue_1;
792
- }
793
- else {
794
- matchResult_1 = 1;
795
- }
796
- }
797
- else {
798
- matchResult_1 = 1;
799
- }
800
- switch (matchResult_1) {
801
- case 0: {
802
- const declaration = item_4(0, declarations_1);
803
- const matchValue_2 = declaration.kind;
804
- switch (matchValue_2) {
805
- case 264:
806
- return new GlueType(/* ClassDeclaration */ 12, [new GlueClassDeclaration(empty(), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getFullyQualifiedName(typ.symbol), typ.symbol.name, empty(), empty(), empty(), empty(), true)]);
807
- case 265:
808
- case 266: {
809
- const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
810
- if (matchValue_3 == null) {
811
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration);
812
- }
813
- else {
814
- const typeNode = matchValue_3;
815
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
816
- }
817
- }
818
- case 268:
819
- return GlueType.Discard;
820
- default:
821
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration);
822
- }
823
- }
824
- default:
825
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
826
- }
827
- }
828
- else {
829
- return primitiveOfFlags(typ);
830
- }
831
- }
832
- }
833
-
834
- export function UtilityType_readExclude(reader, typeReferenceNode) {
835
- let matchValue_1, activePatternResult_4, item, objectArg, activePatternResult_6, item_1, objectArg_1, matchValue_3, typeArguments, typeArguments_1, excluded, isNullish, matchValue_5, symbol, matchValue_6, matchValue_7, typeArguments_2, typeArguments_3, excluded_1, isNullish_1, matchValue_9, symbol_1, matchValue_10, matchValue_11, typeArguments_4, typeArguments_5, excluded_2, isNullish_2, matchValue_13, symbol_2, matchValue_14;
836
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
837
- const matchValue = typ.flags;
838
- let matchResult;
839
- if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
840
- matchResult = 0;
841
- }
842
- else if ($007CHasTypeFlags$007C_$007C(2048, matchValue) != null) {
843
- matchResult = 0;
844
- }
845
- else if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
846
- matchResult = 0;
847
- }
848
- else {
849
- matchResult = 1;
850
- }
851
- switch (matchResult) {
852
- case 0:
853
- return new GlueType(/* Union */ 7, [new GlueTypeUnion((matchValue_1 = typ.flags, ($007CHasTypeFlags$007C_$007C(1024, matchValue_1) != null) ? ((activePatternResult_4 = Type_StringLiteral_$007CString$007COther$007C(typ), (activePatternResult_4.tag === 1) ? (((item = Report_readerError_Z19516DCE("Exclude", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 696), (objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg.push(item)))), empty())) : singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_4.fields[0]])])))) : (($007CHasTypeFlags$007C_$007C(2048, matchValue_1) != null) ? ((activePatternResult_6 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ), (activePatternResult_6.tag === 1) ? singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_6.fields[0]])])) : ((activePatternResult_6.tag === 2) ? (((item_1 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 711), (objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_1.push(item_1)))), empty())) : singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_6.fields[0]])]))))) : choose((typ_1) => {
854
- const matchValue_2 = typ_1.flags;
855
- if ($007CHasTypeFlags$007C_$007C(1024, matchValue_2) != null) {
856
- const literalType = typ_1;
857
- return new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [literalType.value])]);
858
- }
859
- else if ($007CHasTypeFlags$007C_$007C(2048, matchValue_2) != null) {
860
- const activePatternResult_9 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ_1);
861
- switch (activePatternResult_9.tag) {
862
- case 1:
863
- return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_9.fields[0]])]);
864
- case 2: {
865
- const item_2 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 738);
866
- const objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
867
- void (objectArg_2.push(item_2));
868
- return undefined;
869
- }
870
- default:
871
- return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_9.fields[0]])]);
872
- }
873
- }
874
- else {
875
- return undefined;
876
- }
877
- }, toList(typ.types)))))]);
878
- default: {
879
- let matchResult_1;
880
- if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
881
- if ((matchValue_3 = typeReferenceNode.typeArguments, (matchValue_3 != null) && (((typeArguments = matchValue_3, ~~typeArguments.length > 1)) && ((typeArguments_1 = matchValue_3, (excluded = (typeArguments_1[0]), (isNullish = ((typeNode) => {
882
- const matchValue_4 = typeNode.kind;
883
- switch (matchValue_4) {
884
- case 157:
885
- return true;
886
- case 193:
887
- return forAll(isNullish, typeNode.types);
888
- case 202:
889
- return typeNode.literal.kind === 106;
890
- default:
891
- return false;
892
- }
893
- }), (isNullish(typeArguments_1[1]) ? true : (excluded.kind === 200)) ? true : ((excluded.kind === 184) && ((matchValue_5 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(excluded.typeName), (matchValue_5 == null) ? false : ((symbol = matchValue_5, (matchValue_6 = symbol.flags, $007CHasSymbolFlags$007C_$007C(262144, matchValue_6) != null))))))))))))) {
894
- matchResult_1 = 0;
895
- }
896
- else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
897
- if ((matchValue_7 = typeReferenceNode.typeArguments, (matchValue_7 != null) && (((typeArguments_2 = matchValue_7, ~~typeArguments_2.length > 1)) && ((typeArguments_3 = matchValue_7, (excluded_1 = (typeArguments_3[0]), (isNullish_1 = ((typeNode_1) => {
898
- const matchValue_8 = typeNode_1.kind;
899
- switch (matchValue_8) {
900
- case 157:
901
- return true;
902
- case 193:
903
- return forAll(isNullish_1, typeNode_1.types);
904
- case 202:
905
- return typeNode_1.literal.kind === 106;
906
- default:
907
- return false;
908
- }
909
- }), (isNullish_1(typeArguments_3[1]) ? true : (excluded_1.kind === 200)) ? true : ((excluded_1.kind === 184) && ((matchValue_9 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(excluded_1.typeName), (matchValue_9 == null) ? false : ((symbol_1 = matchValue_9, (matchValue_10 = symbol_1.flags, $007CHasSymbolFlags$007C_$007C(262144, matchValue_10) != null))))))))))))) {
910
- matchResult_1 = 0;
911
- }
912
- else {
913
- matchResult_1 = 1;
914
- }
915
- }
916
- else {
917
- matchResult_1 = 1;
918
- }
919
- }
920
- else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
921
- if ((matchValue_11 = typeReferenceNode.typeArguments, (matchValue_11 != null) && (((typeArguments_4 = matchValue_11, ~~typeArguments_4.length > 1)) && ((typeArguments_5 = matchValue_11, (excluded_2 = (typeArguments_5[0]), (isNullish_2 = ((typeNode_2) => {
922
- const matchValue_12 = typeNode_2.kind;
923
- switch (matchValue_12) {
924
- case 157:
925
- return true;
926
- case 193:
927
- return forAll(isNullish_2, typeNode_2.types);
928
- case 202:
929
- return typeNode_2.literal.kind === 106;
930
- default:
931
- return false;
932
- }
933
- }), (isNullish_2(typeArguments_5[1]) ? true : (excluded_2.kind === 200)) ? true : ((excluded_2.kind === 184) && ((matchValue_13 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(excluded_2.typeName), (matchValue_13 == null) ? false : ((symbol_2 = matchValue_13, (matchValue_14 = symbol_2.flags, $007CHasSymbolFlags$007C_$007C(262144, matchValue_14) != null))))))))))))) {
934
- matchResult_1 = 0;
935
- }
936
- else {
937
- matchResult_1 = 1;
938
- }
939
- }
940
- else {
941
- matchResult_1 = 1;
942
- }
943
- switch (matchResult_1) {
944
- case 0:
945
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_6(typeReferenceNode.typeArguments)[0]);
946
- default:
947
- if ($007CHasTypeFlags$007C_$007C(32, matchValue) != null) {
948
- return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
949
- }
950
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue) != null) {
951
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]);
952
- }
953
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue) != null) {
954
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Bool]);
955
- }
956
- else if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
957
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
958
- }
959
- else if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
960
- const matchValue_15 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
961
- if (matchValue_15 == null) {
962
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
963
- }
964
- else {
965
- const typeNode_3 = matchValue_15;
966
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode_3);
967
- }
968
- }
969
- else {
970
- const item_3 = Report_readerError_Z19516DCE("Exclude", "Was expecting the resolved type to be a literal or a union", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 799);
971
- const objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
972
- void (objectArg_3.push(item_3));
973
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
974
- }
975
- }
976
- }
977
- }
978
- }
979
-
980
- function UtilityType_isMemberDeclaration(declaration) {
981
- const matchValue = declaration.kind;
982
- switch (matchValue) {
983
- case 264:
984
- case 265:
985
- case 266:
986
- case 267:
987
- case 268:
988
- return false;
989
- default:
990
- return true;
991
- }
992
- }
993
-
994
- function UtilityType_readPropertyMembers(reader, contextNode, property) {
995
- let option_1;
996
- const declarations = defaultArg((option_1 = property.declarations, (option_1 != null) ? toList(filter(UtilityType_isMemberDeclaration, option_1)) : undefined), empty());
997
- return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing, contextNode, () => (isEmpty(declarations) ? ofArray(toArray(readPropertyWithoutDeclaration(reader, contextNode, property))) : map_1((declaration_1) => readInstantiatedMember(reader, contextNode, property, declaration_1), declarations)));
998
- }
999
-
1000
- function UtilityType_readMembers(reader, contextNode, typ) {
1001
- let objectArg;
1002
- return List_distinct(collect_1((property) => UtilityType_readPropertyMembers(reader, contextNode, property), toList((objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg.getPropertiesOfType(typ)))), {
1003
- Equals: equals,
1004
- GetHashCode: (x) => (safeHash(x) | 0),
1005
- });
1006
- }
1007
-
1008
- /**
1009
- * When a generic type reference is applied with concrete type arguments
1010
- * (e.g. a custom utility type like <c>Picked<User, "id"></c>), the
1011
- * TypeChecker resolves it to an anonymous object type. We read its resolved
1012
- * members (via <see cref="readMembers"/>) and expand it into a TypeLiteral
1013
- * so it is generated as a concrete interface instead of an unusable
1014
- * reference to the (generic) utility.
1015
- */
1016
- export function UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
1017
- let matchValue, typeArguments, typNode;
1018
- if (!((matchValue = typeReferenceNode.typeArguments, (matchValue == null) ? false : ((typeArguments = matchValue, ~~typeArguments.length > 0))))) {
1019
- return undefined;
1020
- }
1021
- else {
1022
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
1023
- let isNamedDeclaration;
1024
- if (Operators_IsNull(typ.symbol)) {
1025
- isNamedDeclaration = false;
1026
- }
1027
- else {
1028
- const matchValue_1 = typ.symbol.declarations;
1029
- isNamedDeclaration = ((matchValue_1 == null) ? false : exists((declaration) => {
1030
- const matchValue_2 = declaration.kind;
1031
- switch (matchValue_2) {
1032
- case 264:
1033
- case 265:
1034
- return true;
1035
- default:
1036
- return false;
1037
- }
1038
- }, matchValue_1));
1039
- }
1040
- let isTypeAliasApplication;
1041
- const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(typeReferenceNode.typeName);
1042
- if (matchValue_3 == null) {
1043
- isTypeAliasApplication = false;
1044
- }
1045
- else {
1046
- const symbol = matchValue_3;
1047
- const matchValue_4 = symbol.flags;
1048
- isTypeAliasApplication = ($007CHasSymbolFlags$007C_$007C(524288, matchValue_4) != null);
1049
- }
1050
- const isInProgress = exists((inProgress) => (inProgress === typ), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
1051
- let isGenericMapped;
1052
- const matchValue_5 = typ.flags;
1053
- isGenericMapped = (($007CHasTypeFlags$007C_$007C(1048576, matchValue_5) != null) && (((typ.objectFlags & 32) !== 0) && exists((argument) => {
1054
- const matchValue_6 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(argument).flags;
1055
- if ($007CHasTypeFlags$007C_$007C(524288, matchValue_6) != null) {
1056
- return true;
1057
- }
1058
- else {
1059
- return false;
1060
- }
1061
- }, value_6(typeReferenceNode.typeArguments))));
1062
- const isArrayLike = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().isArrayLikeType(typ);
1063
- const matchValue_7 = typ.flags;
1064
- let matchResult;
1065
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
1066
- if ((isTupleType(typ) ? true : (isArrayLike && !isNamedDeclaration)) && !isInProgress) {
1067
- matchResult = 0;
1068
- }
1069
- else {
1070
- matchResult = 1;
1071
- }
1072
- }
1073
- else {
1074
- matchResult = 1;
1075
- }
1076
- switch (matchResult) {
1077
- case 0: {
1078
- const option_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
1079
- if (option_1 != null) {
1080
- return (typNode = option_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
1081
- }
1082
- else {
1083
- return undefined;
1084
- }
1085
- }
1086
- default: {
1087
- let matchResult_1;
1088
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
1089
- if ((!isNamedDeclaration && !isInProgress) && !isGenericMapped) {
1090
- matchResult_1 = 0;
1091
- }
1092
- else {
1093
- matchResult_1 = 1;
1094
- }
1095
- }
1096
- else {
1097
- matchResult_1 = 1;
1098
- }
1099
- switch (matchResult_1) {
1100
- case 0: {
1101
- const members = withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions, typ, () => UtilityType_readMembers(reader, typeReferenceNode, typ));
1102
- if (isEmpty(members)) {
1103
- return undefined;
1104
- }
1105
- else {
1106
- return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(members, undefined)]);
1107
- }
1108
- }
1109
- default: {
1110
- let matchResult_2;
1111
- if ($007CHasTypeFlags$007C_$007C(32, matchValue_7) != null) {
1112
- if (isTypeAliasApplication) {
1113
- matchResult_2 = 0;
1114
- }
1115
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
1116
- if (isTypeAliasApplication) {
1117
- matchResult_2 = 0;
1118
- }
1119
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
1120
- if (isTypeAliasApplication) {
1121
- matchResult_2 = 0;
1122
- }
1123
- else {
1124
- matchResult_2 = 1;
1125
- }
1126
- }
1127
- else {
1128
- matchResult_2 = 1;
1129
- }
1130
- }
1131
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
1132
- if (isTypeAliasApplication) {
1133
- matchResult_2 = 0;
1134
- }
1135
- else {
1136
- matchResult_2 = 1;
1137
- }
1138
- }
1139
- else {
1140
- matchResult_2 = 1;
1141
- }
1142
- }
1143
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
1144
- if (isTypeAliasApplication) {
1145
- matchResult_2 = 0;
1146
- }
1147
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
1148
- if (isTypeAliasApplication) {
1149
- matchResult_2 = 0;
1150
- }
1151
- else {
1152
- matchResult_2 = 1;
1153
- }
1154
- }
1155
- else {
1156
- matchResult_2 = 1;
1157
- }
1158
- }
1159
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
1160
- if (isTypeAliasApplication) {
1161
- matchResult_2 = 0;
1162
- }
1163
- else {
1164
- matchResult_2 = 1;
1165
- }
1166
- }
1167
- else {
1168
- matchResult_2 = 1;
1169
- }
1170
- switch (matchResult_2) {
1171
- case 0:
1172
- return readTypeUsingFlags(reader, typ);
1173
- default:
1174
- return undefined;
1175
- }
1176
- }
1177
- }
1178
- }
1179
- }
1180
- }
1181
- }
1182
-
1183
- function UtilityType_baseTypeOf(reader, typeNode) {
1184
- let option_2, option, binder, checker, option_1, mapping, objectArg, option_3;
1185
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeNode);
1186
- const matchValue = typ.flags;
1187
- let matchResult;
1188
- if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
1189
- if ((typeNode.pos < 0) && (typeNode.kind === 184)) {
1190
- matchResult = 0;
1191
- }
1192
- else {
1193
- matchResult = 1;
1194
- }
1195
- }
1196
- else {
1197
- matchResult = 1;
1198
- }
1199
- switch (matchResult) {
1200
- case 0:
1201
- return defaultArg((option_2 = ((option = symbolAtLocation(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeNode.typeName), (binder = ((checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol) => resolveAlias(checker, symbol))), (option_1 = option, (option_1 != null) ? binder(option_1) : undefined)))), (mapping = ((objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol_1) => objectArg.getDeclaredTypeOfSymbol(symbol_1))), (option_3 = option_2, (option_3 != null) ? mapping(option_3) : undefined))), typ);
1202
- default:
1203
- return typ;
1204
- }
1205
- }
1206
-
1207
- function UtilityType_literalKeysOf(typeNode_mut) {
1208
- UtilityType_literalKeysOf:
1209
- while (true) {
1210
- const typeNode = typeNode_mut;
1211
- const matchValue = typeNode.kind;
1212
- switch (matchValue) {
1213
- case 193:
1214
- return collect_1(UtilityType_literalKeysOf, toList(typeNode.types));
1215
- case 197: {
1216
- typeNode_mut = typeNode.type;
1217
- continue UtilityType_literalKeysOf;
1218
- }
1219
- case 202: {
1220
- const literal = typeNode.literal;
1221
- if (literal.kind === 11) {
1222
- return singleton(literal.text);
1223
- }
1224
- else {
1225
- return empty();
1226
- }
1227
- }
1228
- default:
1229
- return empty();
1230
- }
1231
- break;
1232
- }
1233
- }
1234
-
1235
- function UtilityType_withoutForeignTypeParameters(reader, bound, members) {
1236
- const declaredAbove = (node) => {
1237
- if (Operators_IsNull(node)) {
1238
- return empty();
1239
- }
1240
- else {
1241
- const typeParameters = node.typeParameters;
1242
- return append((typeParameters == null) ? empty() : map_1((p) => identifierText(p.name), toList(typeParameters)), declaredAbove(node.parent));
1243
- }
1244
- };
1245
- let inScope;
1246
- const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
1247
- inScope = ((matchValue == null) ? empty() : declaredAbove(matchValue));
1248
- const signatureMentions = (returnType, parameters) => append(GlueSubstitution_mentionedTypeParameters(returnType), collect_1((parameter) => GlueSubstitution_mentionedTypeParameters(parameter.Type), parameters));
1249
- const foreign = ofList(map_1((name_1) => [name_1, new GlueType(/* Primitive */ 3, [GluePrimitive.Any])], filter_1((name) => {
1250
- if (!contains(name, inScope, {
1251
- Equals: (x_1, y_1) => (x_1 === y_1),
1252
- GetHashCode: (x_1) => (stringHash(x_1) | 0),
1253
- })) {
1254
- return !FSharpMap__ContainsKey(bound, name);
1255
- }
1256
- else {
1257
- return false;
1258
- }
1259
- }, List_distinct(collect_1((glueMember) => {
1260
- switch (glueMember.tag) {
1261
- case 1:
1262
- return GlueSubstitution_mentionedTypeParameters(glueMember.fields[0].Type);
1263
- case 0: {
1264
- const method = glueMember.fields[0];
1265
- return signatureMentions(method.Type, method.Parameters);
1266
- }
1267
- case 6: {
1268
- const method_1 = glueMember.fields[0];
1269
- return signatureMentions(method_1.Type, method_1.Parameters);
1270
- }
1271
- default:
1272
- return empty();
1273
- }
1274
- }, members), {
1275
- Equals: (x, y) => (x === y),
1276
- GetHashCode: (x) => (stringHash(x) | 0),
1277
- }))), {
1278
- Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
1279
- });
1280
- if (FSharpMap__get_IsEmpty(foreign)) {
1281
- return members;
1282
- }
1283
- else {
1284
- return map_1((glueMember_1) => GlueSubstitution_substituteMember(foreign, glueMember_1), members);
1285
- }
1286
- }
1287
-
1288
- export function UtilityType_readPartial(reader, typeReferenceNode) {
1289
- const baseType = UtilityType_baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
1290
- if (exists((typ) => (typ === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials)) {
1291
- const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1045);
1292
- const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1293
- void (objectArg.push(item));
1294
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1295
- }
1296
- else {
1297
- return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials, baseType, () => {
1298
- if (isTupleType(baseType)) {
1299
- const typNode = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode), undefined, typeNodeBuilderFlags);
1300
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode);
1301
- }
1302
- else {
1303
- const baseNode = value_6(typeReferenceNode.typeArguments)[0];
1304
- let members;
1305
- const matchValue = baseType.flags;
1306
- let matchResult;
1307
- if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
1308
- if (baseNode.kind === 133) {
1309
- matchResult = 0;
1310
- }
1311
- else {
1312
- matchResult = 1;
1313
- }
1314
- }
1315
- else {
1316
- matchResult = 1;
1317
- }
1318
- switch (matchResult) {
1319
- case 0: {
1320
- members = empty();
1321
- break;
1322
- }
1323
- default: {
1324
- let matchResult_1;
1325
- if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
1326
- if ((baseNode.pos < 0) && (baseNode.kind === 188)) {
1327
- matchResult_1 = 0;
1328
- }
1329
- else {
1330
- matchResult_1 = 1;
1331
- }
1332
- }
1333
- else {
1334
- matchResult_1 = 1;
1335
- }
1336
- switch (matchResult_1) {
1337
- case 0: {
1338
- const matchValue_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](baseNode);
1339
- members = ((matchValue_1.tag === 22) ? matchValue_1.fields[0].Members : empty());
1340
- break;
1341
- }
1342
- default:
1343
- if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
1344
- const item_1 = Report_readerError_Z19516DCE("partial inner type", "Was not able to resolve the inner type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1087);
1345
- const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1346
- void (objectArg_1.push(item_1));
1347
- members = empty();
1348
- }
1349
- else {
1350
- members = UtilityType_readMembers(reader, typeReferenceNode, baseType);
1351
- }
1352
- }
1353
- }
1354
- }
1355
- const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
1356
- let members_2;
1357
- const members_1 = map_1((glueMember) => GlueSubstitution_substituteMember(defaults, glueMember), members);
1358
- members_2 = ((typeReferenceNode.pos < 0) ? UtilityType_withoutForeignTypeParameters(reader, defaults, members_1) : members_1);
1359
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Partial */ 0, [new GlueInterface(empty(), getFullNameOrEmpty(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeReferenceNode), entityNameText(typeReferenceNode.typeName), members_2, empty(), empty())])]);
1360
- }
1361
- });
1362
- }
1363
- }
1364
-
1365
- export function UtilityType_readRecord(reader, typeReferenceNode) {
1366
- const typeArguments = readTypeArguments(reader, typeReferenceNode);
1367
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Record */ 1, [new GlueRecord(item_5(0, typeArguments), item_5(1, typeArguments))])]);
1368
- }
1369
-
1370
- export function UtilityType_readReturnType(reader, typeReferenceNode) {
1371
- let matchValue_4, matchValue_1, symbol, matchValue_2, declarations, declarations_1;
1372
- const rawTyp = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
1373
- let typ;
1374
- const matchValue = rawTyp.flags;
1375
- let matchResult;
1376
- if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
1377
- matchResult = 0;
1378
- }
1379
- else if ($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) {
1380
- matchResult = 0;
1381
- }
1382
- else if ($007CHasTypeFlags$007C_$007C(16777216, matchValue) != null) {
1383
- matchResult = 0;
1384
- }
1385
- else if ($007CHasTypeFlags$007C_$007C(2097152, matchValue) != null) {
1386
- matchResult = 0;
1387
- }
1388
- else {
1389
- matchResult = 1;
1390
- }
1391
- switch (matchResult) {
1392
- case 0: {
1393
- typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getApparentType(rawTyp);
1394
- break;
1395
- }
1396
- default:
1397
- typ = rawTyp;
1398
- }
1399
- const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
1400
- if (matchValue_3 == null) {
1401
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ReturnType */ 2, [readTypeUsingFlags(reader, typ)])]);
1402
- }
1403
- else {
1404
- const typeNode = matchValue_3;
1405
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ReturnType */ 2, [(matchValue_4 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode), (matchValue_4.tag === 22) ? ((matchValue_4.fields[0].Id == null) ? (new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(matchValue_4.fields[0].Members, (matchValue_1 = typ.getSymbol(), (matchValue_1 == null) ? undefined : ((symbol = matchValue_1, (matchValue_2 = symbol.declarations, (matchValue_2 != null) ? (((declarations = matchValue_2, declarations.length > 0)) ? ((declarations_1 = matchValue_2, typeLiteralId(item_4(0, declarations_1)))) : undefined) : undefined)))))])) : matchValue_4) : matchValue_4)])]);
1406
- }
1407
- }
1408
-
1409
- export function UtilityType_readThisParameterType(reader, typeReferenceNode) {
1410
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
1411
- const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
1412
- if (matchValue == null) {
1413
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ThisParameterType */ 3, [readTypeUsingFlags(reader, typ)])]);
1414
- }
1415
- else {
1416
- const typeNode = matchValue;
1417
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ThisParameterType */ 3, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode)])]);
1418
- }
1419
- }
1420
-
1421
- export function UtilityType_readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
1422
- let option_1, matchValue_4, item_1, objectArg_2, objectArg_3;
1423
- let keysToOmitType;
1424
- const node = value_6(typeReferenceNode.typeArguments)[1];
1425
- const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
1426
- keysToOmitType = objectArg.getTypeFromTypeNode(node);
1427
- let hasUnboundKeys;
1428
- const matchValue = keysToOmitType.flags;
1429
- let matchResult;
1430
- if ($007CHasTypeFlags$007C_$007C(524288, matchValue) != null) {
1431
- matchResult = 0;
1432
- }
1433
- else if ($007CHasTypeFlags$007C_$007C(2097152, matchValue) != null) {
1434
- matchResult = 0;
1435
- }
1436
- else if ($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) {
1437
- matchResult = 0;
1438
- }
1439
- else {
1440
- matchResult = 1;
1441
- }
1442
- switch (matchResult) {
1443
- case 0: {
1444
- hasUnboundKeys = true;
1445
- break;
1446
- }
1447
- default:
1448
- hasUnboundKeys = false;
1449
- }
1450
- const tryReadValueOfKeys = (typ) => {
1451
- const activePatternResult_3 = Type_StringLiteral_$007CString$007COther$007C(typ);
1452
- if (activePatternResult_3.tag === 1) {
1453
- const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1209);
1454
- const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1455
- void (objectArg_1.push(item));
1456
- return undefined;
1457
- }
1458
- else {
1459
- return activePatternResult_3.fields[0];
1460
- }
1461
- };
1462
- let keysToOmit;
1463
- const matchValue_1 = keysToOmitType.flags;
1464
- let matchResult_1;
1465
- if (hasUnboundKeys) {
1466
- matchResult_1 = 0;
1467
- }
1468
- else if ($007CHasTypeFlags$007C_$007C(1, matchValue_1) != null) {
1469
- if (typeReferenceNode.pos < 0) {
1470
- matchResult_1 = 1;
1471
- }
1472
- else {
1473
- matchResult_1 = 2;
1474
- }
1475
- }
1476
- else {
1477
- matchResult_1 = 2;
1478
- }
1479
- switch (matchResult_1) {
1480
- case 0: {
1481
- keysToOmit = empty_3();
1482
- break;
1483
- }
1484
- case 1: {
1485
- keysToOmit = ofList_1(UtilityType_literalKeysOf(value_6(typeReferenceNode.typeArguments)[1]));
1486
- break;
1487
- }
1488
- default:
1489
- keysToOmit = (keysToOmitType.isUnion() ? choose_1(tryReadValueOfKeys, keysToOmitType.types) : defaultArg((option_1 = tryReadValueOfKeys(keysToOmitType), (option_1 != null) ? singleton_1(option_1) : undefined), []));
1490
- }
1491
- const baseType = UtilityType_baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
1492
- let literalMembers;
1493
- const matchValue_2 = baseType.flags;
1494
- let matchResult_2;
1495
- if ($007CHasTypeFlags$007C_$007C(1, matchValue_2) != null) {
1496
- if (typeReferenceNode.pos < 0) {
1497
- matchResult_2 = 0;
1498
- }
1499
- else {
1500
- matchResult_2 = 1;
1501
- }
1502
- }
1503
- else {
1504
- matchResult_2 = 1;
1505
- }
1506
- switch (matchResult_2) {
1507
- case 0: {
1508
- const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_6(typeReferenceNode.typeArguments)[0]);
1509
- literalMembers = ((matchValue_3.tag === 20) ? matchValue_3.fields[0] : ((matchValue_3.tag === 22) ? matchValue_3.fields[0].Members : undefined));
1510
- break;
1511
- }
1512
- default:
1513
- literalMembers = undefined;
1514
- }
1515
- const filteredProperties = toList(filter((prop) => (keepListedKeys === contains_1(prop.name, keysToOmit, {
1516
- Equals: (x, y) => (x === y),
1517
- GetHashCode: (x) => (stringHash(x) | 0),
1518
- })), (matchValue_4 = baseType.flags, ($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? ((literalMembers != null) ? [] : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1244), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType))))) : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1244), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType)))))));
1519
- const isInProgress = exists((inProgress) => (inProgress === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
1520
- const members_1 = isInProgress ? empty() : withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions, baseType, () => collect_1((property) => UtilityType_readPropertyMembers(reader, typeReferenceNode, property), filteredProperties));
1521
- const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
1522
- let members_4;
1523
- const members_3 = map_1((glueMember_2) => GlueSubstitution_substituteMember(defaults, glueMember_2), (literalMembers == null) ? members_1 : filter_1((glueMember_1) => {
1524
- let matchValue_5;
1525
- const glueMember = glueMember_1;
1526
- switch (glueMember.tag) {
1527
- case 0: {
1528
- matchValue_5 = glueMember.fields[0].Name;
1529
- break;
1530
- }
1531
- case 6: {
1532
- matchValue_5 = glueMember.fields[0].Name;
1533
- break;
1534
- }
1535
- case 2: {
1536
- matchValue_5 = glueMember.fields[0].Name;
1537
- break;
1538
- }
1539
- case 3: {
1540
- matchValue_5 = glueMember.fields[0].Name;
1541
- break;
1542
- }
1543
- case 4:
1544
- case 5:
1545
- case 7: {
1546
- matchValue_5 = undefined;
1547
- break;
1548
- }
1549
- default:
1550
- matchValue_5 = glueMember.fields[0].Name;
1551
- }
1552
- if (matchValue_5 == null) {
1553
- return !keepListedKeys;
1554
- }
1555
- else {
1556
- return keepListedKeys === contains_1(matchValue_5, keysToOmit, {
1557
- Equals: (x_1, y_2) => (x_1 === y_2),
1558
- GetHashCode: (x_1) => (stringHash(x_1) | 0),
1559
- });
1560
- }
1561
- }, literalMembers));
1562
- members_4 = ((typeReferenceNode.pos < 0) ? UtilityType_withoutForeignTypeParameters(reader, defaults, members_3) : members_3);
1563
- if (hasUnboundKeys ? true : isInProgress) {
1564
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1565
- }
1566
- else {
1567
- return new GlueType(/* UtilityType */ 27, [(keepListedKeys ? ((Item) => (new GlueUtilityType(/* Pick */ 5, [Item]))) : ((Item_1) => (new GlueUtilityType(/* Omit */ 4, [Item_1]))))(members_4)]);
1568
- }
1569
- }
1570
-
1571
- export function UtilityType_readOmit(reader, typeReferenceNode) {
1572
- return UtilityType_readOmitOrPick(reader, typeReferenceNode, false);
1573
- }
1574
-
1575
- export function UtilityType_readPick(reader, typeReferenceNode) {
1576
- return UtilityType_readOmitOrPick(reader, typeReferenceNode, true);
1577
- }
1578
-
1579
- export function UtilityType_readReadonly(reader, typeReferenceNode) {
1580
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
1581
- const matchValue = typ.flags;
1582
- let matchResult;
1583
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
1584
- matchResult = 0;
1585
- }
1586
- else if ($007CHasTypeFlags$007C_$007C(268435456, matchValue) != null) {
1587
- matchResult = 0;
1588
- }
1589
- else {
1590
- matchResult = 1;
1591
- }
1592
- switch (matchResult) {
1593
- case 0:
1594
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Readonly */ 6, [new GlueReadonly(/* Members */ 0, [UtilityType_readMembers(reader, typeReferenceNode, typ)])])]);
1595
- default:
1596
- if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
1597
- const unionType = typ;
1598
- try {
1599
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Readonly */ 6, [new GlueReadonly(/* Union */ 1, [toList(choose_1((innerType) => {
1600
- let copyOfStruct, Name;
1601
- if ((copyOfStruct = innerType.flags, (copyOfStruct & 1048576) !== 0)) {
1602
- return (Name = (value_6(innerType.aliasTypeArguments)[0]).symbol.name, new GlueInterface(empty(), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getFullyQualifiedName((value_6(innerType.aliasTypeArguments)[0]).symbol), Name, UtilityType_readMembers(reader, typeReferenceNode, innerType), empty(), empty()));
1603
- }
1604
- else {
1605
- return undefined;
1606
- }
1607
- }, unionType.types))])])]);
1608
- }
1609
- catch (matchValue_1) {
1610
- const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1368);
1611
- const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1612
- void (objectArg.push(item));
1613
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1614
- }
1615
- }
1616
- else {
1617
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1618
- }
1619
- }
1620
- }
2
+ import { tryReadLiteral, typeLiteralId, declaredName, isFromEsLib, Type_StringLiteral_$007CString$007COther$007C, isFromEs5Lib, entityNameText, readTypeArguments, landingOf, crossesNamespace, modulePathForSymbol, isLibraryName, getFullNameOrEmpty, knownExternalTypeNames, isExternalToPackages, importedName, identifierText, typeNodeBuilderFlags, $007CHasTypeFlags$007C_$007C, resolveAlias, $007CHasSymbolFlags$007C_$007C, symbolAtLocation } from "./Utils.js";
3
+ import { unwrap, orElse, defaultArg, value as value_2 } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
4
+ import { GlueTypeLiteral, GlueConstructSignature, GlueThisType, GlueFunctionType, GlueTypeUnion, GlueLiteral, GlueTypeReference, GluePrimitive, GlueType } from "../GlueAST.js";
5
+ import { readReadonly, readPick, readOmit, readThisParameterType, readReturnType, readRecord, readPartial, readExclude, tryExpandAnonymousObjectApplication } from "./UtilityType.js";
6
+ import { contains, item as item_1 } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
7
+ import { isGlobalThisQuery, truncateToDeclaredArity, tryResolveDeferred, isDeferredConditional } from "./Deferred.js";
8
+ import { filter, choose, sortByDescending, tryHead, map as map_1, toList, exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
9
+ import { FSharpSet__Contains } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
10
+ import { sanitizeTypeName } from "../Utils/Naming.js";
11
+ import { exists as exists_1, collect, head, tail, isEmpty, map, append, fold, singleton, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
12
+ import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
13
+ import { List_distinct, List_distinctBy } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
14
+ import { Exception, safeHash, equals, comparePrimitives, stringHash } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
15
+ import { ts } from "@ts-morph/bootstrap";
16
+ import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
17
+ import { readTypeQueryNode } from "./TypeQueryNode.js";
18
+ import { readIntersectionType } from "./IntersectionTypeNode.js";
19
+ import { readConditionalType } from "./ConditionalTypeNode.js";
20
+ import { Report_readerError_Z19516DCE } from "./Report.js";
21
+ import { readExpressionWithTypeArguments } from "./ExpressionWithTypeArguments.js";
22
+ import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
1621
23
 
1622
24
  function readTypeReference(reader, typeNode) {
1623
25
  let option_13, symbol_4;
@@ -1627,12 +29,12 @@ function readTypeReference(reader, typeNode) {
1627
29
  const readTypeReference_1 = (isStandardLibrary) => {
1628
30
  let symbol_2, matchValue_3, declarations, typNode, option_9, valueDeclaration, matchValue_5, matchValue_6;
1629
31
  if ((symbolOpt == null) ? false : ((symbol_2 = symbolOpt, (matchValue_3 = symbol_2.flags, $007CHasSymbolFlags$007C_$007C(262144, matchValue_3) != null)))) {
1630
- return new GlueType(/* TypeParameter */ 16, [value_6(symbolOpt).name]);
32
+ return new GlueType(/* TypeParameter */ 16, [value_2(symbolOpt).name]);
1631
33
  }
1632
34
  else {
1633
35
  let matchValue_4;
1634
36
  let option_7;
1635
- const option_5 = UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
37
+ const option_5 = tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
1636
38
  if (option_5 != null) {
1637
39
  option_7 = option_5;
1638
40
  }
@@ -1662,7 +64,7 @@ function readTypeReference(reader, typeNode) {
1662
64
  }
1663
65
  switch (matchResult) {
1664
66
  case 0: {
1665
- const declaration = item_4(0, declarations_1);
67
+ const declaration = item_1(0, declarations_1);
1666
68
  isConditionalAlias = ((declaration.kind === 266) && (declaration.type.kind === 195));
1667
69
  break;
1668
70
  }
@@ -1745,13 +147,13 @@ function readTypeReference(reader, typeNode) {
1745
147
  }
1746
148
  };
1747
149
  if (((entityNameText(typeReferenceNode.typeName) === "NoInfer") && (typeReferenceNode.typeArguments != null)) && ((((option_13 = symbolOpt, (option_13 != null) ? ((symbol_4 = option_13, symbol_4.declarations)) : undefined)) == null) ? true : isFromEs5Lib(symbolOpt))) {
1748
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_6(typeReferenceNode.typeArguments)[0]);
150
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_2(typeReferenceNode.typeArguments)[0]);
1749
151
  }
1750
152
  else if (isFromEs5Lib(symbolOpt)) {
1751
153
  const matchValue_10 = getFullNameOrEmpty(checker, typeReferenceNode.typeName);
1752
154
  switch (matchValue_10) {
1753
155
  case "Exclude":
1754
- return UtilityType_readExclude(reader, typeReferenceNode);
156
+ return readExclude(reader, typeReferenceNode);
1755
157
  case "Uppercase":
1756
158
  case "Lowercase":
1757
159
  case "Capitalize":
@@ -1789,7 +191,7 @@ function readTypeReference(reader, typeNode) {
1789
191
  default:
1790
192
  return undefined;
1791
193
  }
1792
- }, empty(), map_1(literals, toList(typ_1.types)));
194
+ }, empty(), map(literals, toList(typ_1.types)));
1793
195
  }
1794
196
  else {
1795
197
  return undefined;
@@ -1830,33 +232,33 @@ function readTypeReference(reader, typeNode) {
1830
232
  }
1831
233
  }
1832
234
  case "Partial":
1833
- return UtilityType_readPartial(reader, typeReferenceNode);
235
+ return readPartial(reader, typeReferenceNode);
1834
236
  case "Record":
1835
- return UtilityType_readRecord(reader, typeReferenceNode);
237
+ return readRecord(reader, typeReferenceNode);
1836
238
  case "ReturnType":
1837
- return UtilityType_readReturnType(reader, typeReferenceNode);
239
+ return readReturnType(reader, typeReferenceNode);
1838
240
  case "ThisParameterType":
1839
- return UtilityType_readThisParameterType(reader, typeReferenceNode);
241
+ return readThisParameterType(reader, typeReferenceNode);
1840
242
  case "Omit": {
1841
- const option_16 = UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
243
+ const option_16 = tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
1842
244
  if (option_16 != null) {
1843
245
  return option_16;
1844
246
  }
1845
247
  else {
1846
- return UtilityType_readOmit(reader, typeReferenceNode);
248
+ return readOmit(reader, typeReferenceNode);
1847
249
  }
1848
250
  }
1849
251
  case "Pick": {
1850
- const option_18 = UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
252
+ const option_18 = tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
1851
253
  if (option_18 != null) {
1852
254
  return option_18;
1853
255
  }
1854
256
  else {
1855
- return UtilityType_readPick(reader, typeReferenceNode);
257
+ return readPick(reader, typeReferenceNode);
1856
258
  }
1857
259
  }
1858
260
  case "Readonly":
1859
- return UtilityType_readReadonly(reader, typeReferenceNode);
261
+ return readReadonly(reader, typeReferenceNode);
1860
262
  default:
1861
263
  return readTypeReference_1(true);
1862
264
  }
@@ -1877,8 +279,8 @@ function readFunctionType(reader, typeNode) {
1877
279
  if (Operators_IsNull(node)) {
1878
280
  return acc;
1879
281
  }
1880
- else if (((Operators_IsNull(node.parent) && (node.pos < 0)) && (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]() != null)) && !(node === value_6(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]()))) {
1881
- node_mut = value_6(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]());
282
+ else if (((Operators_IsNull(node.parent) && (node.pos < 0)) && (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]() != null)) && !(node === value_2(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]()))) {
283
+ node_mut = value_2(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]());
1882
284
  acc_mut = acc;
1883
285
  continue collectEnclosing;
1884
286
  }
@@ -1900,7 +302,7 @@ function readFunctionType(reader, typeNode) {
1900
302
  GetHashCode: (x) => (stringHash(x) | 0),
1901
303
  });
1902
304
  typeParameters = (isEmpty(matchValue) ? empty() : reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"]((ts.factory).createNodeArray(Array.from(matchValue))));
1903
- return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](typeNode), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](functionTypeNode.type), typeParameters, (matchValue_1 = functionTypeNode.typeParameters, (matchValue_1 == null) ? empty() : toList(map((typeParameter_1) => identifierText(typeParameter_1.name), matchValue_1))), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](functionTypeNode.parameters))]);
305
+ return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](typeNode), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](functionTypeNode.type), typeParameters, (matchValue_1 = functionTypeNode.typeParameters, (matchValue_1 == null) ? empty() : toList(map_1((typeParameter_1) => identifierText(typeParameter_1.name), matchValue_1))), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](functionTypeNode.parameters))]);
1904
306
  }
1905
307
 
1906
308
  function readImportType(reader, typeNode) {
@@ -1936,7 +338,7 @@ function readImportType(reader, typeNode) {
1936
338
  else {
1937
339
  const moduleName = unresolvedModule;
1938
340
  const warning = concat("\'", moduleName, "\' is not installed, the types imported from it are generated as \'obj\'");
1939
- if (!contains_2(warning, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), {
341
+ if (!contains(warning, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), {
1940
342
  Equals: (x, y) => (x === y),
1941
343
  GetHashCode: (x) => (stringHash(x) | 0),
1942
344
  })) {
@@ -1952,7 +354,7 @@ function readThisType(reader, typeNode) {
1952
354
  const thisTypeNode = typeNode;
1953
355
  const typ = checker.getTypeAtLocation(thisTypeNode);
1954
356
  const declarations = Operators_IsNull(typ.symbol) ? undefined : typ.symbol.declarations;
1955
- const typParameters = (declarations == null) ? empty() : defaultArg((option_1 = tryHead(sortByDescending((typeParameters) => (~~typeParameters.length | 0), choose_1((declaration) => {
357
+ const typParameters = (declarations == null) ? empty() : defaultArg((option_1 = tryHead(sortByDescending((typeParameters) => (~~typeParameters.length | 0), choose((declaration) => {
1956
358
  const matchValue = declaration.kind;
1957
359
  switch (matchValue) {
1958
360
  case 264:
@@ -1974,301 +376,6 @@ function readThisType(reader, typeNode) {
1974
376
  }
1975
377
  }
1976
378
 
1977
- function readIntersectionConstituents(reader, typeNode) {
1978
- let matchValue;
1979
- const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
1980
- const intersectionTypeNode = typeNode;
1981
- const unionOrIntersectionType = checker.getTypeAtLocation(intersectionTypeNode);
1982
- void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections.push(unionOrIntersectionType));
1983
- const _guard = {
1984
- Dispose() {
1985
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections.splice(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections.length - 1, 1);
1986
- },
1987
- };
1988
- try {
1989
- const properties_1 = choose((property_1) => {
1990
- const matchValue_1 = property_1.declarations;
1991
- if (matchValue_1 == null) {
1992
- return new IntersectionTypePropertyResult(/* WithoutDeclaration */ 1, [property_1]);
1993
- }
1994
- else {
1995
- const declarations = matchValue_1;
1996
- if (declarations.length === 1) {
1997
- return new IntersectionTypePropertyResult(/* Single */ 0, [property_1, item_4(0, declarations)]);
1998
- }
1999
- else if (forAll((declaration) => {
2000
- if (declaration.kind === 172) {
2001
- return true;
2002
- }
2003
- else {
2004
- return declaration.kind === 173;
2005
- }
2006
- }, declarations)) {
2007
- return new IntersectionTypePropertyResult(/* WithoutDeclaration */ 1, [property_1]);
2008
- }
2009
- else {
2010
- return IntersectionTypePropertyResult.ForceAny;
2011
- }
2012
- }
2013
- }, unionOrIntersectionType.isUnion() ? List_distinct(concat_1(map_1((arg) => toList(checker.getPropertiesOfType(arg)), toList(unionOrIntersectionType.types))), {
2014
- Equals: equals,
2015
- GetHashCode: (x) => (structuralHash(x) | 0),
2016
- }) : ((matchValue = toList(unionOrIntersectionType.getProperties()), isEmpty(matchValue) ? ((intersectionTypeNode.pos >= 0) ? List_distinctBy((property) => property.name, collect_1((constituent) => {
2017
- let type_1;
2018
- return toList((type_1 = checker.getTypeAtLocation(constituent), checker.getPropertiesOfType(type_1)));
2019
- }, toList(intersectionTypeNode.types)), {
2020
- Equals: (x_1, y_1) => (x_1 === y_1),
2021
- GetHashCode: (x_1) => (stringHash(x_1) | 0),
2022
- }) : matchValue) : matchValue)));
2023
- const intersectsATypeQuery = exists((constituent_1) => (constituent_1.kind === 187), intersectionTypeNode.types);
2024
- const everyConstituentIsAReference = forAll((constituent_2) => (constituent_2.kind === 184), intersectionTypeNode.types);
2025
- const hasUnsupportedProperties = intersectsATypeQuery ? true : exists_1((property_2) => {
2026
- switch (property_2.tag) {
2027
- case 1:
2028
- return false;
2029
- case 0:
2030
- if (everyConstituentIsAReference) {
2031
- return property_2.fields[1].kind === 175;
2032
- }
2033
- else {
2034
- return false;
2035
- }
2036
- default:
2037
- return true;
2038
- }
2039
- }, properties_1);
2040
- const callSignatures = unionOrIntersectionType.isUnion() ? empty() : choose((signature) => {
2041
- const synthesized = checker.signatureToSignatureDeclaration(signature, 180, typeNode, typeNodeBuilderFlags);
2042
- if (synthesized == null) {
2043
- return undefined;
2044
- }
2045
- else {
2046
- const declaration_2 = synthesized;
2047
- declaration_2.parent = typeNode;
2048
- const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
2049
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](declaration_2);
2050
- try {
2051
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_2);
2052
- }
2053
- finally {
2054
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
2055
- }
2056
- }
2057
- }, toList(checker.getSignaturesOfType(unionOrIntersectionType, 0)));
2058
- if (hasUnsupportedProperties) {
2059
- const references = map_1((constituent_3) => {
2060
- if (constituent_3.kind === 184) {
2061
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constituent_3);
2062
- }
2063
- else {
2064
- return GlueType.Discard;
2065
- }
2066
- }, toList(intersectionTypeNode.types));
2067
- const literalMembers = collect_1((constituent_4) => {
2068
- if (constituent_4.kind === 188) {
2069
- const matchValue_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constituent_4);
2070
- if (matchValue_2.tag === 22) {
2071
- return matchValue_2.fields[0].Members;
2072
- }
2073
- else {
2074
- return empty();
2075
- }
2076
- }
2077
- else {
2078
- return empty();
2079
- }
2080
- }, toList(intersectionTypeNode.types));
2081
- const inheritable = filter_1((reference) => !equals(reference, GlueType.Discard), references);
2082
- return (!isEmpty(inheritable) && forAll_1((_arg) => {
2083
- if (_arg.tag === 13) {
2084
- return true;
2085
- }
2086
- else {
2087
- return false;
2088
- }
2089
- }, inheritable)) ? (new GlueType(/* IntersectionOfReferences */ 21, [inheritable, literalMembers])) : (new GlueType(/* Primitive */ 3, [GluePrimitive.Any]));
2090
- }
2091
- else {
2092
- return new GlueType(/* IntersectionType */ 20, [append(withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing, typeNode, () => choose((_arg_1) => {
2093
- switch (_arg_1.tag) {
2094
- case 1:
2095
- return readPropertyWithoutDeclaration(reader, typeNode, _arg_1.fields[0]);
2096
- case 2:
2097
- throw new Exception("Should not happen here");
2098
- default:
2099
- return readInstantiatedMember(reader, typeNode, _arg_1.fields[0], _arg_1.fields[1]);
2100
- }
2101
- }, properties_1)), append(callSignatures, collect_1((constituent_5) => {
2102
- if (constituent_5.kind === 188) {
2103
- return map_1((declaration_4) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_4), filter_1((element) => (element.kind === 182), toList(constituent_5.members)));
2104
- }
2105
- else {
2106
- return empty();
2107
- }
2108
- }, toList(intersectionTypeNode.types))))]);
2109
- }
2110
- }
2111
- finally {
2112
- disposeSafe(_guard);
2113
- }
2114
- }
2115
-
2116
- function readIntersectionType(reader, typeNode) {
2117
- const constituents = toList(filter((arg) => {
2118
- let constituent, this$;
2119
- return !((constituent = arg, (constituent.kind === 188) && (((this$ = constituent.members, ~~this$.length)) === 0)));
2120
- }, typeNode.types));
2121
- let matchResult, single;
2122
- if (!isEmpty(constituents)) {
2123
- if (isEmpty(tail(constituents))) {
2124
- matchResult = 0;
2125
- single = head(constituents);
2126
- }
2127
- else {
2128
- matchResult = 1;
2129
- }
2130
- }
2131
- else {
2132
- matchResult = 1;
2133
- }
2134
- switch (matchResult) {
2135
- case 0:
2136
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](single);
2137
- default:
2138
- return readIntersectionConstituents(reader, typeNode);
2139
- }
2140
- }
2141
-
2142
- function readExpressionWithTypeArguments(reader, typeNode) {
2143
- let symbol, symbol_2, symbol_3, symbol_4, matchValue_2, option_4, symbol_6, matchValue_3, ofAlias, matchValue_4, matchValue_5, alias, written, option_6;
2144
- const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
2145
- const expression = typeNode;
2146
- const typ = checker.getTypeFromTypeNode(expression);
2147
- const symbolOpt = orElse(orElse(typ.aliasSymbol, Operators_IsNull(typ.symbol) ? undefined : typ.symbol), checker.getSymbolAtLocation(expression.expression));
2148
- const isFromEs5 = isFromEs5Lib(symbolOpt);
2149
- const matchValue = getFullNameOrEmpty(checker, expression.expression);
2150
- let matchResult;
2151
- if (isFromEs5) {
2152
- switch (matchValue) {
2153
- case "Omit": {
2154
- matchResult = 0;
2155
- break;
2156
- }
2157
- case "Pick": {
2158
- matchResult = 1;
2159
- break;
2160
- }
2161
- default:
2162
- matchResult = 2;
2163
- }
2164
- }
2165
- else {
2166
- matchResult = 2;
2167
- }
2168
- switch (matchResult) {
2169
- case 0:
2170
- return UtilityType_readOmit(reader, expression);
2171
- case 1:
2172
- return UtilityType_readPick(reader, expression);
2173
- default: {
2174
- const isQualified = expression.expression.kind === 212;
2175
- const name = (symbolOpt != null) ? (((symbol = symbolOpt, symbol.name === "default")) ? ((symbol_2 = symbolOpt, defaultArg(declaredName(symbol_2), symbol_2.name))) : ((!isFromEs5) ? ((symbol_3 = symbolOpt, symbol_3.name)) : (isQualified ? expression.expression.name.text : expression.expression.getText()))) : (isQualified ? expression.expression.name.text : expression.expression.getText());
2176
- const isExternal = isExternalToPackages(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbolOpt);
2177
- if (((symbolOpt == null) ? false : ((symbol_4 = symbolOpt, (symbol_4.name === "__type") ? true : (symbol_4.name === "__object")))) ? true : ((isExternal && !FSharpSet__Contains(knownExternalTypeNames, name)) && !(isFromEs5 && (name === "Partial")))) {
2178
- return GlueType.Discard;
2179
- }
2180
- else {
2181
- return new GlueType(/* TypeReference */ 13, [new GlueTypeReference((name.indexOf(".") >= 0) ? name : sanitizeTypeName(name), (matchValue_2 = ((option_4 = symbolOpt, (option_4 != null) ? resolveValueAlias(checker, option_4) : undefined)), (matchValue_2 == null) ? getFullNameOrEmpty(checker, expression.expression) : ((symbol_6 = matchValue_2, checker.getFullyQualifiedName(symbol_6)))), isLibraryName(reader, name) ? empty() : modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), isQualified ? true : crossesNamespace(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbolOpt, landingOf(reader, expression)), symbolOpt), (matchValue_3 = readTypeArguments(reader, expression), isEmpty(matchValue_3) ? ((ofAlias = (((matchValue_4 = checker.getSymbolAtLocation(expression.expression), (matchValue_5 = typ.aliasSymbol, (matchValue_4 != null) && ((matchValue_5 != null) && ((alias = matchValue_5, (written = matchValue_4, !(written === alias)))))))) ? defaultArg((option_6 = typ.aliasTypeArguments, (option_6 != null) ? toList(option_6) : undefined), empty()) : empty()), map_1((argument) => {
2182
- const typNode = checker.typeToTypeNode(argument, undefined, typeNodeBuilderFlags);
2183
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode);
2184
- }, isEmpty(ofAlias) ? resolvedBaseTypeArguments(checker, expression) : ofAlias))) : matchValue_3), (isFromEs5 ? true : isExternal) ? true : isLibraryName(reader, name))]);
2185
- }
2186
- }
2187
- }
2188
- }
2189
-
2190
- function readConditionalType(reader, typeNode) {
2191
- let branch, trueType, falseType;
2192
- const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
2193
- const conditionalTypeNode = typeNode;
2194
- const typ = checker.getTypeAtLocation(conditionalTypeNode);
2195
- if (isDeferredConditional(typ)) {
2196
- const resolved = isAnyTypeParameter(reader, conditionalTypeNode.checkType) ? ((branch = ((node) => {
2197
- const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](node);
2198
- let matchResult, glueType;
2199
- if (matchValue.tag === 8) {
2200
- if (matchValue.fields[0].tag === 4) {
2201
- matchResult = 0;
2202
- }
2203
- else {
2204
- matchResult = 1;
2205
- glueType = matchValue;
2206
- }
2207
- }
2208
- else {
2209
- matchResult = 1;
2210
- glueType = matchValue;
2211
- }
2212
- switch (matchResult) {
2213
- case 0:
2214
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Null]);
2215
- default:
2216
- return glueType;
2217
- }
2218
- }), (trueType = branch(conditionalTypeNode.trueType), (falseType = branch(conditionalTypeNode.falseType), equals(trueType, falseType) ? trueType : (new GlueType(/* Union */ 7, [new GlueTypeUnion(ofArray([trueType, falseType]))])))))) : tryResolveDeferred(reader, typeNode);
2219
- if (resolved == null) {
2220
- const warningsCount = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length | 0;
2221
- const inferred = List_distinctBy((_arg) => _arg.Name, map_1((inferTypeNode) => (new GlueTypeParameter(inferTypeNode.typeParameter.name.getText(), inferredConstraint(reader, inferTypeNode), undefined)), inferTypeNodes(conditionalTypeNode.extendsType)), {
2222
- Equals: (x, y) => (x === y),
2223
- GetHashCode: (x) => (stringHash(x) | 0),
2224
- });
2225
- const conditionalType = new GlueConditionalType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.checkType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.extendsType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.trueType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.falseType), inferred);
2226
- if (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length > warningsCount) {
2227
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().splice(warningsCount, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length - warningsCount);
2228
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
2229
- }
2230
- else {
2231
- return new GlueType(/* ConditionalType */ 33, [conditionalType]);
2232
- }
2233
- }
2234
- else {
2235
- return resolved;
2236
- }
2237
- }
2238
- else {
2239
- const matchValue_1 = typ.flags;
2240
- if ($007CHasTypeFlags$007C_$007C(524288, matchValue_1) != null) {
2241
- return new GlueType(/* TypeParameter */ 16, [typ.symbol.name]);
2242
- }
2243
- else if ($007CHasTypeFlags$007C_$007C(8192, matchValue_1) != null) {
2244
- return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Bool */ 3, [typ.intrinsicName === "true"])]);
2245
- }
2246
- else {
2247
- const matchValue_2 = readTypeUsingFlags(reader, typ);
2248
- let matchResult_1, forward;
2249
- if (matchValue_2.tag === 3) {
2250
- if (matchValue_2.fields[0].tag === 6) {
2251
- matchResult_1 = 0;
2252
- }
2253
- else {
2254
- matchResult_1 = 1;
2255
- forward = matchValue_2;
2256
- }
2257
- }
2258
- else {
2259
- matchResult_1 = 1;
2260
- forward = matchValue_2;
2261
- }
2262
- switch (matchResult_1) {
2263
- case 0:
2264
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.checkType);
2265
- default:
2266
- return forward;
2267
- }
2268
- }
2269
- }
2270
- }
2271
-
2272
379
  function readTemplateLiteralType(reader, typeNode) {
2273
380
  const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
2274
381
  const templateLiteralTypeNode = typeNode;
@@ -2284,7 +391,7 @@ function readTemplateLiteralType(reader, typeNode) {
2284
391
  }
2285
392
  }
2286
393
  else if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
2287
- return collect_1(readResolvedLiterals, toList(typ_1.types));
394
+ return collect(readResolvedLiterals, toList(typ_1.types));
2288
395
  }
2289
396
  else {
2290
397
  return empty();
@@ -2397,7 +504,7 @@ export function readTypeNode(reader, typeNode) {
2397
504
  return readTypeQueryNode(reader, typeNode);
2398
505
  case 188: {
2399
506
  const typeLiteralNode = typeNode;
2400
- return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(map_1((declaration) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration), toList(typeLiteralNode.members)), typeLiteralId(typeLiteralNode))]);
507
+ return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(map((declaration) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration), toList(typeLiteralNode.members)), typeLiteralId(typeLiteralNode))]);
2401
508
  }
2402
509
  case 189: {
2403
510
  const arrayTypeNode = typeNode;
@@ -2405,9 +512,9 @@ export function readTypeNode(reader, typeNode) {
2405
512
  }
2406
513
  case 190: {
2407
514
  const tupleTypeNode = typeNode;
2408
- const elements = map_1((value) => value, toList(tupleTypeNode.elements));
515
+ const elements = map((value) => value, toList(tupleTypeNode.elements));
2409
516
  if (exists_1((element) => (element.kind === 192), elements)) {
2410
- const elementTypes = List_distinct(map_1((element_1) => {
517
+ const elementTypes = List_distinct(map((element_1) => {
2411
518
  if (element_1.kind === 192) {
2412
519
  const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](element_1.type);
2413
520
  if (matchValue_3.tag === 14) {
@@ -2445,7 +552,7 @@ export function readTypeNode(reader, typeNode) {
2445
552
  }
2446
553
  }
2447
554
  else {
2448
- return new GlueType(/* TupleType */ 18, [map_1((typNode) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode), elements)]);
555
+ return new GlueType(/* TupleType */ 18, [map((typNode) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode), elements)]);
2449
556
  }
2450
557
  }
2451
558
  case 191: {
@@ -2509,7 +616,7 @@ export function readTypeNode(reader, typeNode) {
2509
616
  const literalTypeNode = typeNode;
2510
617
  const matchValue_2 = tryReadLiteral(checker, literalTypeNode.literal);
2511
618
  if (matchValue_2 == null) {
2512
- throw new Exception(Report_readerError_Z19516DCE("type node - literal type", "Could not read literal type", typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 2243));
619
+ throw new Exception(Report_readerError_Z19516DCE("type node - literal type", "Could not read literal type", typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 451));
2513
620
  }
2514
621
  else {
2515
622
  return new GlueType(/* Literal */ 8, [matchValue_2]);
@@ -2524,7 +631,7 @@ export function readTypeNode(reader, typeNode) {
2524
631
  case 234:
2525
632
  return readExpressionWithTypeArguments(reader, typeNode);
2526
633
  default: {
2527
- const item = Report_readerError_Z19516DCE("type node", concat("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(typeNode.kind)), typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 2387);
634
+ const item = Report_readerError_Z19516DCE("type node", concat("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(typeNode.kind)), typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 595);
2528
635
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
2529
636
  void (objectArg.push(item));
2530
637
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);