@glutinum/cli 1.0.0-beta.1 → 1.0.0-beta.3

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.
Files changed (47) hide show
  1. package/README.md +16 -0
  2. package/dist/Glutinum.Converter/Abbreviations.js +9 -32
  3. package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
  4. package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
  5. package/dist/Glutinum.Converter/FsharpAST.js +116 -65
  6. package/dist/Glutinum.Converter/Generate.js +38 -25
  7. package/dist/Glutinum.Converter/GlueAST.js +79 -41
  8. package/dist/Glutinum.Converter/Hosting.js +141 -167
  9. package/dist/Glutinum.Converter/Merge.js +369 -337
  10. package/dist/Glutinum.Converter/Packages.js +391 -92
  11. package/dist/Glutinum.Converter/Printer.js +398 -387
  12. package/dist/Glutinum.Converter/Read.js +387 -88
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
  14. package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
  15. package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
  16. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
  17. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
  18. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
  19. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +14 -20
  20. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
  21. package/dist/Glutinum.Converter/Reader/Node.js +8 -11
  22. package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
  23. package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1342
  24. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
  25. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
  26. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
  27. package/dist/Glutinum.Converter/Reader/Types.js +290 -15
  28. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
  29. package/dist/Glutinum.Converter/Reader/Utils.js +325 -25
  30. package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
  31. package/dist/Glutinum.Converter/Transform.js +3572 -8415
  32. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  33. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  34. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  35. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1149 -0
  36. package/dist/Glutinum.Converter/Transformer/Context.js +666 -0
  37. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  38. package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
  39. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  40. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +596 -0
  41. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  42. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -0
  43. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  44. package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
  45. package/dist/Glutinum.Converter/Utils/String.js +14 -3
  46. package/dist/Program.js +102 -239
  47. package/package.json +3 -2
@@ -1,21 +1,21 @@
1
1
 
2
2
  import { Union } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
3
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, 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, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags } from "./Utils.js";
4
6
  import { Report_readerError_Z19516DCE } from "./Report.js";
5
7
  import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
6
- import { forAll as forAll_1, concat as concat_2, exists as exists_1, head, tail, fold, item as item_5, contains, filter, map as map_1, append as append_1, collect as collect_1, isEmpty, choose, singleton as singleton_1, length, truncate, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
7
- import { resolvedBaseTypeArguments, tryReadLiteral, declaredName, isFromEsLib, isFromEs5Lib, modulePathForSymbol, knownExternalTypeNames, isExternalToPackages, importedName, typeLiteralId, readTypeArguments, getFullNameOrEmpty, defaultTypeArguments, identifierText, symbolAtLocation, isTupleType, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, entityNameText, mainDeclaration, resolveAlias, $007CHasTypeFlags$007C_$007C, $007CHasSymbolFlags$007C_$007C } from "./Utils.js";
8
- import { GlueThisType, GlueConditionalType, GlueSubstitution_substitute, GlueConstructSignature, GlueFunctionType, GlueTypeReference, GlueReadonly, GlueRecord, GlueUtilityType, GlueInterface, GlueSubstitution_substituteMember, GlueSubstitution_mentionedTypeParameters, GlueTypeLiteral, GlueTypeUnion, GlueLiteral, GlueClassDeclaration, GluePrimitive, GlueType, GlueMethod, GlueMethodSignature, GlueMember, GlueProperty, GlueAccessor } from "../GlueAST.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";
9
10
  import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
10
- import { sortByDescending, contains as contains_1, filter as filter_1, choose as choose_1, ofList as ofList_1, exists, map, concat as concat_1, forAll, tryHead, tryFindIndex, collect, empty as empty_1, singleton, append, delay, toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
11
- import { unwrap, orElse, value as value_8, defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
12
- import { contains as contains_2, item as item_4 } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
13
- import { structuralHash, disposeSafe, comparePrimitives, stringHash, safeHash, equals, Exception } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
14
- import { List_distinctBy, List_distinct, distinct } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
15
- import { FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, ofList } from "../../fable_modules/fable-library-js.5.17.2/Map.js";
16
- import { FSharpSet__Contains } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
17
- import { sanitizeTypeName } from "../Utils/Naming.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";
18
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
19
  import { readTypeQueryNode } from "./TypeQueryNode.js";
20
20
  import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
21
21
 
@@ -35,13 +35,21 @@ function IntersectionTypePropertyResult_$reflection() {
35
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
36
  }
37
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
+
38
47
  function readPropertyWithoutDeclaration(reader, contextNode, property) {
39
48
  let matchValue_1;
40
49
  const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeOfSymbol(property);
41
- const flags = 1 | 16384;
42
- const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, flags);
50
+ const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
43
51
  if (matchValue == null) {
44
- 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", 56);
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);
45
53
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
46
54
  void (objectArg.push(item));
47
55
  return undefined;
@@ -70,9 +78,8 @@ function readInstantiatedMember(reader, contextNode, property, declaration) {
70
78
  return declaredMember;
71
79
  }
72
80
  else {
73
- const flags = 1 | 16384;
74
81
  const enclosingDeclaration = (contextNode.pos < 0) ? undefined : contextNode;
75
- const matchValue = checker.typeToTypeNode(instantiatedType, enclosingDeclaration, flags);
82
+ const matchValue = checker.typeToTypeNode(instantiatedType, enclosingDeclaration, typeNodeBuilderFlags);
76
83
  if (matchValue != null) {
77
84
  const typeNode = matchValue;
78
85
  const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
@@ -125,7 +132,7 @@ function readInstantiatedMember(reader, contextNode, property, declaration) {
125
132
  case 0:
126
133
  return new GlueMember(/* Property */ 1, [new GlueProperty(info.Name, info.Documentation, typ, info.IsStatic, info.IsOptional, info.Accessor, info.IsPrivate)]);
127
134
  case 1:
128
- return new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature(info_1.Name, info_1.Documentation, info_1.TypeParameters, functionType.Parameters, functionType.Type)]);
135
+ return new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature(info_1.Name, info_1.Documentation, info_1.TypeParameters, functionType.Parameters, functionType.Type, info_1.IsOptional)]);
129
136
  case 2:
130
137
  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)]);
131
138
  default:
@@ -138,8 +145,6 @@ function readInstantiatedMember(reader, contextNode, property, declaration) {
138
145
  }
139
146
  }
140
147
 
141
- const intersectionsInProgress = [];
142
-
143
148
  function isLibraryName(reader, name) {
144
149
  const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
145
150
  if (matchValue == null) {
@@ -160,813 +165,1955 @@ function isDeferredConditional(typ) {
160
165
  }
161
166
  }
162
167
 
163
- function inferTypeNodes(node) {
164
- return toList(delay(() => append((node.kind === 196) ? singleton(node) : empty_1(), delay(() => collect(inferTypeNodes, node.getChildren())))));
168
+ function isParseTreeNode(node) {
169
+ return (node.flags & 16) === 0;
165
170
  }
166
171
 
167
- function inferredConstraint(reader, inferTypeNode) {
168
- const matchValue_1 = inferTypeNode.typeParameter.constraint;
169
- if (matchValue_1 == null) {
170
- let atPosition;
171
- if (inferTypeNode.parent.kind === 184) {
172
- const typeReferenceNode = inferTypeNode.parent;
173
- let position;
174
- const option_1 = typeReferenceNode.typeArguments;
175
- position = ((option_1 != null) ? tryFindIndex((typeArgument) => (typeArgument === inferTypeNode), option_1) : undefined);
176
- let option_13;
177
- let option_9;
178
- let option_7;
179
- let option_5;
180
- const option_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(typeReferenceNode.typeName);
181
- let binder_2;
182
- const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
183
- binder_2 = ((symbol) => resolveAlias(checker, symbol));
184
- const option_3 = option_2;
185
- option_5 = ((option_3 != null) ? binder_2(option_3) : undefined);
186
- if (option_5 != null) {
187
- const symbol_1 = option_5;
188
- option_7 = symbol_1.declarations;
189
- }
190
- else {
191
- option_7 = undefined;
192
- }
193
- option_9 = ((option_7 != null) ? tryHead(option_7) : undefined);
194
- if (option_9 != null) {
195
- const declaration = option_9;
196
- const matchValue = declaration.kind;
197
- option_13 = ((matchValue === 264) ? declaration.typeParameters : ((matchValue === 265) ? declaration.typeParameters : ((matchValue === 266) ? declaration.typeParameters : undefined)));
172
+ function typeParametersInScope(reader, typeNode) {
173
+ const collect = (node_mut, acc_mut) => {
174
+ collect:
175
+ while (true) {
176
+ const node = node_mut, acc = acc_mut;
177
+ let option_1;
178
+ if (Operators_IsNull(node)) {
179
+ return reverse(acc);
180
+ }
181
+ 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"]()))) {
182
+ node_mut = value_6(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]());
183
+ acc_mut = acc;
184
+ continue collect;
185
+ }
186
+ else if (node.kind === 266) {
187
+ return reverse(acc);
198
188
  }
199
189
  else {
200
- option_13 = undefined;
190
+ const own_1 = defaultArg((option_1 = (isParseTreeNode(node) ? node.typeParameters : undefined), (option_1 != null) ? toList(option_1) : undefined), empty());
191
+ node_mut = node.parent;
192
+ acc_mut = append(reverse(own_1), acc);
193
+ continue collect;
201
194
  }
202
- if (option_13 != null) {
203
- const typeParameters = option_13;
204
- const option_11 = position;
205
- if (option_11 != null) {
206
- const position_1 = option_11 | 0;
207
- atPosition = ((position_1 < ~~typeParameters.length) ? (typeParameters[position_1]).constraint : undefined);
195
+ break;
196
+ }
197
+ };
198
+ return collect(typeNode.parent, empty());
199
+ }
200
+
201
+ function isDeclaredByType(typeParameter) {
202
+ const parent = typeParameter.parent;
203
+ if (!Operators_IsNull(parent)) {
204
+ const matchValue = parent.kind;
205
+ switch (matchValue) {
206
+ case 232:
207
+ case 264:
208
+ case 265:
209
+ return true;
210
+ default:
211
+ return false;
212
+ }
213
+ }
214
+ else {
215
+ return false;
216
+ }
217
+ }
218
+
219
+ function boundTypeParameters(reader, typeNode) {
220
+ return fold((bound, typeParameter) => {
221
+ let constraint_, default_;
222
+ const name = identifierText(typeParameter.name);
223
+ let binding;
224
+ const matchValue = typeParameter.default;
225
+ const matchValue_1 = typeParameter.constraint;
226
+ let matchResult, default__1, constraint__1;
227
+ if (matchValue == null) {
228
+ if (matchValue_1 != null) {
229
+ if ((constraint_ = matchValue_1, constraint_.kind !== 199)) {
230
+ matchResult = 2;
231
+ constraint__1 = matchValue_1;
208
232
  }
209
233
  else {
210
- atPosition = undefined;
234
+ matchResult = 3;
211
235
  }
212
236
  }
213
237
  else {
214
- atPosition = undefined;
238
+ matchResult = 3;
215
239
  }
216
240
  }
241
+ else if ((default_ = matchValue, isDeclaredByType(typeParameter) && (default_.kind !== 133))) {
242
+ matchResult = 0;
243
+ default__1 = matchValue;
244
+ }
217
245
  else {
218
- atPosition = undefined;
246
+ matchResult = 1;
219
247
  }
220
- if (atPosition == null) {
221
- return GlueType.Unknown;
248
+ switch (matchResult) {
249
+ case 0: {
250
+ binding = default__1;
251
+ break;
252
+ }
253
+ case 1: {
254
+ binding = undefined;
255
+ break;
256
+ }
257
+ case 2: {
258
+ binding = constraint__1;
259
+ break;
260
+ }
261
+ default:
262
+ binding = undefined;
263
+ }
264
+ let matchResult_1, binding_2;
265
+ if (binding != null) {
266
+ if (!FSharpMap__ContainsKey(bound, name)) {
267
+ matchResult_1 = 0;
268
+ binding_2 = binding;
269
+ }
270
+ else {
271
+ matchResult_1 = 1;
272
+ }
222
273
  }
223
274
  else {
224
- const constraintNode_1 = atPosition;
225
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constraintNode_1);
275
+ matchResult_1 = 1;
276
+ }
277
+ switch (matchResult_1) {
278
+ case 0:
279
+ return FSharpMap__Add(bound, name, binding_2);
280
+ default:
281
+ return bound;
282
+ }
283
+ }, empty_1({
284
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
285
+ }), typeParametersInScope(reader, typeNode));
286
+ }
287
+
288
+ function isAnyTypeParameter(reader, typeNode) {
289
+ let option_1, _arg;
290
+ if (typeNode.kind === 184) {
291
+ const typeName = typeNode.typeName;
292
+ if (typeName.kind === 80) {
293
+ 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)));
294
+ }
295
+ else {
296
+ return false;
226
297
  }
227
298
  }
228
299
  else {
229
- const constraintNode = matchValue_1;
230
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constraintNode);
300
+ return false;
231
301
  }
232
302
  }
233
303
 
234
- function truncateToDeclaredArity(reader, symbolOpt, typeArguments) {
235
- let option_5, _arg;
236
- let declaredArity;
237
- let option_8;
238
- let option_2;
239
- let binder;
240
- const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
241
- binder = ((symbol) => resolveAlias(checker, symbol));
242
- const option_1 = symbolOpt;
243
- option_2 = ((option_1 != null) ? binder(option_1) : undefined);
244
- let binder_2;
245
- const packageContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
246
- binder_2 = ((symbol_1) => mainDeclaration(packageContext, symbol_1));
247
- const option_3 = option_2;
248
- option_8 = ((option_3 != null) ? binder_2(option_3) : undefined);
249
- if (option_8 != null) {
250
- const declaration = option_8;
251
- const matchValue = declaration.kind;
252
- switch (matchValue) {
253
- case 264:
254
- case 265:
255
- case 266: {
256
- declaredArity = defaultArg((option_5 = declaration.typeParameters, (option_5 != null) ? ((_arg = option_5, ~~_arg.length)) : undefined), 0);
257
- break;
304
+ function mentionsBoundTypeParameter(bindings, typeNode) {
305
+ let option_1;
306
+ const mentions = (typeNode_1) => mentionsBoundTypeParameter(bindings, typeNode_1);
307
+ const matchValue = typeNode.kind;
308
+ switch (matchValue) {
309
+ case 184: {
310
+ const typeReferenceNode = typeNode;
311
+ const typeName = typeReferenceNode.typeName;
312
+ if ((typeName.kind === 80) && FSharpMap__ContainsKey(bindings, identifierText(typeName))) {
313
+ return true;
314
+ }
315
+ else {
316
+ return defaultArg((option_1 = typeReferenceNode.typeArguments, (option_1 != null) ? exists(mentions, option_1) : undefined), false);
258
317
  }
259
- default:
260
- declaredArity = undefined;
261
318
  }
262
- }
263
- else {
264
- declaredArity = undefined;
265
- }
266
- let matchResult, arity_1;
267
- if (declaredArity != null) {
268
- if (declaredArity < length(typeArguments)) {
269
- matchResult = 0;
270
- arity_1 = declaredArity;
319
+ case 189:
320
+ return mentions(typeNode.elementType);
321
+ case 193:
322
+ return exists(mentions, typeNode.types);
323
+ case 195: {
324
+ const conditionalTypeNode = typeNode;
325
+ if ((mentions(conditionalTypeNode.checkType) ? true : mentions(conditionalTypeNode.extendsType)) ? true : mentions(conditionalTypeNode.trueType)) {
326
+ return true;
327
+ }
328
+ else {
329
+ return mentions(conditionalTypeNode.falseType);
330
+ }
271
331
  }
272
- else {
273
- matchResult = 1;
332
+ case 200: {
333
+ const indexedAccessTypeNode = typeNode;
334
+ if (mentions(indexedAccessTypeNode.objectType)) {
335
+ return true;
336
+ }
337
+ else {
338
+ return mentions(indexedAccessTypeNode.indexType);
339
+ }
274
340
  }
275
- }
276
- else {
277
- matchResult = 1;
278
- }
279
- switch (matchResult) {
280
- case 0:
281
- return truncate(arity_1, typeArguments);
282
341
  default:
283
- return typeArguments;
342
+ return false;
284
343
  }
285
344
  }
286
345
 
287
- function isGlobalThisQuery(typeNode) {
288
- if (typeNode.kind === 187) {
289
- return entityNameText(typeNode.exprName) === "globalThis";
290
- }
291
- else {
292
- return false;
346
+ function substituteBoundTypeParameters(bindings, typeNode) {
347
+ const substitute = (typeNode_1) => substituteBoundTypeParameters(bindings, typeNode_1);
348
+ const adopt = (synthesized) => ((function (ts, node, like, flag) {
349
+ Object.assign(node, { flags: node.flags & ~flag, pos: like.pos, end: like.end, parent: like.parent });
350
+ ts.forEachChild(node, function (child) {
351
+ if ((child.flags & flag) !== 0 && !child.parent) {
352
+ Object.assign(child, { flags: child.flags & ~flag, pos: like.pos, end: like.end, parent: node });
353
+ }
354
+ });
355
+ return node;
356
+ })(ts, synthesized, typeNode, 16));
357
+ const matchValue = typeNode.kind;
358
+ switch (matchValue) {
359
+ case 184: {
360
+ const typeReferenceNode = typeNode;
361
+ const typeName = typeReferenceNode.typeName;
362
+ const matchValue_1 = typeReferenceNode.typeArguments;
363
+ if (matchValue_1 != null) {
364
+ const typeArguments = matchValue_1;
365
+ return adopt((ts.factory).createTypeReferenceNode(typeReferenceNode.typeName, Array.from(map(substitute, typeArguments))));
366
+ }
367
+ else if (typeName.kind === 80) {
368
+ return defaultArg(FSharpMap__TryFind(bindings, identifierText(typeName)), typeNode);
369
+ }
370
+ else {
371
+ return typeNode;
372
+ }
373
+ }
374
+ case 189:
375
+ return adopt((ts.factory).createArrayTypeNode(substitute(typeNode.elementType)));
376
+ case 193:
377
+ return adopt((ts.factory).createUnionTypeNode(Array.from(map(substitute, typeNode.types))));
378
+ case 195: {
379
+ const conditionalTypeNode = typeNode;
380
+ return adopt((ts.factory).createConditionalTypeNode(substitute(conditionalTypeNode.checkType), substitute(conditionalTypeNode.extendsType), substitute(conditionalTypeNode.trueType), substitute(conditionalTypeNode.falseType)));
381
+ }
382
+ case 200: {
383
+ const indexedAccessTypeNode = typeNode;
384
+ return adopt((ts.factory).createIndexedAccessTypeNode(substitute(indexedAccessTypeNode.objectType), substitute(indexedAccessTypeNode.indexType)));
385
+ }
386
+ default:
387
+ return typeNode;
293
388
  }
294
389
  }
295
390
 
296
- function readTypeUsingFlags(reader, typ) {
297
- let declarations;
391
+ function deferredConditionals(checker, depth, typ) {
392
+ let depth_1;
298
393
  const matchValue = typ.flags;
299
- let matchResult;
300
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
301
- if (Operators_IsNull(typ.symbol)) {
394
+ if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
395
+ return singleton(typ);
396
+ }
397
+ else {
398
+ let matchResult;
399
+ if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
400
+ matchResult = 0;
401
+ }
402
+ else if ($007CHasTypeFlags$007C_$007C(268435456, matchValue) != null) {
302
403
  matchResult = 0;
303
404
  }
304
405
  else {
305
406
  matchResult = 1;
306
407
  }
307
- }
308
- else {
309
- matchResult = 1;
310
- }
311
- switch (matchResult) {
312
- case 0:
313
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
314
- default:
315
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
316
- const matchValue_1 = typ.symbol.declarations;
317
- if (matchValue_1 == null) {
318
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
319
- }
320
- else if ((declarations = matchValue_1, declarations.length > 0)) {
321
- const declarations_1 = matchValue_1;
322
- const declaration = item_4(0, declarations_1);
323
- const matchValue_2 = declaration.kind;
324
- switch (matchValue_2) {
325
- case 264:
326
- 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)]);
327
- case 265:
328
- case 266: {
329
- const flags = 1 | 16384;
330
- const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, flags);
331
- if (matchValue_3 == null) {
332
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration);
333
- }
334
- else {
335
- const typeNode = matchValue_3;
336
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
337
- }
338
- }
339
- case 268:
340
- return GlueType.Discard;
341
- default:
342
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration);
408
+ switch (matchResult) {
409
+ case 0:
410
+ return collect_1((typ_1) => deferredConditionals(checker, depth, typ_1), toList(typ.types));
411
+ default: {
412
+ let matchResult_1;
413
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
414
+ if ((depth < 8) && ((typ.objectFlags & 4) !== 0)) {
415
+ matchResult_1 = 0;
416
+ }
417
+ else {
418
+ matchResult_1 = 1;
343
419
  }
344
420
  }
345
421
  else {
346
- throw new Exception("Match failure: Microsoft.FSharp.Core.FSharpOption`1");
422
+ matchResult_1 = 1;
423
+ }
424
+ switch (matchResult_1) {
425
+ case 0:
426
+ return collect_1((depth_1 = ((depth + 1) | 0), (typ_2) => deferredConditionals(checker, depth_1, typ_2)), toList(checker.getTypeArguments(typ)));
427
+ default:
428
+ return empty();
347
429
  }
348
430
  }
349
- else if ($007CHasTypeFlags$007C_$007C(32, matchValue) != null) {
350
- return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
351
- }
352
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue) != null) {
353
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]);
354
- }
355
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue) != null) {
356
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Bool]);
357
- }
358
- else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
359
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
360
- }
361
- else if ($007CHasTypeFlags$007C_$007C(16, matchValue) != null) {
362
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Unit]);
363
- }
364
- else {
365
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
366
- }
431
+ }
367
432
  }
368
433
  }
369
434
 
370
- export function UtilityType_readExclude(reader, typeReferenceNode) {
371
- 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;
372
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
373
- const matchValue = typ.flags;
374
- let matchResult;
375
- if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
376
- matchResult = 0;
377
- }
378
- else if ($007CHasTypeFlags$007C_$007C(2048, matchValue) != null) {
379
- matchResult = 0;
380
- }
381
- else if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
382
- matchResult = 0;
435
+ function mentionedTypes(checker, depth, typ) {
436
+ let option_1, matchValue, indexedAccess, conditional;
437
+ let mentioned;
438
+ const depth_1 = (depth + 1) | 0;
439
+ mentioned = ((typ_1) => mentionedTypes(checker, depth_1, typ_1));
440
+ if (depth > 8) {
441
+ return empty();
383
442
  }
384
443
  else {
385
- matchResult = 1;
444
+ 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())))))));
386
445
  }
387
- switch (matchResult) {
388
- case 0:
389
- 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", 295), (objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg.push(item)))), empty())) : singleton_1(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_1(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", 310), (objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_1.push(item_1)))), empty())) : singleton_1(new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_6.fields[0]])]))))) : choose((typ_1) => {
390
- const matchValue_2 = typ_1.flags;
391
- if ($007CHasTypeFlags$007C_$007C(1024, matchValue_2) != null) {
392
- const literalType = typ_1;
393
- return new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [literalType.value])]);
394
- }
395
- else if ($007CHasTypeFlags$007C_$007C(2048, matchValue_2) != null) {
396
- const activePatternResult_9 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ_1);
397
- switch (activePatternResult_9.tag) {
398
- case 1:
399
- return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_9.fields[0]])]);
400
- case 2: {
401
- const item_2 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 337);
402
- const objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
403
- void (objectArg_2.push(item_2));
404
- return undefined;
405
- }
406
- default:
407
- return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_9.fields[0]])]);
408
- }
409
- }
410
- else {
411
- return undefined;
412
- }
413
- }, toList(typ.types)))))]);
414
- default: {
415
- let matchResult_1;
416
- if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
417
- if ((matchValue_3 = typeReferenceNode.typeArguments, (matchValue_3 != null) && (((typeArguments = matchValue_3, ~~typeArguments.length > 1)) && ((typeArguments_1 = matchValue_3, (excluded = (typeArguments_1[0]), (isNullish = ((typeNode) => {
418
- const matchValue_4 = typeNode.kind;
419
- switch (matchValue_4) {
420
- case 157:
421
- return true;
422
- case 193:
423
- return forAll(isNullish, typeNode.types);
424
- case 202:
425
- return typeNode.literal.kind === 106;
426
- default:
427
- return false;
428
- }
429
- }), (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))))))))))))) {
430
- matchResult_1 = 0;
431
- }
432
- else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
433
- 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) => {
434
- const matchValue_8 = typeNode_1.kind;
435
- switch (matchValue_8) {
436
- case 157:
437
- return true;
438
- case 193:
439
- return forAll(isNullish_1, typeNode_1.types);
440
- case 202:
441
- return typeNode_1.literal.kind === 106;
442
- default:
443
- return false;
444
- }
445
- }), (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))))))))))))) {
446
- matchResult_1 = 0;
446
+ }
447
+
448
+ function typeParameterNamesOf(checker, typ) {
449
+ return choose((mentioned) => {
450
+ const matchValue = mentioned.flags;
451
+ if ($007CHasTypeFlags$007C_$007C(524288, matchValue) != null) {
452
+ return mentioned.symbol.name;
453
+ }
454
+ else {
455
+ return undefined;
456
+ }
457
+ }, mentionedTypes(checker, 0, typ));
458
+ }
459
+
460
+ function isStillBound(checker, bound, typ) {
461
+ const substitutes = toList(map((node_1) => checker.getTypeFromTypeNode(node_1), filter((node) => (node.kind === 184), FSharpMap__get_Values(bound))));
462
+ const mentioned = mentionedTypes(checker, 0, typ);
463
+ return exists_1((substitute) => exists_1((typ_1) => (typ_1 === substitute), mentioned), substitutes);
464
+ }
465
+
466
+ function resolveWithBindings(checker_mut, typeNode_mut, bindings_mut, bound_mut, typ_mut) {
467
+ resolveWithBindings:
468
+ while (true) {
469
+ const checker = checker_mut, typeNode = typeNode_mut, bindings = bindings_mut, bound = bound_mut, typ = typ_mut;
470
+ const conditionals = deferredConditionals(checker, 0, typ);
471
+ if (isEmpty(conditionals)) {
472
+ if (isStillBound(checker, bound, typ)) {
473
+ return undefined;
474
+ }
475
+ else {
476
+ return typ;
477
+ }
478
+ }
479
+ else {
480
+ const alreadyBound = FSharpMap__get_Count(bound) | 0;
481
+ const bound_3 = fold((bound_1, conditional) => fold((bound_2, name) => {
482
+ const matchValue = FSharpMap__TryFind(bindings, name);
483
+ let matchResult, binding_1;
484
+ if (matchValue != null) {
485
+ if (!FSharpMap__ContainsKey(bound_2, name)) {
486
+ matchResult = 0;
487
+ binding_1 = matchValue;
447
488
  }
448
489
  else {
449
- matchResult_1 = 1;
490
+ matchResult = 1;
450
491
  }
451
492
  }
452
493
  else {
453
- matchResult_1 = 1;
454
- }
455
- }
456
- else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
457
- 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) => {
458
- const matchValue_12 = typeNode_2.kind;
459
- switch (matchValue_12) {
460
- case 157:
461
- return true;
462
- case 193:
463
- return forAll(isNullish_2, typeNode_2.types);
464
- case 202:
465
- return typeNode_2.literal.kind === 106;
466
- default:
467
- return false;
468
- }
469
- }), (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))))))))))))) {
470
- matchResult_1 = 0;
494
+ matchResult = 1;
471
495
  }
472
- else {
473
- matchResult_1 = 1;
496
+ switch (matchResult) {
497
+ case 0:
498
+ return FSharpMap__Add(bound_2, name, binding_1);
499
+ default:
500
+ return bound_2;
474
501
  }
502
+ }, bound_1, append(typeParameterNamesOf(checker, conditional.checkType), typeParameterNamesOf(checker, conditional.extendsType))), bound, conditionals);
503
+ if ((FSharpMap__get_Count(bound_3) === alreadyBound) ? true : !mentionsBoundTypeParameter(bound_3, typeNode)) {
504
+ return undefined;
475
505
  }
476
506
  else {
477
- matchResult_1 = 1;
507
+ checker_mut = checker;
508
+ typeNode_mut = typeNode;
509
+ bindings_mut = bindings;
510
+ bound_mut = bound_3;
511
+ typ_mut = checker.getTypeFromTypeNode(substituteBoundTypeParameters(bound_3, typeNode));
512
+ continue resolveWithBindings;
478
513
  }
479
- switch (matchResult_1) {
480
- case 0:
481
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_8(typeReferenceNode.typeArguments)[0]);
482
- default:
483
- if ($007CHasTypeFlags$007C_$007C(32, matchValue) != null) {
484
- return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
485
- }
486
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue) != null) {
487
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]);
488
- }
489
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue) != null) {
490
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Bool]);
514
+ }
515
+ break;
516
+ }
517
+ }
518
+
519
+ function standsForConditional(checker_mut, visited_mut, node_mut) {
520
+ standsForConditional:
521
+ while (true) {
522
+ const checker = checker_mut, visited = visited_mut, node = node_mut;
523
+ let option_3;
524
+ const matchValue = node.kind;
525
+ switch (matchValue) {
526
+ case 184: {
527
+ const typeReferenceNode = node;
528
+ let matchValue_1;
529
+ const option_1 = symbolAtLocation(checker, typeReferenceNode.typeName);
530
+ matchValue_1 = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
531
+ if (matchValue_1 == null) {
532
+ return false;
533
+ }
534
+ else {
535
+ const symbol_1 = matchValue_1;
536
+ const key = checker.getFullyQualifiedName(symbol_1);
537
+ if (!FSharpSet__Contains(visited, key)) {
538
+ return defaultArg((option_3 = symbol_1.declarations, (option_3 != null) ? exists((declaration) => {
539
+ if (declaration.kind === 266) {
540
+ return standsForConditional(checker, FSharpSet__Add(visited, key), declaration.type);
541
+ }
542
+ else {
543
+ return false;
544
+ }
545
+ }, option_3) : undefined), false);
491
546
  }
492
547
  else {
493
- 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", 391);
494
- const objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
495
- void (objectArg_3.push(item_3));
496
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
548
+ return false;
497
549
  }
550
+ }
551
+ }
552
+ case 195:
553
+ return true;
554
+ case 197: {
555
+ checker_mut = checker;
556
+ visited_mut = visited;
557
+ node_mut = node.type;
558
+ continue standsForConditional;
498
559
  }
560
+ default:
561
+ return false;
499
562
  }
563
+ break;
500
564
  }
501
565
  }
502
566
 
503
- function UtilityType_readMembers(reader, contextNode, typ) {
504
- let objectArg;
505
- return toList(distinct(concat_1(choose((property) => {
506
- const matchValue = property.declarations;
507
- if (matchValue == null) {
508
- const option_1 = readPropertyWithoutDeclaration(reader, contextNode, property);
509
- if (option_1 != null) {
510
- return singleton(option_1);
567
+ function isWithinConstraint(node_mut) {
568
+ isWithinConstraint:
569
+ while (true) {
570
+ const node = node_mut;
571
+ if (Operators_IsNull(node) ? true : Operators_IsNull(node.parent)) {
572
+ return false;
573
+ }
574
+ else if (node.parent.kind === 169) {
575
+ const matchValue = node.parent.constraint;
576
+ if (matchValue == null) {
577
+ return false;
511
578
  }
512
579
  else {
513
- return undefined;
580
+ return matchValue === node;
514
581
  }
515
582
  }
516
583
  else {
517
- return map((declaration) => readInstantiatedMember(reader, contextNode, property, declaration), matchValue);
584
+ node_mut = node.parent;
585
+ continue isWithinConstraint;
518
586
  }
519
- }, toList((objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg.getPropertiesOfType(typ))))), {
520
- Equals: equals,
521
- GetHashCode: (x) => (safeHash(x) | 0),
522
- }));
587
+ break;
588
+ }
523
589
  }
524
590
 
525
- const UtilityType_expansionsInProgress = [];
526
-
527
- export function UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
528
- let matchValue, typeArguments, typNode;
529
- if (!((matchValue = typeReferenceNode.typeArguments, (matchValue == null) ? false : ((typeArguments = matchValue, ~~typeArguments.length > 0))))) {
591
+ function tryResolveDeferred(reader, typeNode) {
592
+ let resolvedNode, previousContext;
593
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
594
+ const bindings = boundTypeParameters(reader, typeNode);
595
+ if (((!isParseTreeNode(typeNode) ? true : !standsForConditional(checker, empty_2({
596
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
597
+ }), typeNode)) ? true : isWithinConstraint(typeNode)) ? true : !mentionsBoundTypeParameter(bindings, typeNode)) {
530
598
  return undefined;
531
599
  }
532
600
  else {
533
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
534
- let isNamedDeclaration;
535
- if (Operators_IsNull(typ.symbol)) {
536
- isNamedDeclaration = false;
537
- }
538
- else {
539
- const matchValue_1 = typ.symbol.declarations;
540
- isNamedDeclaration = ((matchValue_1 == null) ? false : exists((declaration) => {
541
- const matchValue_2 = declaration.kind;
542
- switch (matchValue_2) {
543
- case 264:
544
- case 265:
545
- return true;
546
- default:
547
- return false;
548
- }
549
- }, matchValue_1));
550
- }
551
- let isTypeAliasApplication;
552
- const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(typeReferenceNode.typeName);
553
- if (matchValue_3 == null) {
554
- isTypeAliasApplication = false;
601
+ const typ = checker.getTypeAtLocation(typeNode);
602
+ if (isEmpty(deferredConditionals(checker, 0, typ))) {
603
+ return undefined;
555
604
  }
556
605
  else {
557
- const symbol = matchValue_3;
558
- const matchValue_4 = symbol.flags;
559
- isTypeAliasApplication = ($007CHasSymbolFlags$007C_$007C(524288, matchValue_4) != null);
560
- }
561
- const isInProgress = exists((inProgress) => (inProgress === typ), UtilityType_expansionsInProgress);
562
- let isGenericMapped;
563
- const matchValue_5 = typ.flags;
564
- isGenericMapped = (($007CHasTypeFlags$007C_$007C(1048576, matchValue_5) != null) && (((typ.objectFlags & 32) !== 0) && exists((argument) => {
565
- const matchValue_6 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(argument).flags;
566
- if ($007CHasTypeFlags$007C_$007C(524288, matchValue_6) != null) {
567
- return true;
606
+ let option_3;
607
+ const option_1 = resolveWithBindings(checker, typeNode, bindings, empty_1({
608
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
609
+ }), typ);
610
+ if (option_1 != null) {
611
+ const resolved = option_1;
612
+ option_3 = checker.typeToTypeNode(resolved, typeNode, typeNodeBuilderFlags);
568
613
  }
569
614
  else {
570
- return false;
615
+ option_3 = undefined;
571
616
  }
572
- }, value_8(typeReferenceNode.typeArguments))));
573
- const isArrayLike = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().isArrayLikeType(typ);
574
- const matchValue_7 = typ.flags;
575
- let matchResult;
576
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
577
- if ((isTupleType(typ) ? true : (isArrayLike && !isNamedDeclaration)) && !isInProgress) {
578
- matchResult = 0;
617
+ if (option_3 != null) {
618
+ return (resolvedNode = option_3, (previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"](), (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](typeNode), (() => {
619
+ try {
620
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](resolvedNode);
621
+ }
622
+ finally {
623
+ reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
624
+ }
625
+ })())));
579
626
  }
580
627
  else {
581
- matchResult = 1;
628
+ return undefined;
582
629
  }
583
630
  }
584
- else {
585
- matchResult = 1;
586
- }
587
- switch (matchResult) {
588
- case 0: {
589
- const flags = 1 | 16384;
590
- const option_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, flags);
591
- if (option_1 != null) {
592
- return (typNode = option_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
593
- }
594
- else {
595
- return undefined;
596
- }
631
+ }
632
+ }
633
+
634
+ function inferTypeNodes(node) {
635
+ return toList(delay(() => append_1((node.kind === 196) ? singleton_1(node) : empty_3(), delay(() => collect_2(inferTypeNodes, node.getChildren())))));
636
+ }
637
+
638
+ function inferredConstraint(reader, inferTypeNode) {
639
+ const matchValue_1 = inferTypeNode.typeParameter.constraint;
640
+ if (matchValue_1 == null) {
641
+ let atPosition;
642
+ if (inferTypeNode.parent.kind === 184) {
643
+ const typeReferenceNode = inferTypeNode.parent;
644
+ let position;
645
+ const option_1 = typeReferenceNode.typeArguments;
646
+ position = ((option_1 != null) ? tryFindIndex((typeArgument) => (typeArgument === inferTypeNode), option_1) : undefined);
647
+ let option_13;
648
+ let option_9;
649
+ let option_7;
650
+ let option_5;
651
+ const option_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(typeReferenceNode.typeName);
652
+ let binder_2;
653
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
654
+ binder_2 = ((symbol) => resolveAlias(checker, symbol));
655
+ const option_3 = option_2;
656
+ option_5 = ((option_3 != null) ? binder_2(option_3) : undefined);
657
+ if (option_5 != null) {
658
+ const symbol_1 = option_5;
659
+ option_7 = symbol_1.declarations;
597
660
  }
598
- default: {
599
- let matchResult_1;
600
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
601
- if ((!isNamedDeclaration && !isInProgress) && !isGenericMapped) {
602
- matchResult_1 = 0;
661
+ else {
662
+ option_7 = undefined;
663
+ }
664
+ option_9 = ((option_7 != null) ? tryHead(option_7) : undefined);
665
+ if (option_9 != null) {
666
+ const declaration = option_9;
667
+ const matchValue = declaration.kind;
668
+ option_13 = ((matchValue === 264) ? declaration.typeParameters : ((matchValue === 265) ? declaration.typeParameters : ((matchValue === 266) ? declaration.typeParameters : undefined)));
669
+ }
670
+ else {
671
+ option_13 = undefined;
672
+ }
673
+ if (option_13 != null) {
674
+ const typeParameters = option_13;
675
+ const option_11 = position;
676
+ if (option_11 != null) {
677
+ const position_1 = option_11 | 0;
678
+ atPosition = ((position_1 < ~~typeParameters.length) ? (typeParameters[position_1]).constraint : undefined);
679
+ }
680
+ else {
681
+ atPosition = undefined;
682
+ }
683
+ }
684
+ else {
685
+ atPosition = undefined;
686
+ }
687
+ }
688
+ else {
689
+ atPosition = undefined;
690
+ }
691
+ if (atPosition == null) {
692
+ return GlueType.Unknown;
693
+ }
694
+ else {
695
+ const constraintNode_1 = atPosition;
696
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constraintNode_1);
697
+ }
698
+ }
699
+ else {
700
+ const constraintNode = matchValue_1;
701
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constraintNode);
702
+ }
703
+ }
704
+
705
+ function truncateToDeclaredArity(reader, symbolOpt, typeArguments) {
706
+ let option_5, _arg;
707
+ let declaredArity;
708
+ let option_8;
709
+ let option_2;
710
+ let binder;
711
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
712
+ binder = ((symbol) => resolveAlias(checker, symbol));
713
+ const option_1 = symbolOpt;
714
+ option_2 = ((option_1 != null) ? binder(option_1) : undefined);
715
+ let binder_2;
716
+ const packageContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
717
+ binder_2 = ((symbol_1) => mainDeclaration(packageContext, symbol_1));
718
+ const option_3 = option_2;
719
+ option_8 = ((option_3 != null) ? binder_2(option_3) : undefined);
720
+ if (option_8 != null) {
721
+ const declaration = option_8;
722
+ const matchValue = declaration.kind;
723
+ switch (matchValue) {
724
+ case 264:
725
+ case 265:
726
+ case 266: {
727
+ declaredArity = defaultArg((option_5 = declaration.typeParameters, (option_5 != null) ? ((_arg = option_5, ~~_arg.length)) : undefined), 0);
728
+ break;
729
+ }
730
+ default:
731
+ declaredArity = undefined;
732
+ }
733
+ }
734
+ else {
735
+ declaredArity = undefined;
736
+ }
737
+ let matchResult, arity_1;
738
+ if (declaredArity != null) {
739
+ if (declaredArity < length(typeArguments)) {
740
+ matchResult = 0;
741
+ arity_1 = declaredArity;
742
+ }
743
+ else {
744
+ matchResult = 1;
745
+ }
746
+ }
747
+ else {
748
+ matchResult = 1;
749
+ }
750
+ switch (matchResult) {
751
+ case 0:
752
+ return truncate(arity_1, typeArguments);
753
+ default:
754
+ return typeArguments;
755
+ }
756
+ }
757
+
758
+ function isGlobalThisQuery(typeNode) {
759
+ if (typeNode.kind === 187) {
760
+ return entityNameText(typeNode.exprName) === "globalThis";
761
+ }
762
+ else {
763
+ return false;
764
+ }
765
+ }
766
+
767
+ function readTypeUsingFlags(reader, typ) {
768
+ let declarations;
769
+ const matchValue = typ.flags;
770
+ let matchResult;
771
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
772
+ if (Operators_IsNull(typ.symbol)) {
773
+ matchResult = 0;
774
+ }
775
+ else {
776
+ matchResult = 1;
777
+ }
778
+ }
779
+ else {
780
+ matchResult = 1;
781
+ }
782
+ switch (matchResult) {
783
+ case 0:
784
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
785
+ default:
786
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
787
+ const matchValue_1 = typ.symbol.declarations;
788
+ let matchResult_1, declarations_1;
789
+ if (matchValue_1 != null) {
790
+ if ((declarations = matchValue_1, declarations.length > 0)) {
791
+ matchResult_1 = 0;
792
+ declarations_1 = matchValue_1;
793
+ }
794
+ else {
795
+ matchResult_1 = 1;
796
+ }
797
+ }
798
+ else {
799
+ matchResult_1 = 1;
800
+ }
801
+ switch (matchResult_1) {
802
+ case 0: {
803
+ const declaration = item_4(0, declarations_1);
804
+ const matchValue_2 = declaration.kind;
805
+ switch (matchValue_2) {
806
+ case 264:
807
+ 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)]);
808
+ case 265:
809
+ case 266: {
810
+ const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
811
+ if (matchValue_3 == null) {
812
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration);
813
+ }
814
+ else {
815
+ const typeNode = matchValue_3;
816
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
817
+ }
818
+ }
819
+ case 268:
820
+ return GlueType.Discard;
821
+ default:
822
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration);
823
+ }
824
+ }
825
+ default:
826
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
827
+ }
828
+ }
829
+ else {
830
+ return primitiveOfFlags(typ);
831
+ }
832
+ }
833
+ }
834
+
835
+ export function UtilityType_readExclude(reader, typeReferenceNode) {
836
+ 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;
837
+ const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
838
+ const matchValue = typ.flags;
839
+ let matchResult;
840
+ if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
841
+ matchResult = 0;
842
+ }
843
+ else if ($007CHasTypeFlags$007C_$007C(2048, matchValue) != null) {
844
+ matchResult = 0;
845
+ }
846
+ else if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
847
+ matchResult = 0;
848
+ }
849
+ else {
850
+ matchResult = 1;
851
+ }
852
+ switch (matchResult) {
853
+ case 0:
854
+ 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", 697), (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", 712), (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) => {
855
+ const matchValue_2 = typ_1.flags;
856
+ if ($007CHasTypeFlags$007C_$007C(1024, matchValue_2) != null) {
857
+ const literalType = typ_1;
858
+ return new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [literalType.value])]);
859
+ }
860
+ else if ($007CHasTypeFlags$007C_$007C(2048, matchValue_2) != null) {
861
+ const activePatternResult_9 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ_1);
862
+ switch (activePatternResult_9.tag) {
863
+ case 1:
864
+ return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_9.fields[0]])]);
865
+ case 2: {
866
+ const item_2 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 739);
867
+ const objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
868
+ void (objectArg_2.push(item_2));
869
+ return undefined;
870
+ }
871
+ default:
872
+ return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_9.fields[0]])]);
873
+ }
874
+ }
875
+ else {
876
+ return undefined;
877
+ }
878
+ }, toList(typ.types)))))]);
879
+ default: {
880
+ let matchResult_1;
881
+ if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
882
+ if ((matchValue_3 = typeReferenceNode.typeArguments, (matchValue_3 != null) && (((typeArguments = matchValue_3, ~~typeArguments.length > 1)) && ((typeArguments_1 = matchValue_3, (excluded = (typeArguments_1[0]), (isNullish = ((typeNode) => {
883
+ const matchValue_4 = typeNode.kind;
884
+ switch (matchValue_4) {
885
+ case 157:
886
+ return true;
887
+ case 193:
888
+ return forAll(isNullish, typeNode.types);
889
+ case 202:
890
+ return typeNode.literal.kind === 106;
891
+ default:
892
+ return false;
893
+ }
894
+ }), (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))))))))))))) {
895
+ matchResult_1 = 0;
896
+ }
897
+ else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
898
+ 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) => {
899
+ const matchValue_8 = typeNode_1.kind;
900
+ switch (matchValue_8) {
901
+ case 157:
902
+ return true;
903
+ case 193:
904
+ return forAll(isNullish_1, typeNode_1.types);
905
+ case 202:
906
+ return typeNode_1.literal.kind === 106;
907
+ default:
908
+ return false;
909
+ }
910
+ }), (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))))))))))))) {
911
+ matchResult_1 = 0;
912
+ }
913
+ else {
914
+ matchResult_1 = 1;
915
+ }
916
+ }
917
+ else {
918
+ matchResult_1 = 1;
919
+ }
920
+ }
921
+ else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
922
+ 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) => {
923
+ const matchValue_12 = typeNode_2.kind;
924
+ switch (matchValue_12) {
925
+ case 157:
926
+ return true;
927
+ case 193:
928
+ return forAll(isNullish_2, typeNode_2.types);
929
+ case 202:
930
+ return typeNode_2.literal.kind === 106;
931
+ default:
932
+ return false;
933
+ }
934
+ }), (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))))))))))))) {
935
+ matchResult_1 = 0;
936
+ }
937
+ else {
938
+ matchResult_1 = 1;
939
+ }
940
+ }
941
+ else {
942
+ matchResult_1 = 1;
943
+ }
944
+ switch (matchResult_1) {
945
+ case 0:
946
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_6(typeReferenceNode.typeArguments)[0]);
947
+ default:
948
+ if ($007CHasTypeFlags$007C_$007C(32, matchValue) != null) {
949
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
950
+ }
951
+ else if ($007CHasTypeFlags$007C_$007C(64, matchValue) != null) {
952
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]);
953
+ }
954
+ else if ($007CHasTypeFlags$007C_$007C(256, matchValue) != null) {
955
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Bool]);
956
+ }
957
+ else if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
958
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
959
+ }
960
+ else {
961
+ 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", 795);
962
+ const objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
963
+ void (objectArg_3.push(item_3));
964
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
965
+ }
966
+ }
967
+ }
968
+ }
969
+ }
970
+
971
+ function UtilityType_isMemberDeclaration(declaration) {
972
+ const matchValue = declaration.kind;
973
+ switch (matchValue) {
974
+ case 264:
975
+ case 265:
976
+ case 266:
977
+ case 267:
978
+ case 268:
979
+ return false;
980
+ default:
981
+ return true;
982
+ }
983
+ }
984
+
985
+ function UtilityType_readPropertyMembers(reader, contextNode, property) {
986
+ let option_1;
987
+ const declarations = defaultArg((option_1 = property.declarations, (option_1 != null) ? toList(filter(UtilityType_isMemberDeclaration, option_1)) : undefined), empty());
988
+ 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)));
989
+ }
990
+
991
+ function UtilityType_readMembers(reader, contextNode, typ) {
992
+ let objectArg;
993
+ return List_distinct(collect_1((property) => UtilityType_readPropertyMembers(reader, contextNode, property), toList((objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg.getPropertiesOfType(typ)))), {
994
+ Equals: equals,
995
+ GetHashCode: (x) => (safeHash(x) | 0),
996
+ });
997
+ }
998
+
999
+ /**
1000
+ * When a generic type reference is applied with concrete type arguments
1001
+ * (e.g. a custom utility type like <c>Picked<User, "id"></c>), the
1002
+ * TypeChecker resolves it to an anonymous object type. We read its resolved
1003
+ * members (via <see cref="readMembers"/>) and expand it into a TypeLiteral
1004
+ * so it is generated as a concrete interface instead of an unusable
1005
+ * reference to the (generic) utility.
1006
+ */
1007
+ export function UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
1008
+ let matchValue, typeArguments, typNode;
1009
+ if (!((matchValue = typeReferenceNode.typeArguments, (matchValue == null) ? false : ((typeArguments = matchValue, ~~typeArguments.length > 0))))) {
1010
+ return undefined;
1011
+ }
1012
+ else {
1013
+ const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
1014
+ let isNamedDeclaration;
1015
+ if (Operators_IsNull(typ.symbol)) {
1016
+ isNamedDeclaration = false;
1017
+ }
1018
+ else {
1019
+ const matchValue_1 = typ.symbol.declarations;
1020
+ isNamedDeclaration = ((matchValue_1 == null) ? false : exists((declaration) => {
1021
+ const matchValue_2 = declaration.kind;
1022
+ switch (matchValue_2) {
1023
+ case 264:
1024
+ case 265:
1025
+ return true;
1026
+ default:
1027
+ return false;
1028
+ }
1029
+ }, matchValue_1));
1030
+ }
1031
+ let isTypeAliasApplication;
1032
+ const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(typeReferenceNode.typeName);
1033
+ if (matchValue_3 == null) {
1034
+ isTypeAliasApplication = false;
1035
+ }
1036
+ else {
1037
+ const symbol = matchValue_3;
1038
+ const matchValue_4 = symbol.flags;
1039
+ isTypeAliasApplication = ($007CHasSymbolFlags$007C_$007C(524288, matchValue_4) != null);
1040
+ }
1041
+ const isInProgress = exists((inProgress) => (inProgress === typ), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
1042
+ let isGenericMapped;
1043
+ const matchValue_5 = typ.flags;
1044
+ isGenericMapped = (($007CHasTypeFlags$007C_$007C(1048576, matchValue_5) != null) && (((typ.objectFlags & 32) !== 0) && exists((argument) => {
1045
+ const matchValue_6 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(argument).flags;
1046
+ if ($007CHasTypeFlags$007C_$007C(524288, matchValue_6) != null) {
1047
+ return true;
1048
+ }
1049
+ else {
1050
+ return false;
1051
+ }
1052
+ }, value_6(typeReferenceNode.typeArguments))));
1053
+ const isArrayLike = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().isArrayLikeType(typ);
1054
+ const matchValue_7 = typ.flags;
1055
+ let matchResult;
1056
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
1057
+ if ((isTupleType(typ) ? true : (isArrayLike && !isNamedDeclaration)) && !isInProgress) {
1058
+ matchResult = 0;
1059
+ }
1060
+ else {
1061
+ matchResult = 1;
1062
+ }
1063
+ }
1064
+ else {
1065
+ matchResult = 1;
1066
+ }
1067
+ switch (matchResult) {
1068
+ case 0: {
1069
+ const option_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
1070
+ if (option_1 != null) {
1071
+ return (typNode = option_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
1072
+ }
1073
+ else {
1074
+ return undefined;
1075
+ }
1076
+ }
1077
+ default: {
1078
+ let matchResult_1;
1079
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
1080
+ if ((!isNamedDeclaration && !isInProgress) && !isGenericMapped) {
1081
+ matchResult_1 = 0;
1082
+ }
1083
+ else {
1084
+ matchResult_1 = 1;
1085
+ }
1086
+ }
1087
+ else {
1088
+ matchResult_1 = 1;
1089
+ }
1090
+ switch (matchResult_1) {
1091
+ case 0: {
1092
+ const members = withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions, typ, () => UtilityType_readMembers(reader, typeReferenceNode, typ));
1093
+ if (isEmpty(members)) {
1094
+ return undefined;
1095
+ }
1096
+ else {
1097
+ return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(members, undefined)]);
1098
+ }
1099
+ }
1100
+ default: {
1101
+ let matchResult_2;
1102
+ if ($007CHasTypeFlags$007C_$007C(32, matchValue_7) != null) {
1103
+ if (isTypeAliasApplication) {
1104
+ matchResult_2 = 0;
1105
+ }
1106
+ else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
1107
+ if (isTypeAliasApplication) {
1108
+ matchResult_2 = 0;
1109
+ }
1110
+ else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
1111
+ if (isTypeAliasApplication) {
1112
+ matchResult_2 = 0;
1113
+ }
1114
+ else {
1115
+ matchResult_2 = 1;
1116
+ }
1117
+ }
1118
+ else {
1119
+ matchResult_2 = 1;
1120
+ }
1121
+ }
1122
+ else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
1123
+ if (isTypeAliasApplication) {
1124
+ matchResult_2 = 0;
1125
+ }
1126
+ else {
1127
+ matchResult_2 = 1;
1128
+ }
1129
+ }
1130
+ else {
1131
+ matchResult_2 = 1;
1132
+ }
1133
+ }
1134
+ else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
1135
+ if (isTypeAliasApplication) {
1136
+ matchResult_2 = 0;
1137
+ }
1138
+ else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
1139
+ if (isTypeAliasApplication) {
1140
+ matchResult_2 = 0;
1141
+ }
1142
+ else {
1143
+ matchResult_2 = 1;
1144
+ }
1145
+ }
1146
+ else {
1147
+ matchResult_2 = 1;
1148
+ }
1149
+ }
1150
+ else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
1151
+ if (isTypeAliasApplication) {
1152
+ matchResult_2 = 0;
1153
+ }
1154
+ else {
1155
+ matchResult_2 = 1;
1156
+ }
1157
+ }
1158
+ else {
1159
+ matchResult_2 = 1;
1160
+ }
1161
+ switch (matchResult_2) {
1162
+ case 0:
1163
+ return readTypeUsingFlags(reader, typ);
1164
+ default:
1165
+ return undefined;
1166
+ }
1167
+ }
1168
+ }
1169
+ }
1170
+ }
1171
+ }
1172
+ }
1173
+
1174
+ function UtilityType_baseTypeOf(reader, typeNode) {
1175
+ let option_2, option, binder, checker, option_1, mapping, objectArg, option_3;
1176
+ const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeNode);
1177
+ const matchValue = typ.flags;
1178
+ let matchResult;
1179
+ if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
1180
+ if ((typeNode.pos < 0) && (typeNode.kind === 184)) {
1181
+ matchResult = 0;
1182
+ }
1183
+ else {
1184
+ matchResult = 1;
1185
+ }
1186
+ }
1187
+ else {
1188
+ matchResult = 1;
1189
+ }
1190
+ switch (matchResult) {
1191
+ case 0:
1192
+ 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);
1193
+ default:
1194
+ return typ;
1195
+ }
1196
+ }
1197
+
1198
+ function UtilityType_literalKeysOf(typeNode_mut) {
1199
+ UtilityType_literalKeysOf:
1200
+ while (true) {
1201
+ const typeNode = typeNode_mut;
1202
+ const matchValue = typeNode.kind;
1203
+ switch (matchValue) {
1204
+ case 193:
1205
+ return collect_1(UtilityType_literalKeysOf, toList(typeNode.types));
1206
+ case 197: {
1207
+ typeNode_mut = typeNode.type;
1208
+ continue UtilityType_literalKeysOf;
1209
+ }
1210
+ case 202: {
1211
+ const literal = typeNode.literal;
1212
+ if (literal.kind === 11) {
1213
+ return singleton(literal.text);
1214
+ }
1215
+ else {
1216
+ return empty();
1217
+ }
1218
+ }
1219
+ default:
1220
+ return empty();
1221
+ }
1222
+ break;
1223
+ }
1224
+ }
1225
+
1226
+ function UtilityType_withoutForeignTypeParameters(reader, bound, members) {
1227
+ const declaredAbove = (node) => {
1228
+ if (Operators_IsNull(node)) {
1229
+ return empty();
1230
+ }
1231
+ else {
1232
+ const typeParameters = node.typeParameters;
1233
+ return append((typeParameters == null) ? empty() : map_1((p) => identifierText(p.name), toList(typeParameters)), declaredAbove(node.parent));
1234
+ }
1235
+ };
1236
+ let inScope;
1237
+ const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
1238
+ inScope = ((matchValue == null) ? empty() : declaredAbove(matchValue));
1239
+ const signatureMentions = (returnType, parameters) => append(GlueSubstitution_mentionedTypeParameters(returnType), collect_1((parameter) => GlueSubstitution_mentionedTypeParameters(parameter.Type), parameters));
1240
+ const foreign = ofList(map_1((name_1) => [name_1, new GlueType(/* Primitive */ 3, [GluePrimitive.Any])], filter_1((name) => {
1241
+ if (!contains(name, inScope, {
1242
+ Equals: (x_1, y_1) => (x_1 === y_1),
1243
+ GetHashCode: (x_1) => (stringHash(x_1) | 0),
1244
+ })) {
1245
+ return !FSharpMap__ContainsKey(bound, name);
1246
+ }
1247
+ else {
1248
+ return false;
1249
+ }
1250
+ }, List_distinct(collect_1((glueMember) => {
1251
+ switch (glueMember.tag) {
1252
+ case 1:
1253
+ return GlueSubstitution_mentionedTypeParameters(glueMember.fields[0].Type);
1254
+ case 0: {
1255
+ const method = glueMember.fields[0];
1256
+ return signatureMentions(method.Type, method.Parameters);
1257
+ }
1258
+ case 6: {
1259
+ const method_1 = glueMember.fields[0];
1260
+ return signatureMentions(method_1.Type, method_1.Parameters);
1261
+ }
1262
+ default:
1263
+ return empty();
1264
+ }
1265
+ }, members), {
1266
+ Equals: (x, y) => (x === y),
1267
+ GetHashCode: (x) => (stringHash(x) | 0),
1268
+ }))), {
1269
+ Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
1270
+ });
1271
+ if (FSharpMap__get_IsEmpty(foreign)) {
1272
+ return members;
1273
+ }
1274
+ else {
1275
+ return map_1((glueMember_1) => GlueSubstitution_substituteMember(foreign, glueMember_1), members);
1276
+ }
1277
+ }
1278
+
1279
+ export function UtilityType_readPartial(reader, typeReferenceNode) {
1280
+ const baseType = UtilityType_baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
1281
+ if (exists((typ) => (typ === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials)) {
1282
+ const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1041);
1283
+ const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1284
+ void (objectArg.push(item));
1285
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1286
+ }
1287
+ else {
1288
+ return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials, baseType, () => {
1289
+ if (isTupleType(baseType)) {
1290
+ const typNode = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode), undefined, typeNodeBuilderFlags);
1291
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode);
1292
+ }
1293
+ else {
1294
+ const baseNode = value_6(typeReferenceNode.typeArguments)[0];
1295
+ let members;
1296
+ const matchValue = baseType.flags;
1297
+ let matchResult;
1298
+ if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
1299
+ if (baseNode.kind === 133) {
1300
+ matchResult = 0;
603
1301
  }
604
1302
  else {
605
- matchResult_1 = 1;
1303
+ matchResult = 1;
606
1304
  }
607
1305
  }
608
1306
  else {
609
- matchResult_1 = 1;
1307
+ matchResult = 1;
610
1308
  }
611
- switch (matchResult_1) {
1309
+ switch (matchResult) {
612
1310
  case 0: {
613
- void (UtilityType_expansionsInProgress.push(typ));
614
- let members;
615
- try {
616
- members = UtilityType_readMembers(reader, typeReferenceNode, typ);
617
- }
618
- finally {
619
- UtilityType_expansionsInProgress.splice(UtilityType_expansionsInProgress.length - 1, 1);
620
- }
621
- if (isEmpty(members)) {
622
- return undefined;
623
- }
624
- else {
625
- return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(members, undefined)]);
626
- }
1311
+ members = empty();
1312
+ break;
627
1313
  }
628
1314
  default: {
629
- let matchResult_2;
630
- if ($007CHasTypeFlags$007C_$007C(32, matchValue_7) != null) {
631
- if (isTypeAliasApplication) {
632
- matchResult_2 = 0;
633
- }
634
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
635
- if (isTypeAliasApplication) {
636
- matchResult_2 = 0;
637
- }
638
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
639
- if (isTypeAliasApplication) {
640
- matchResult_2 = 0;
641
- }
642
- else {
643
- matchResult_2 = 1;
644
- }
645
- }
646
- else {
647
- matchResult_2 = 1;
648
- }
649
- }
650
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
651
- if (isTypeAliasApplication) {
652
- matchResult_2 = 0;
653
- }
654
- else {
655
- matchResult_2 = 1;
656
- }
1315
+ let matchResult_1;
1316
+ if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
1317
+ if ((baseNode.pos < 0) && (baseNode.kind === 188)) {
1318
+ matchResult_1 = 0;
657
1319
  }
658
1320
  else {
659
- matchResult_2 = 1;
1321
+ matchResult_1 = 1;
660
1322
  }
661
1323
  }
662
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
663
- if (isTypeAliasApplication) {
664
- matchResult_2 = 0;
1324
+ else {
1325
+ matchResult_1 = 1;
1326
+ }
1327
+ switch (matchResult_1) {
1328
+ case 0: {
1329
+ const matchValue_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](baseNode);
1330
+ members = ((matchValue_1.tag === 22) ? matchValue_1.fields[0].Members : empty());
1331
+ break;
665
1332
  }
666
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
667
- if (isTypeAliasApplication) {
668
- matchResult_2 = 0;
1333
+ default:
1334
+ if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
1335
+ 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", 1083);
1336
+ const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1337
+ void (objectArg_1.push(item_1));
1338
+ members = empty();
669
1339
  }
670
1340
  else {
671
- matchResult_2 = 1;
1341
+ members = UtilityType_readMembers(reader, typeReferenceNode, baseType);
672
1342
  }
673
- }
674
- else {
675
- matchResult_2 = 1;
676
- }
677
- }
678
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
679
- if (isTypeAliasApplication) {
680
- matchResult_2 = 0;
681
- }
682
- else {
683
- matchResult_2 = 1;
684
- }
685
- }
686
- else {
687
- matchResult_2 = 1;
688
- }
689
- switch (matchResult_2) {
690
- case 0:
691
- return readTypeUsingFlags(reader, typ);
692
- default:
693
- return undefined;
694
1343
  }
695
1344
  }
696
1345
  }
1346
+ const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
1347
+ let members_2;
1348
+ const members_1 = map_1((glueMember) => GlueSubstitution_substituteMember(defaults, glueMember), members);
1349
+ members_2 = ((typeReferenceNode.pos < 0) ? UtilityType_withoutForeignTypeParameters(reader, defaults, members_1) : members_1);
1350
+ 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())])]);
1351
+ }
1352
+ });
1353
+ }
1354
+ }
1355
+
1356
+ export function UtilityType_readRecord(reader, typeReferenceNode) {
1357
+ const typeArguments = readTypeArguments(reader, typeReferenceNode);
1358
+ return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Record */ 1, [new GlueRecord(item_5(0, typeArguments), item_5(1, typeArguments))])]);
1359
+ }
1360
+
1361
+ export function UtilityType_readReturnType(reader, typeReferenceNode) {
1362
+ let matchValue_4, matchValue_1, symbol, matchValue_2, declarations, declarations_1;
1363
+ const rawTyp = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
1364
+ let typ;
1365
+ const matchValue = rawTyp.flags;
1366
+ let matchResult;
1367
+ if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
1368
+ matchResult = 0;
1369
+ }
1370
+ else if ($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) {
1371
+ matchResult = 0;
1372
+ }
1373
+ else if ($007CHasTypeFlags$007C_$007C(16777216, matchValue) != null) {
1374
+ matchResult = 0;
1375
+ }
1376
+ else if ($007CHasTypeFlags$007C_$007C(2097152, matchValue) != null) {
1377
+ matchResult = 0;
1378
+ }
1379
+ else {
1380
+ matchResult = 1;
1381
+ }
1382
+ switch (matchResult) {
1383
+ case 0: {
1384
+ typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getApparentType(rawTyp);
1385
+ break;
1386
+ }
1387
+ default:
1388
+ typ = rawTyp;
1389
+ }
1390
+ const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, undefined);
1391
+ if (matchValue_3 == null) {
1392
+ return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ReturnType */ 2, [readTypeUsingFlags(reader, typ)])]);
1393
+ }
1394
+ else {
1395
+ const typeNode = matchValue_3;
1396
+ 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)])]);
1397
+ }
1398
+ }
1399
+
1400
+ export function UtilityType_readThisParameterType(reader, typeReferenceNode) {
1401
+ const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
1402
+ const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, undefined);
1403
+ if (matchValue == null) {
1404
+ return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ThisParameterType */ 3, [readTypeUsingFlags(reader, typ)])]);
1405
+ }
1406
+ else {
1407
+ const typeNode = matchValue;
1408
+ return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ThisParameterType */ 3, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode)])]);
1409
+ }
1410
+ }
1411
+
1412
+ export function UtilityType_readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
1413
+ let option_1, matchValue_4, item_1, objectArg_2, objectArg_3;
1414
+ let keysToOmitType;
1415
+ const node = value_6(typeReferenceNode.typeArguments)[1];
1416
+ const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
1417
+ keysToOmitType = objectArg.getTypeFromTypeNode(node);
1418
+ let hasUnboundKeys;
1419
+ const matchValue = keysToOmitType.flags;
1420
+ let matchResult;
1421
+ if ($007CHasTypeFlags$007C_$007C(524288, matchValue) != null) {
1422
+ matchResult = 0;
1423
+ }
1424
+ else if ($007CHasTypeFlags$007C_$007C(2097152, matchValue) != null) {
1425
+ matchResult = 0;
1426
+ }
1427
+ else if ($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) {
1428
+ matchResult = 0;
1429
+ }
1430
+ else {
1431
+ matchResult = 1;
1432
+ }
1433
+ switch (matchResult) {
1434
+ case 0: {
1435
+ hasUnboundKeys = true;
1436
+ break;
1437
+ }
1438
+ default:
1439
+ hasUnboundKeys = false;
1440
+ }
1441
+ const tryReadValueOfKeys = (typ) => {
1442
+ const activePatternResult_3 = Type_StringLiteral_$007CString$007COther$007C(typ);
1443
+ if (activePatternResult_3.tag === 1) {
1444
+ const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1205);
1445
+ const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1446
+ void (objectArg_1.push(item));
1447
+ return undefined;
1448
+ }
1449
+ else {
1450
+ return activePatternResult_3.fields[0];
1451
+ }
1452
+ };
1453
+ let keysToOmit;
1454
+ const matchValue_1 = keysToOmitType.flags;
1455
+ let matchResult_1;
1456
+ if (hasUnboundKeys) {
1457
+ matchResult_1 = 0;
1458
+ }
1459
+ else if ($007CHasTypeFlags$007C_$007C(1, matchValue_1) != null) {
1460
+ if (typeReferenceNode.pos < 0) {
1461
+ matchResult_1 = 1;
1462
+ }
1463
+ else {
1464
+ matchResult_1 = 2;
1465
+ }
1466
+ }
1467
+ else {
1468
+ matchResult_1 = 2;
1469
+ }
1470
+ switch (matchResult_1) {
1471
+ case 0: {
1472
+ keysToOmit = empty_3();
1473
+ break;
1474
+ }
1475
+ case 1: {
1476
+ keysToOmit = ofList_1(UtilityType_literalKeysOf(value_6(typeReferenceNode.typeArguments)[1]));
1477
+ break;
1478
+ }
1479
+ default:
1480
+ keysToOmit = (keysToOmitType.isUnion() ? choose_1(tryReadValueOfKeys, keysToOmitType.types) : defaultArg((option_1 = tryReadValueOfKeys(keysToOmitType), (option_1 != null) ? singleton_1(option_1) : undefined), []));
1481
+ }
1482
+ const baseType = UtilityType_baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
1483
+ let literalMembers;
1484
+ const matchValue_2 = baseType.flags;
1485
+ let matchResult_2;
1486
+ if ($007CHasTypeFlags$007C_$007C(1, matchValue_2) != null) {
1487
+ if (typeReferenceNode.pos < 0) {
1488
+ matchResult_2 = 0;
1489
+ }
1490
+ else {
1491
+ matchResult_2 = 1;
1492
+ }
1493
+ }
1494
+ else {
1495
+ matchResult_2 = 1;
1496
+ }
1497
+ switch (matchResult_2) {
1498
+ case 0: {
1499
+ const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_6(typeReferenceNode.typeArguments)[0]);
1500
+ literalMembers = ((matchValue_3.tag === 20) ? matchValue_3.fields[0] : ((matchValue_3.tag === 22) ? matchValue_3.fields[0].Members : undefined));
1501
+ break;
1502
+ }
1503
+ default:
1504
+ literalMembers = undefined;
1505
+ }
1506
+ const filteredProperties = toList(filter((prop) => (keepListedKeys === contains_1(prop.name, keysToOmit, {
1507
+ Equals: (x, y) => (x === y),
1508
+ GetHashCode: (x) => (stringHash(x) | 0),
1509
+ })), (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", 1240), (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", 1240), (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)))))));
1510
+ const isInProgress = exists((inProgress) => (inProgress === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
1511
+ 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));
1512
+ const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
1513
+ let members_4;
1514
+ const members_3 = map_1((glueMember_2) => GlueSubstitution_substituteMember(defaults, glueMember_2), (literalMembers == null) ? members_1 : filter_1((glueMember_1) => {
1515
+ let matchValue_5;
1516
+ const glueMember = glueMember_1;
1517
+ switch (glueMember.tag) {
1518
+ case 0: {
1519
+ matchValue_5 = glueMember.fields[0].Name;
1520
+ break;
1521
+ }
1522
+ case 6: {
1523
+ matchValue_5 = glueMember.fields[0].Name;
1524
+ break;
1525
+ }
1526
+ case 2: {
1527
+ matchValue_5 = glueMember.fields[0].Name;
1528
+ break;
1529
+ }
1530
+ case 3: {
1531
+ matchValue_5 = glueMember.fields[0].Name;
1532
+ break;
1533
+ }
1534
+ case 4:
1535
+ case 5:
1536
+ case 7: {
1537
+ matchValue_5 = undefined;
1538
+ break;
697
1539
  }
1540
+ default:
1541
+ matchValue_5 = glueMember.fields[0].Name;
1542
+ }
1543
+ if (matchValue_5 == null) {
1544
+ return !keepListedKeys;
1545
+ }
1546
+ else {
1547
+ return keepListedKeys === contains_1(matchValue_5, keysToOmit, {
1548
+ Equals: (x_1, y_2) => (x_1 === y_2),
1549
+ GetHashCode: (x_1) => (stringHash(x_1) | 0),
1550
+ });
698
1551
  }
1552
+ }, literalMembers));
1553
+ members_4 = ((typeReferenceNode.pos < 0) ? UtilityType_withoutForeignTypeParameters(reader, defaults, members_3) : members_3);
1554
+ if (hasUnboundKeys ? true : isInProgress) {
1555
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1556
+ }
1557
+ else {
1558
+ return new GlueType(/* UtilityType */ 27, [(keepListedKeys ? ((Item) => (new GlueUtilityType(/* Pick */ 5, [Item]))) : ((Item_1) => (new GlueUtilityType(/* Omit */ 4, [Item_1]))))(members_4)]);
699
1559
  }
700
1560
  }
701
1561
 
702
- const UtilityType_partialsBeingRead = [];
1562
+ export function UtilityType_readOmit(reader, typeReferenceNode) {
1563
+ return UtilityType_readOmitOrPick(reader, typeReferenceNode, false);
1564
+ }
703
1565
 
704
- function UtilityType_baseTypeOf(reader, typeNode) {
705
- let option_2, option, binder, checker, option_1, mapping, objectArg, option_3;
706
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeNode);
1566
+ export function UtilityType_readPick(reader, typeReferenceNode) {
1567
+ return UtilityType_readOmitOrPick(reader, typeReferenceNode, true);
1568
+ }
1569
+
1570
+ export function UtilityType_readReadonly(reader, typeReferenceNode) {
1571
+ const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
707
1572
  const matchValue = typ.flags;
708
1573
  let matchResult;
709
- if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
710
- if ((typeNode.pos < 0) && (typeNode.kind === 184)) {
711
- matchResult = 0;
712
- }
713
- else {
714
- matchResult = 1;
715
- }
1574
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
1575
+ matchResult = 0;
1576
+ }
1577
+ else if ($007CHasTypeFlags$007C_$007C(268435456, matchValue) != null) {
1578
+ matchResult = 0;
716
1579
  }
717
1580
  else {
718
1581
  matchResult = 1;
719
1582
  }
720
1583
  switch (matchResult) {
721
1584
  case 0:
722
- 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);
1585
+ return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Readonly */ 6, [new GlueReadonly(/* Members */ 0, [UtilityType_readMembers(reader, typeReferenceNode, typ)])])]);
723
1586
  default:
724
- return typ;
725
- }
726
- }
727
-
728
- function UtilityType_literalKeysOf(typeNode_mut) {
729
- UtilityType_literalKeysOf:
730
- while (true) {
731
- const typeNode = typeNode_mut;
732
- const matchValue = typeNode.kind;
733
- switch (matchValue) {
734
- case 193:
735
- return collect_1(UtilityType_literalKeysOf, toList(typeNode.types));
736
- case 197: {
737
- typeNode_mut = typeNode.type;
738
- continue UtilityType_literalKeysOf;
739
- }
740
- case 202: {
741
- const literal = typeNode.literal;
742
- if (literal.kind === 11) {
743
- return singleton_1(literal.text);
1587
+ if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
1588
+ const unionType = typ;
1589
+ try {
1590
+ return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Readonly */ 6, [new GlueReadonly(/* Union */ 1, [toList(choose_1((innerType) => {
1591
+ let copyOfStruct, Name;
1592
+ if ((copyOfStruct = innerType.flags, (copyOfStruct & 1048576) !== 0)) {
1593
+ 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()));
1594
+ }
1595
+ else {
1596
+ return undefined;
1597
+ }
1598
+ }, unionType.types))])])]);
744
1599
  }
745
- else {
746
- return empty();
1600
+ catch (matchValue_1) {
1601
+ const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1364);
1602
+ const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1603
+ void (objectArg.push(item));
1604
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
747
1605
  }
748
1606
  }
749
- default:
750
- return empty();
751
- }
752
- break;
1607
+ else {
1608
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1609
+ }
753
1610
  }
754
1611
  }
755
1612
 
756
- function UtilityType_withoutForeignTypeParameters(reader, bound, members) {
757
- const declaredAbove = (node) => {
758
- if (Operators_IsNull(node)) {
759
- return empty();
760
- }
761
- else {
762
- const typeParameters = node.typeParameters;
763
- return append_1((typeParameters == null) ? empty() : map_1((p) => identifierText(p.name), toList(typeParameters)), declaredAbove(node.parent));
764
- }
765
- };
766
- let inScope;
767
- const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
768
- inScope = ((matchValue == null) ? empty() : declaredAbove(matchValue));
769
- const foreign = ofList(map_1((name_1) => [name_1, new GlueType(/* Primitive */ 3, [GluePrimitive.Any])], filter((name) => {
770
- if (!contains(name, inScope, {
771
- Equals: (x_1, y_1) => (x_1 === y_1),
772
- GetHashCode: (x_1) => (stringHash(x_1) | 0),
773
- })) {
774
- return !FSharpMap__ContainsKey(bound, name);
1613
+ function readTypeReference(reader, typeNode) {
1614
+ let option_13, symbol_4;
1615
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
1616
+ const typeReferenceNode = typeNode;
1617
+ const symbolOpt = symbolAtLocation(checker, typeReferenceNode.typeName);
1618
+ const readTypeReference_1 = (isStandardLibrary) => {
1619
+ let symbol_2, matchValue_3, declarations, typNode, option_9, valueDeclaration, matchValue_5, matchValue_6;
1620
+ if ((symbolOpt == null) ? false : ((symbol_2 = symbolOpt, (matchValue_3 = symbol_2.flags, $007CHasSymbolFlags$007C_$007C(262144, matchValue_3) != null)))) {
1621
+ return new GlueType(/* TypeParameter */ 16, [value_6(symbolOpt).name]);
775
1622
  }
776
1623
  else {
777
- return false;
778
- }
779
- }, List_distinct(collect_1((glueMember) => {
780
- switch (glueMember.tag) {
781
- case 1:
782
- return GlueSubstitution_mentionedTypeParameters(glueMember.fields[0].Type);
783
- case 0: {
784
- const method = glueMember.fields[0];
785
- return append_1(GlueSubstitution_mentionedTypeParameters(method.Type), collect_1((parameter) => GlueSubstitution_mentionedTypeParameters(parameter.Type), method.Parameters));
786
- }
787
- case 6: {
788
- const method_1 = glueMember.fields[0];
789
- return append_1(GlueSubstitution_mentionedTypeParameters(method_1.Type), collect_1((parameter_1) => GlueSubstitution_mentionedTypeParameters(parameter_1.Type), method_1.Parameters));
790
- }
791
- default:
792
- return empty();
793
- }
794
- }, members), {
795
- Equals: (x, y) => (x === y),
796
- GetHashCode: (x) => (stringHash(x) | 0),
797
- }))), {
798
- Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
799
- });
800
- if (FSharpMap__get_IsEmpty(foreign)) {
801
- return members;
802
- }
803
- else {
804
- return map_1((glueMember_1) => GlueSubstitution_substituteMember(foreign, glueMember_1), members);
805
- }
806
- }
807
-
808
- export function UtilityType_readPartial(reader, typeReferenceNode) {
809
- const baseType = UtilityType_baseTypeOf(reader, value_8(typeReferenceNode.typeArguments)[0]);
810
- if (exists((typ) => (typ === baseType), UtilityType_partialsBeingRead)) {
811
- const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 628);
812
- const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
813
- void (objectArg.push(item));
814
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
815
- }
816
- else {
817
- void (UtilityType_partialsBeingRead.push(baseType));
818
- try {
819
- if (isTupleType(baseType)) {
820
- const flags = 1 | 16384;
821
- const typNode = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode), undefined, flags);
822
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode);
1624
+ let matchValue_4;
1625
+ let option_7;
1626
+ const option_5 = UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
1627
+ if (option_5 != null) {
1628
+ option_7 = option_5;
823
1629
  }
824
1630
  else {
825
- const baseNode = value_8(typeReferenceNode.typeArguments)[0];
826
- let members;
827
- const matchValue = baseType.flags;
828
- let matchResult;
829
- if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
830
- if (baseNode.kind === 133) {
831
- matchResult = 0;
1631
+ let isConditionalAlias;
1632
+ let matchValue;
1633
+ const option_1 = symbolOpt;
1634
+ matchValue = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
1635
+ if (matchValue == null) {
1636
+ isConditionalAlias = false;
1637
+ }
1638
+ else {
1639
+ const symbol_1 = matchValue;
1640
+ const matchValue_1 = symbol_1.declarations;
1641
+ let matchResult, declarations_1;
1642
+ if (matchValue_1 != null) {
1643
+ if ((declarations = matchValue_1, declarations.length > 0)) {
1644
+ matchResult = 0;
1645
+ declarations_1 = matchValue_1;
1646
+ }
1647
+ else {
1648
+ matchResult = 1;
1649
+ }
832
1650
  }
833
1651
  else {
834
1652
  matchResult = 1;
835
1653
  }
1654
+ switch (matchResult) {
1655
+ case 0: {
1656
+ const declaration = item_4(0, declarations_1);
1657
+ isConditionalAlias = ((declaration.kind === 266) && (declaration.type.kind === 195));
1658
+ break;
1659
+ }
1660
+ default:
1661
+ isConditionalAlias = false;
1662
+ }
1663
+ }
1664
+ if ((typeReferenceNode.pos < 0) ? true : !isConditionalAlias) {
1665
+ option_7 = undefined;
836
1666
  }
837
1667
  else {
838
- matchResult = 1;
1668
+ const typ = checker.getTypeFromTypeNode(typeReferenceNode);
1669
+ let isUnknown;
1670
+ const matchValue_2 = typ.flags;
1671
+ let matchResult_1;
1672
+ if ($007CHasTypeFlags$007C_$007C(1, matchValue_2) != null) {
1673
+ matchResult_1 = 0;
1674
+ }
1675
+ else if ($007CHasTypeFlags$007C_$007C(262144, matchValue_2) != null) {
1676
+ matchResult_1 = 0;
1677
+ }
1678
+ else {
1679
+ matchResult_1 = 1;
1680
+ }
1681
+ switch (matchResult_1) {
1682
+ case 0: {
1683
+ isUnknown = true;
1684
+ break;
1685
+ }
1686
+ default:
1687
+ isUnknown = false;
1688
+ }
1689
+ if (isDeferredConditional(typ) ? true : isUnknown) {
1690
+ option_7 = undefined;
1691
+ }
1692
+ else {
1693
+ const option_3 = checker.typeToTypeNode(typ, typeReferenceNode, typeNodeBuilderFlags);
1694
+ option_7 = ((option_3 != null) ? ((typNode = option_3, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode))) : undefined);
1695
+ }
839
1696
  }
840
- switch (matchResult) {
841
- case 0: {
842
- members = empty();
843
- break;
1697
+ }
1698
+ matchValue_4 = ((option_7 != null) ? option_7 : tryResolveDeferred(reader, typeNode));
1699
+ if (matchValue_4 == null) {
1700
+ const isQualified = typeReferenceNode.typeName.kind === 167;
1701
+ const writtenName = () => {
1702
+ if (isQualified) {
1703
+ return typeReferenceNode.typeName.right.text;
844
1704
  }
845
- default: {
846
- let matchResult_1;
847
- if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
848
- if ((baseNode.pos < 0) && (baseNode.kind === 188)) {
849
- matchResult_1 = 0;
850
- }
851
- else {
852
- matchResult_1 = 1;
853
- }
1705
+ else {
1706
+ return identifierText(typeReferenceNode.typeName);
1707
+ }
1708
+ };
1709
+ let name;
1710
+ if (symbolOpt == null) {
1711
+ name = writtenName();
1712
+ }
1713
+ else {
1714
+ const symbol_3 = symbolOpt;
1715
+ name = defaultArg(orElse(importedName(checker, symbol_3), (option_9 = symbol_3.valueDeclaration, (option_9 != null) ? ((valueDeclaration = option_9, (matchValue_5 = valueDeclaration.kind, (matchValue_5 === 267) ? (isQualified ? symbol_3.name : writtenName()) : ((matchValue_5 === 307) ? (valueDeclaration.symbol.parent.getName()) : writtenName())))) : undefined)), writtenName());
1716
+ }
1717
+ const isUnresolved = ((reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]() != null) && (symbolOpt == null)) && (typeReferenceNode.pos >= 0);
1718
+ const isExternal = isExternalToPackages(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbolOpt);
1719
+ if ((((name === "...") ? true : ((matchValue_6 = typeReferenceNode.typeArguments, (matchValue_6 == null) ? false : exists((typeArgument) => {
1720
+ if (typeArgument.kind === 184) {
1721
+ return typeArgument.typeName.escapedText === "...";
1722
+ }
1723
+ else {
1724
+ return false;
1725
+ }
1726
+ }, matchValue_6)))) ? true : isUnresolved) ? true : (isExternal && !FSharpSet__Contains(knownExternalTypeNames, name))) {
1727
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1728
+ }
1729
+ else {
1730
+ return new GlueType(/* TypeReference */ 13, [new GlueTypeReference((name.indexOf(".") >= 0) ? name : sanitizeTypeName(name), getFullNameOrEmpty(checker, typeReferenceNode.typeName), 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, typeNode)), symbolOpt), truncateToDeclaredArity(reader, symbolOpt, readTypeArguments(reader, typeReferenceNode)), (isStandardLibrary ? true : isExternal) ? true : isLibraryName(reader, name))]);
1731
+ }
1732
+ }
1733
+ else {
1734
+ return matchValue_4;
1735
+ }
1736
+ }
1737
+ };
1738
+ 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))) {
1739
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_6(typeReferenceNode.typeArguments)[0]);
1740
+ }
1741
+ else if (isFromEs5Lib(symbolOpt)) {
1742
+ const matchValue_10 = getFullNameOrEmpty(checker, typeReferenceNode.typeName);
1743
+ switch (matchValue_10) {
1744
+ case "Exclude":
1745
+ return UtilityType_readExclude(reader, typeReferenceNode);
1746
+ case "Uppercase":
1747
+ case "Lowercase":
1748
+ case "Capitalize":
1749
+ case "Uncapitalize": {
1750
+ const literals = (typ_1) => {
1751
+ const matchValue_7 = typ_1.flags;
1752
+ if ($007CHasTypeFlags$007C_$007C(1024, matchValue_7) != null) {
1753
+ const activePatternResult_4 = Type_StringLiteral_$007CString$007COther$007C(typ_1);
1754
+ if (activePatternResult_4.tag === 1) {
1755
+ return undefined;
854
1756
  }
855
1757
  else {
856
- matchResult_1 = 1;
1758
+ return singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_4.fields[0]])]));
857
1759
  }
858
- switch (matchResult_1) {
859
- case 0: {
860
- const matchValue_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](baseNode);
861
- members = ((matchValue_1.tag === 22) ? matchValue_1.fields[0].Members : empty());
862
- break;
863
- }
864
- default:
865
- if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
866
- 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", 671);
867
- const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
868
- void (objectArg_1.push(item_1));
869
- members = empty();
1760
+ }
1761
+ else if ($007CHasTypeFlags$007C_$007C(134217728, matchValue_7) != null) {
1762
+ return fold((acc, cases) => {
1763
+ let matchResult_2, acc_1, cases_1;
1764
+ if (acc != null) {
1765
+ if (cases != null) {
1766
+ matchResult_2 = 0;
1767
+ acc_1 = acc;
1768
+ cases_1 = cases;
870
1769
  }
871
1770
  else {
872
- members = UtilityType_readMembers(reader, typeReferenceNode, baseType);
1771
+ matchResult_2 = 1;
873
1772
  }
1773
+ }
1774
+ else {
1775
+ matchResult_2 = 1;
1776
+ }
1777
+ switch (matchResult_2) {
1778
+ case 0:
1779
+ return append(acc_1, cases_1);
1780
+ default:
1781
+ return undefined;
1782
+ }
1783
+ }, empty(), map_1(literals, toList(typ_1.types)));
1784
+ }
1785
+ else {
1786
+ return undefined;
1787
+ }
1788
+ };
1789
+ if (typeReferenceNode.pos < 0) {
1790
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
1791
+ }
1792
+ else {
1793
+ const matchValue_9 = literals(checker.getTypeFromTypeNode(typeReferenceNode));
1794
+ let matchResult_3, single, cases_2;
1795
+ if (matchValue_9 != null) {
1796
+ if (!isEmpty(matchValue_9)) {
1797
+ if (isEmpty(tail(matchValue_9))) {
1798
+ matchResult_3 = 0;
1799
+ single = head(matchValue_9);
1800
+ }
1801
+ else {
1802
+ matchResult_3 = 1;
1803
+ cases_2 = matchValue_9;
1804
+ }
874
1805
  }
1806
+ else {
1807
+ matchResult_3 = 2;
1808
+ }
1809
+ }
1810
+ else {
1811
+ matchResult_3 = 2;
1812
+ }
1813
+ switch (matchResult_3) {
1814
+ case 0:
1815
+ return single;
1816
+ case 1:
1817
+ return new GlueType(/* Union */ 7, [new GlueTypeUnion(cases_2)]);
1818
+ default:
1819
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
875
1820
  }
876
1821
  }
877
- const defaults = defaultTypeArguments(reader, value_8(typeReferenceNode.typeArguments)[0]);
878
- let members_2;
879
- const members_1 = map_1((glueMember) => GlueSubstitution_substituteMember(defaults, glueMember), members);
880
- members_2 = ((typeReferenceNode.pos < 0) ? UtilityType_withoutForeignTypeParameters(reader, defaults, members_1) : members_1);
881
- 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())])]);
882
1822
  }
1823
+ case "Partial":
1824
+ return UtilityType_readPartial(reader, typeReferenceNode);
1825
+ case "Record":
1826
+ return UtilityType_readRecord(reader, typeReferenceNode);
1827
+ case "ReturnType":
1828
+ return UtilityType_readReturnType(reader, typeReferenceNode);
1829
+ case "ThisParameterType":
1830
+ return UtilityType_readThisParameterType(reader, typeReferenceNode);
1831
+ case "Omit": {
1832
+ const option_16 = UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
1833
+ if (option_16 != null) {
1834
+ return option_16;
1835
+ }
1836
+ else {
1837
+ return UtilityType_readOmit(reader, typeReferenceNode);
1838
+ }
1839
+ }
1840
+ case "Pick": {
1841
+ const option_18 = UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
1842
+ if (option_18 != null) {
1843
+ return option_18;
1844
+ }
1845
+ else {
1846
+ return UtilityType_readPick(reader, typeReferenceNode);
1847
+ }
1848
+ }
1849
+ case "Readonly":
1850
+ return UtilityType_readReadonly(reader, typeReferenceNode);
1851
+ default:
1852
+ return readTypeReference_1(true);
883
1853
  }
884
- finally {
885
- UtilityType_partialsBeingRead.splice(UtilityType_partialsBeingRead.length - 1, 1);
886
- }
1854
+ }
1855
+ else {
1856
+ return readTypeReference_1(isFromEsLib(symbolOpt));
887
1857
  }
888
1858
  }
889
1859
 
890
- export function UtilityType_readRecord(reader, typeReferenceNode) {
891
- const typeArguments = readTypeArguments(reader, typeReferenceNode);
892
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Record */ 1, [new GlueRecord(item_5(0, typeArguments), item_5(1, typeArguments))])]);
1860
+ function readFunctionType(reader, typeNode) {
1861
+ let matchValue_1;
1862
+ const functionTypeNode = typeNode;
1863
+ let typeParameters;
1864
+ const collectEnclosing = (node_mut, acc_mut) => {
1865
+ collectEnclosing:
1866
+ while (true) {
1867
+ const node = node_mut, acc = acc_mut;
1868
+ if (Operators_IsNull(node)) {
1869
+ return acc;
1870
+ }
1871
+ 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"]()))) {
1872
+ node_mut = value_6(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]());
1873
+ acc_mut = acc;
1874
+ continue collectEnclosing;
1875
+ }
1876
+ else if (node.kind === 169) {
1877
+ return empty();
1878
+ }
1879
+ else {
1880
+ const ownTypeParameters = node.typeParameters;
1881
+ const acc_1 = (ownTypeParameters == null) ? acc : append(acc, toList(ownTypeParameters));
1882
+ node_mut = node.parent;
1883
+ acc_mut = acc_1;
1884
+ continue collectEnclosing;
1885
+ }
1886
+ break;
1887
+ }
1888
+ };
1889
+ const matchValue = List_distinctBy((typeParameter) => identifierText(typeParameter.name), collectEnclosing(functionTypeNode, empty()), {
1890
+ Equals: (x, y) => (x === y),
1891
+ GetHashCode: (x) => (stringHash(x) | 0),
1892
+ });
1893
+ typeParameters = (isEmpty(matchValue) ? empty() : reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"]((ts.factory).createNodeArray(Array.from(matchValue))));
1894
+ 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))]);
893
1895
  }
894
1896
 
895
- export function UtilityType_readReturnType(reader, typeReferenceNode) {
896
- let matchValue_4, matchValue_1, symbol, matchValue_2, declarations, declarations_1;
897
- const rawTyp = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
898
- let typ;
899
- const matchValue = rawTyp.flags;
900
- let matchResult;
901
- if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
902
- matchResult = 0;
903
- }
904
- else if ($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) {
905
- matchResult = 0;
906
- }
907
- else if ($007CHasTypeFlags$007C_$007C(16777216, matchValue) != null) {
908
- matchResult = 0;
1897
+ function readImportType(reader, typeNode) {
1898
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
1899
+ const importTypeNode = typeNode;
1900
+ let unresolvedModule;
1901
+ if (importTypeNode.pos < 0) {
1902
+ unresolvedModule = undefined;
909
1903
  }
910
- else if ($007CHasTypeFlags$007C_$007C(2097152, matchValue) != null) {
911
- matchResult = 0;
1904
+ else if (importTypeNode.argument.kind === 202) {
1905
+ const literal = importTypeNode.argument.literal;
1906
+ unresolvedModule = ((symbolAtLocation(checker, literal) != null) ? undefined : literal.text);
912
1907
  }
913
1908
  else {
914
- matchResult = 1;
1909
+ unresolvedModule = undefined;
915
1910
  }
916
- switch (matchResult) {
917
- case 0: {
918
- typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getApparentType(rawTyp);
919
- break;
1911
+ const matchValue_1 = importTypeNode.qualifier;
1912
+ if (unresolvedModule == null) {
1913
+ if (matchValue_1 == null) {
1914
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1915
+ }
1916
+ else if (importTypeNode.isTypeOf) {
1917
+ const qualifier_1 = matchValue_1;
1918
+ const typNode = (ts.factory).createTypeQueryNode(qualifier_1);
1919
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode);
1920
+ }
1921
+ else {
1922
+ const qualifier_2 = matchValue_1;
1923
+ const typNode_1 = (ts.factory).createTypeReferenceNode(qualifier_2, unwrap(importTypeNode.typeArguments));
1924
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode_1);
920
1925
  }
921
- default:
922
- typ = rawTyp;
923
- }
924
- const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, undefined);
925
- if (matchValue_3 == null) {
926
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ReturnType */ 2, [readTypeUsingFlags(reader, typ)])]);
927
1926
  }
928
1927
  else {
929
- const typeNode = matchValue_3;
930
- 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)])]);
1928
+ const moduleName = unresolvedModule;
1929
+ const warning = concat("\'", moduleName, "\' is not installed, the types imported from it are generated as \'obj\'");
1930
+ if (!contains_2(warning, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), {
1931
+ Equals: (x, y) => (x === y),
1932
+ GetHashCode: (x) => (stringHash(x) | 0),
1933
+ })) {
1934
+ void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning));
1935
+ }
1936
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
931
1937
  }
932
1938
  }
933
1939
 
934
- export function UtilityType_readThisParameterType(reader, typeReferenceNode) {
935
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
936
- const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, undefined);
937
- if (matchValue == null) {
938
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ThisParameterType */ 3, [readTypeUsingFlags(reader, typ)])]);
1940
+ function readThisType(reader, typeNode) {
1941
+ let option_1, arg;
1942
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
1943
+ const thisTypeNode = typeNode;
1944
+ const typ = checker.getTypeAtLocation(thisTypeNode);
1945
+ const declarations = Operators_IsNull(typ.symbol) ? undefined : typ.symbol.declarations;
1946
+ const typParameters = (declarations == null) ? empty() : defaultArg((option_1 = tryHead(sortByDescending((typeParameters) => (~~typeParameters.length | 0), choose_1((declaration) => {
1947
+ const matchValue = declaration.kind;
1948
+ switch (matchValue) {
1949
+ case 264:
1950
+ case 265: {
1951
+ const classDeclaration = declaration;
1952
+ return classDeclaration.typeParameters;
1953
+ }
1954
+ default:
1955
+ return undefined;
1956
+ }
1957
+ }, declarations), {
1958
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
1959
+ })), (option_1 != null) ? ((arg = option_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](arg))) : undefined), empty());
1960
+ if (Operators_IsNull(typ.symbol)) {
1961
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
939
1962
  }
940
1963
  else {
941
- const typeNode = matchValue;
942
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ThisParameterType */ 3, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode)])]);
1964
+ return new GlueType(/* ThisType */ 17, [new GlueThisType(defaultArg(declaredName(typ.symbol), typ.symbol.name), typParameters)]);
943
1965
  }
944
1966
  }
945
1967
 
946
- export function UtilityType_readOmit(reader, typeReferenceNode) {
947
- let option_1, matchValue_3, item_1, objectArg_2, objectArg_3, members_3;
948
- let keysToOmitType;
949
- const node = value_8(typeReferenceNode.typeArguments)[1];
950
- const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
951
- keysToOmitType = objectArg.getTypeFromTypeNode(node);
952
- const tryReadValueOfKeys = (typ) => {
953
- const activePatternResult = Type_StringLiteral_$007CString$007COther$007C(typ);
954
- if (activePatternResult.tag === 1) {
955
- const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 782);
956
- const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
957
- void (objectArg_1.push(item));
958
- return undefined;
1968
+ function readIntersectionConstituents(reader, typeNode) {
1969
+ let matchValue;
1970
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
1971
+ const intersectionTypeNode = typeNode;
1972
+ const unionOrIntersectionType = checker.getTypeAtLocation(intersectionTypeNode);
1973
+ void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections.push(unionOrIntersectionType));
1974
+ const _guard = {
1975
+ Dispose() {
1976
+ reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections.splice(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections.length - 1, 1);
1977
+ },
1978
+ };
1979
+ try {
1980
+ const properties_1 = choose((property_1) => {
1981
+ const matchValue_1 = property_1.declarations;
1982
+ if (matchValue_1 == null) {
1983
+ return new IntersectionTypePropertyResult(/* WithoutDeclaration */ 1, [property_1]);
1984
+ }
1985
+ else {
1986
+ const declarations = matchValue_1;
1987
+ if (declarations.length === 1) {
1988
+ return new IntersectionTypePropertyResult(/* Single */ 0, [property_1, item_4(0, declarations)]);
1989
+ }
1990
+ else if (forAll((declaration) => {
1991
+ if (declaration.kind === 172) {
1992
+ return true;
1993
+ }
1994
+ else {
1995
+ return declaration.kind === 173;
1996
+ }
1997
+ }, declarations)) {
1998
+ return new IntersectionTypePropertyResult(/* WithoutDeclaration */ 1, [property_1]);
1999
+ }
2000
+ else {
2001
+ return IntersectionTypePropertyResult.ForceAny;
2002
+ }
2003
+ }
2004
+ }, unionOrIntersectionType.isUnion() ? List_distinct(concat_1(map_1((arg) => toList(checker.getPropertiesOfType(arg)), toList(unionOrIntersectionType.types))), {
2005
+ Equals: equals,
2006
+ GetHashCode: (x) => (structuralHash(x) | 0),
2007
+ }) : ((matchValue = toList(unionOrIntersectionType.getProperties()), isEmpty(matchValue) ? ((intersectionTypeNode.pos >= 0) ? List_distinctBy((property) => property.name, collect_1((constituent) => {
2008
+ let type_1;
2009
+ return toList((type_1 = checker.getTypeAtLocation(constituent), checker.getPropertiesOfType(type_1)));
2010
+ }, toList(intersectionTypeNode.types)), {
2011
+ Equals: (x_1, y_1) => (x_1 === y_1),
2012
+ GetHashCode: (x_1) => (stringHash(x_1) | 0),
2013
+ }) : matchValue) : matchValue)));
2014
+ const intersectsATypeQuery = exists((constituent_1) => (constituent_1.kind === 187), intersectionTypeNode.types);
2015
+ const everyConstituentIsAReference = forAll((constituent_2) => (constituent_2.kind === 184), intersectionTypeNode.types);
2016
+ const hasUnsupportedProperties = intersectsATypeQuery ? true : exists_1((property_2) => {
2017
+ switch (property_2.tag) {
2018
+ case 1:
2019
+ return false;
2020
+ case 0:
2021
+ if (everyConstituentIsAReference) {
2022
+ return property_2.fields[1].kind === 175;
2023
+ }
2024
+ else {
2025
+ return false;
2026
+ }
2027
+ default:
2028
+ return true;
2029
+ }
2030
+ }, properties_1);
2031
+ const callSignatures = unionOrIntersectionType.isUnion() ? empty() : choose((signature) => {
2032
+ const synthesized = checker.signatureToSignatureDeclaration(signature, 180, typeNode, typeNodeBuilderFlags);
2033
+ if (synthesized == null) {
2034
+ return undefined;
2035
+ }
2036
+ else {
2037
+ const declaration_2 = synthesized;
2038
+ declaration_2.parent = typeNode;
2039
+ const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
2040
+ reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](declaration_2);
2041
+ try {
2042
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_2);
2043
+ }
2044
+ finally {
2045
+ reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
2046
+ }
2047
+ }
2048
+ }, toList(checker.getSignaturesOfType(unionOrIntersectionType, 0)));
2049
+ if (hasUnsupportedProperties) {
2050
+ const references = map_1((constituent_3) => {
2051
+ if (constituent_3.kind === 184) {
2052
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constituent_3);
2053
+ }
2054
+ else {
2055
+ return GlueType.Discard;
2056
+ }
2057
+ }, toList(intersectionTypeNode.types));
2058
+ const literalMembers = collect_1((constituent_4) => {
2059
+ if (constituent_4.kind === 188) {
2060
+ const matchValue_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constituent_4);
2061
+ if (matchValue_2.tag === 22) {
2062
+ return matchValue_2.fields[0].Members;
2063
+ }
2064
+ else {
2065
+ return empty();
2066
+ }
2067
+ }
2068
+ else {
2069
+ return empty();
2070
+ }
2071
+ }, toList(intersectionTypeNode.types));
2072
+ const inheritable = filter_1((reference) => !equals(reference, GlueType.Discard), references);
2073
+ return (!isEmpty(inheritable) && forAll_1((_arg) => {
2074
+ if (_arg.tag === 13) {
2075
+ return true;
2076
+ }
2077
+ else {
2078
+ return false;
2079
+ }
2080
+ }, inheritable)) ? (new GlueType(/* IntersectionOfReferences */ 21, [inheritable, literalMembers])) : (new GlueType(/* Primitive */ 3, [GluePrimitive.Any]));
959
2081
  }
960
2082
  else {
961
- return activePatternResult.fields[0];
2083
+ return new GlueType(/* IntersectionType */ 20, [append(withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing, typeNode, () => choose((_arg_1) => {
2084
+ switch (_arg_1.tag) {
2085
+ case 1:
2086
+ return readPropertyWithoutDeclaration(reader, typeNode, _arg_1.fields[0]);
2087
+ case 2:
2088
+ throw new Exception("Should not happen here");
2089
+ default:
2090
+ return readInstantiatedMember(reader, typeNode, _arg_1.fields[0], _arg_1.fields[1]);
2091
+ }
2092
+ }, properties_1)), append(callSignatures, collect_1((constituent_5) => {
2093
+ if (constituent_5.kind === 188) {
2094
+ return map_1((declaration_4) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_4), filter_1((element) => (element.kind === 182), toList(constituent_5.members)));
2095
+ }
2096
+ else {
2097
+ return empty();
2098
+ }
2099
+ }, toList(intersectionTypeNode.types))))]);
962
2100
  }
963
- };
964
- let keysToOmit;
965
- const matchValue = keysToOmitType.flags;
966
- let matchResult;
967
- if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
968
- if (typeReferenceNode.pos < 0) {
2101
+ }
2102
+ finally {
2103
+ disposeSafe(_guard);
2104
+ }
2105
+ }
2106
+
2107
+ function readIntersectionType(reader, typeNode) {
2108
+ const constituents = toList(filter((arg) => {
2109
+ let constituent, this$;
2110
+ return !((constituent = arg, (constituent.kind === 188) && (((this$ = constituent.members, ~~this$.length)) === 0)));
2111
+ }, typeNode.types));
2112
+ let matchResult, single;
2113
+ if (!isEmpty(constituents)) {
2114
+ if (isEmpty(tail(constituents))) {
969
2115
  matchResult = 0;
2116
+ single = head(constituents);
970
2117
  }
971
2118
  else {
972
2119
  matchResult = 1;
@@ -976,136 +2123,179 @@ export function UtilityType_readOmit(reader, typeReferenceNode) {
976
2123
  matchResult = 1;
977
2124
  }
978
2125
  switch (matchResult) {
979
- case 0: {
980
- keysToOmit = ofList_1(UtilityType_literalKeysOf(value_8(typeReferenceNode.typeArguments)[1]));
981
- break;
982
- }
2126
+ case 0:
2127
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](single);
983
2128
  default:
984
- keysToOmit = (keysToOmitType.isUnion() ? choose_1(tryReadValueOfKeys, keysToOmitType.types) : defaultArg((option_1 = tryReadValueOfKeys(keysToOmitType), (option_1 != null) ? singleton(option_1) : undefined), []));
2129
+ return readIntersectionConstituents(reader, typeNode);
985
2130
  }
986
- const baseType = UtilityType_baseTypeOf(reader, value_8(typeReferenceNode.typeArguments)[0]);
987
- let literalMembers;
988
- const matchValue_1 = baseType.flags;
989
- let matchResult_1;
990
- if ($007CHasTypeFlags$007C_$007C(1, matchValue_1) != null) {
991
- if (typeReferenceNode.pos < 0) {
992
- matchResult_1 = 0;
993
- }
994
- else {
995
- matchResult_1 = 1;
2131
+ }
2132
+
2133
+ function readExpressionWithTypeArguments(reader, typeNode) {
2134
+ 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;
2135
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
2136
+ const expression = typeNode;
2137
+ const typ = checker.getTypeFromTypeNode(expression);
2138
+ const symbolOpt = orElse(orElse(typ.aliasSymbol, Operators_IsNull(typ.symbol) ? undefined : typ.symbol), checker.getSymbolAtLocation(expression.expression));
2139
+ const isFromEs5 = isFromEs5Lib(symbolOpt);
2140
+ const matchValue = getFullNameOrEmpty(checker, expression.expression);
2141
+ let matchResult;
2142
+ if (isFromEs5) {
2143
+ switch (matchValue) {
2144
+ case "Omit": {
2145
+ matchResult = 0;
2146
+ break;
2147
+ }
2148
+ case "Pick": {
2149
+ matchResult = 1;
2150
+ break;
2151
+ }
2152
+ default:
2153
+ matchResult = 2;
996
2154
  }
997
2155
  }
998
2156
  else {
999
- matchResult_1 = 1;
2157
+ matchResult = 2;
1000
2158
  }
1001
- switch (matchResult_1) {
1002
- case 0: {
1003
- const matchValue_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_8(typeReferenceNode.typeArguments)[0]);
1004
- literalMembers = ((matchValue_2.tag === 20) ? matchValue_2.fields[0] : ((matchValue_2.tag === 22) ? matchValue_2.fields[0].Members : undefined));
1005
- break;
2159
+ switch (matchResult) {
2160
+ case 0:
2161
+ return UtilityType_readOmit(reader, expression);
2162
+ case 1:
2163
+ return UtilityType_readPick(reader, expression);
2164
+ default: {
2165
+ const isQualified = expression.expression.kind === 212;
2166
+ 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());
2167
+ const isExternal = isExternalToPackages(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbolOpt);
2168
+ 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")))) {
2169
+ return GlueType.Discard;
2170
+ }
2171
+ else {
2172
+ return new GlueType(/* TypeReference */ 13, [new GlueTypeReference((name.indexOf(".") >= 0) ? name : sanitizeTypeName(name), (matchValue_2 = ((option_4 = symbolOpt, (option_4 != null) ? resolveAlias(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) => {
2173
+ const typNode = checker.typeToTypeNode(argument, undefined, typeNodeBuilderFlags);
2174
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode);
2175
+ }, isEmpty(ofAlias) ? resolvedBaseTypeArguments(checker, expression) : ofAlias))) : matchValue_3), (isFromEs5 ? true : isExternal) ? true : isLibraryName(reader, name))]);
2176
+ }
1006
2177
  }
1007
- default:
1008
- literalMembers = undefined;
1009
2178
  }
1010
- const members_1 = collect_1((property) => {
1011
- const matchValue_4 = property.declarations;
1012
- if (matchValue_4 == null) {
1013
- throw new Exception(Report_readerError_Z19516DCE("type node", "Missing declarations", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 841));
1014
- }
1015
- else {
1016
- return map_1((declaration) => readInstantiatedMember(reader, typeReferenceNode, property, declaration), toList(matchValue_4));
1017
- }
1018
- }, toList(filter_1((prop) => !contains_1(prop.name, keysToOmit, {
1019
- Equals: (x, y) => (x === y),
1020
- GetHashCode: (x) => (stringHash(x) | 0),
1021
- }), (matchValue_3 = baseType.flags, ($007CHasTypeFlags$007C_$007C(1, matchValue_3) != null) ? ((literalMembers != null) ? [] : (($007CHasTypeFlags$007C_$007C(1, matchValue_3) != 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", 816), (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_3) != 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", 816), (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))))))));
1022
- const defaults = defaultTypeArguments(reader, value_8(typeReferenceNode.typeArguments)[0]);
1023
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Omit */ 4, [(members_3 = map_1((glueMember_2) => GlueSubstitution_substituteMember(defaults, glueMember_2), (literalMembers == null) ? members_1 : filter((glueMember_1) => {
1024
- let matchValue_5;
1025
- const glueMember = glueMember_1;
1026
- switch (glueMember.tag) {
1027
- case 0: {
1028
- matchValue_5 = glueMember.fields[0].Name;
1029
- break;
2179
+ }
2180
+
2181
+ function readConditionalType(reader, typeNode) {
2182
+ let branch, trueType, falseType;
2183
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
2184
+ const conditionalTypeNode = typeNode;
2185
+ const typ = checker.getTypeAtLocation(conditionalTypeNode);
2186
+ if (isDeferredConditional(typ)) {
2187
+ const resolved = isAnyTypeParameter(reader, conditionalTypeNode.checkType) ? ((branch = ((node) => {
2188
+ const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](node);
2189
+ let matchResult, glueType;
2190
+ if (matchValue.tag === 8) {
2191
+ if (matchValue.fields[0].tag === 4) {
2192
+ matchResult = 0;
2193
+ }
2194
+ else {
2195
+ matchResult = 1;
2196
+ glueType = matchValue;
2197
+ }
1030
2198
  }
1031
- case 6: {
1032
- matchValue_5 = glueMember.fields[0].Name;
1033
- break;
2199
+ else {
2200
+ matchResult = 1;
2201
+ glueType = matchValue;
1034
2202
  }
1035
- case 2: {
1036
- matchValue_5 = glueMember.fields[0].Name;
1037
- break;
2203
+ switch (matchResult) {
2204
+ case 0:
2205
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Null]);
2206
+ default:
2207
+ return glueType;
1038
2208
  }
1039
- case 3: {
1040
- matchValue_5 = glueMember.fields[0].Name;
1041
- break;
2209
+ }), (trueType = branch(conditionalTypeNode.trueType), (falseType = branch(conditionalTypeNode.falseType), equals(trueType, falseType) ? trueType : (new GlueType(/* Union */ 7, [new GlueTypeUnion(ofArray([trueType, falseType]))])))))) : tryResolveDeferred(reader, typeNode);
2210
+ if (resolved == null) {
2211
+ const warningsCount = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length | 0;
2212
+ const inferred = List_distinctBy((_arg) => _arg.Name, map_1((inferTypeNode) => (new GlueTypeParameter(inferTypeNode.typeParameter.name.getText(), inferredConstraint(reader, inferTypeNode), undefined)), inferTypeNodes(conditionalTypeNode.extendsType)), {
2213
+ Equals: (x, y) => (x === y),
2214
+ GetHashCode: (x) => (stringHash(x) | 0),
2215
+ });
2216
+ 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);
2217
+ if (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length > warningsCount) {
2218
+ reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().splice(warningsCount, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length - warningsCount);
2219
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1042
2220
  }
1043
- case 4:
1044
- case 5:
1045
- case 7: {
1046
- matchValue_5 = undefined;
1047
- break;
2221
+ else {
2222
+ return new GlueType(/* ConditionalType */ 33, [conditionalType]);
1048
2223
  }
1049
- default:
1050
- matchValue_5 = glueMember.fields[0].Name;
1051
- }
1052
- if (matchValue_5 == null) {
1053
- return true;
1054
2224
  }
1055
2225
  else {
1056
- return !contains_1(matchValue_5, keysToOmit, {
1057
- Equals: (x_1, y_1) => (x_1 === y_1),
1058
- GetHashCode: (x_1) => (stringHash(x_1) | 0),
1059
- });
2226
+ return resolved;
1060
2227
  }
1061
- }, literalMembers)), (typeReferenceNode.pos < 0) ? UtilityType_withoutForeignTypeParameters(reader, defaults, members_3) : members_3)])]);
1062
- }
1063
-
1064
- export function UtilityType_readReadonly(reader, typeReferenceNode) {
1065
- const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
1066
- const matchValue = typ.flags;
1067
- let matchResult;
1068
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
1069
- matchResult = 0;
1070
- }
1071
- else if ($007CHasTypeFlags$007C_$007C(268435456, matchValue) != null) {
1072
- matchResult = 0;
1073
2228
  }
1074
2229
  else {
1075
- matchResult = 1;
1076
- }
1077
- switch (matchResult) {
1078
- case 0:
1079
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Readonly */ 5, [new GlueReadonly(/* Members */ 0, [UtilityType_readMembers(reader, typeReferenceNode, typ)])])]);
1080
- default:
1081
- if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
1082
- const unionType = typ;
1083
- try {
1084
- return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Readonly */ 5, [new GlueReadonly(/* Union */ 1, [toList(choose_1((innerType) => {
1085
- let copyOfStruct, Name;
1086
- if ((copyOfStruct = innerType.flags, (copyOfStruct & 1048576) !== 0)) {
1087
- return (Name = (value_8(innerType.aliasTypeArguments)[0]).symbol.name, new GlueInterface(empty(), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getFullyQualifiedName((value_8(innerType.aliasTypeArguments)[0]).symbol), Name, UtilityType_readMembers(reader, typeReferenceNode, innerType), empty(), empty()));
1088
- }
1089
- else {
1090
- return undefined;
1091
- }
1092
- }, unionType.types))])])]);
2230
+ const matchValue_1 = typ.flags;
2231
+ if ($007CHasTypeFlags$007C_$007C(524288, matchValue_1) != null) {
2232
+ return new GlueType(/* TypeParameter */ 16, [typ.symbol.name]);
2233
+ }
2234
+ else if ($007CHasTypeFlags$007C_$007C(8192, matchValue_1) != null) {
2235
+ return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Bool */ 3, [typ.intrinsicName === "true"])]);
2236
+ }
2237
+ else {
2238
+ const matchValue_2 = readTypeUsingFlags(reader, typ);
2239
+ let matchResult_1, forward;
2240
+ if (matchValue_2.tag === 3) {
2241
+ if (matchValue_2.fields[0].tag === 6) {
2242
+ matchResult_1 = 0;
1093
2243
  }
1094
- catch (matchValue_1) {
1095
- const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 923);
1096
- const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1097
- void (objectArg.push(item));
1098
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
2244
+ else {
2245
+ matchResult_1 = 1;
2246
+ forward = matchValue_2;
1099
2247
  }
1100
2248
  }
1101
2249
  else {
1102
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
2250
+ matchResult_1 = 1;
2251
+ forward = matchValue_2;
2252
+ }
2253
+ switch (matchResult_1) {
2254
+ case 0:
2255
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.checkType);
2256
+ default:
2257
+ return forward;
2258
+ }
2259
+ }
2260
+ }
2261
+ }
2262
+
2263
+ function readTemplateLiteralType(reader, typeNode) {
2264
+ const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
2265
+ const templateLiteralTypeNode = typeNode;
2266
+ const readResolvedLiterals = (typ_1) => {
2267
+ const matchValue = typ_1.flags;
2268
+ if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
2269
+ const activePatternResult_1 = Type_StringLiteral_$007CString$007COther$007C(typ_1);
2270
+ if (activePatternResult_1.tag === 1) {
2271
+ return empty();
2272
+ }
2273
+ else {
2274
+ return singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_1.fields[0]])]));
1103
2275
  }
2276
+ }
2277
+ else if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
2278
+ return collect_1(readResolvedLiterals, toList(typ_1.types));
2279
+ }
2280
+ else {
2281
+ return empty();
2282
+ }
2283
+ };
2284
+ const matchValue_1 = readResolvedLiterals(checker.getTypeAtLocation(templateLiteralTypeNode));
2285
+ if (!isEmpty(matchValue_1)) {
2286
+ if (isEmpty(tail(matchValue_1))) {
2287
+ return head(matchValue_1);
2288
+ }
2289
+ else {
2290
+ return new GlueType(/* Union */ 7, [new GlueTypeUnion(matchValue_1)]);
2291
+ }
2292
+ }
2293
+ else {
2294
+ return GlueType.TemplateLiteral;
1104
2295
  }
1105
2296
  }
1106
2297
 
1107
2298
  export function readTypeNode(reader, typeNode) {
1108
- let option_11, symbol_4, matchValue_14, matchValue_23, option_14, arg_2, symbol_5, symbol_7, symbol_8, symbol_9, matchValue_29, option_21, symbol_11, matchValue_30;
1109
2299
  const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
1110
2300
  const matchValue = typeNode.kind;
1111
2301
  switch (matchValue) {
@@ -1134,276 +2324,18 @@ export function readTypeNode(reader, typeNode) {
1134
2324
  case 163:
1135
2325
  return new GlueType(/* Primitive */ 3, [GluePrimitive.BigInt$]);
1136
2326
  case 183: {
1137
- const matchValue_12 = typeNode.assertsModifier;
1138
- if (matchValue_12 == null) {
2327
+ const matchValue_1 = typeNode.assertsModifier;
2328
+ if (matchValue_1 == null) {
1139
2329
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Bool]);
1140
2330
  }
1141
2331
  else {
1142
2332
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Unit]);
1143
2333
  }
1144
2334
  }
1145
- case 184: {
1146
- const typeReferenceNode = typeNode;
1147
- const symbolOpt = symbolAtLocation(checker, typeReferenceNode.typeName);
1148
- const readTypeReference = (isStandardLibrary) => {
1149
- let symbol_2, matchValue_4, declarations, typNode, option_7, valueDeclaration, matchValue_6, matchValue_7;
1150
- if ((symbolOpt == null) ? false : ((symbol_2 = symbolOpt, (matchValue_4 = symbol_2.flags, $007CHasSymbolFlags$007C_$007C(262144, matchValue_4) != null)))) {
1151
- return new GlueType(/* TypeParameter */ 16, [value_8(symbolOpt).name]);
1152
- }
1153
- else {
1154
- let matchValue_5;
1155
- const option_5 = UtilityType_tryExpandAnonymousObjectApplication(reader, typeReferenceNode);
1156
- if (option_5 != null) {
1157
- matchValue_5 = option_5;
1158
- }
1159
- else {
1160
- let isConditionalAlias;
1161
- let matchValue_1;
1162
- const option_1 = symbolOpt;
1163
- matchValue_1 = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
1164
- if (matchValue_1 == null) {
1165
- isConditionalAlias = false;
1166
- }
1167
- else {
1168
- const symbol_1 = matchValue_1;
1169
- const matchValue_2 = symbol_1.declarations;
1170
- let matchResult, declarations_1;
1171
- if (matchValue_2 != null) {
1172
- if ((declarations = matchValue_2, declarations.length > 0)) {
1173
- matchResult = 0;
1174
- declarations_1 = matchValue_2;
1175
- }
1176
- else {
1177
- matchResult = 1;
1178
- }
1179
- }
1180
- else {
1181
- matchResult = 1;
1182
- }
1183
- switch (matchResult) {
1184
- case 0: {
1185
- const declaration = item_4(0, declarations_1);
1186
- isConditionalAlias = ((declaration.kind === 266) && (declaration.type.kind === 195));
1187
- break;
1188
- }
1189
- default:
1190
- isConditionalAlias = false;
1191
- }
1192
- }
1193
- if ((typeReferenceNode.pos < 0) ? true : !isConditionalAlias) {
1194
- matchValue_5 = undefined;
1195
- }
1196
- else {
1197
- const typ = checker.getTypeFromTypeNode(typeReferenceNode);
1198
- let isUnknown;
1199
- const matchValue_3 = typ.flags;
1200
- let matchResult_1;
1201
- if ($007CHasTypeFlags$007C_$007C(1, matchValue_3) != null) {
1202
- matchResult_1 = 0;
1203
- }
1204
- else if ($007CHasTypeFlags$007C_$007C(262144, matchValue_3) != null) {
1205
- matchResult_1 = 0;
1206
- }
1207
- else {
1208
- matchResult_1 = 1;
1209
- }
1210
- switch (matchResult_1) {
1211
- case 0: {
1212
- isUnknown = true;
1213
- break;
1214
- }
1215
- default:
1216
- isUnknown = false;
1217
- }
1218
- if (isDeferredConditional(typ) ? true : isUnknown) {
1219
- matchValue_5 = undefined;
1220
- }
1221
- else {
1222
- const flags = 1 | 16384;
1223
- const option_3 = checker.typeToTypeNode(typ, typeReferenceNode, flags);
1224
- matchValue_5 = ((option_3 != null) ? ((typNode = option_3, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode))) : undefined);
1225
- }
1226
- }
1227
- }
1228
- if (matchValue_5 == null) {
1229
- const isQualified = typeReferenceNode.typeName.kind === 167;
1230
- const writtenName = () => {
1231
- if (isQualified) {
1232
- return typeReferenceNode.typeName.right.text;
1233
- }
1234
- else {
1235
- return identifierText(typeReferenceNode.typeName);
1236
- }
1237
- };
1238
- let name;
1239
- if (symbolOpt == null) {
1240
- name = writtenName();
1241
- }
1242
- else {
1243
- const symbol_3 = symbolOpt;
1244
- name = defaultArg(orElse(importedName(checker, symbol_3), (option_7 = symbol_3.valueDeclaration, (option_7 != null) ? ((valueDeclaration = option_7, (matchValue_6 = valueDeclaration.kind, (matchValue_6 === 267) ? (isQualified ? symbol_3.name : writtenName()) : ((matchValue_6 === 307) ? (valueDeclaration.symbol.parent.getName()) : writtenName())))) : undefined)), writtenName());
1245
- }
1246
- const isUnresolved = ((reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]() != null) && (symbolOpt == null)) && (typeReferenceNode.pos >= 0);
1247
- const isExternal = isExternalToPackages(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbolOpt);
1248
- if ((((name === "...") ? true : ((matchValue_7 = typeReferenceNode.typeArguments, (matchValue_7 == null) ? false : exists((typeArgument) => {
1249
- if (typeArgument.kind === 184) {
1250
- return typeArgument.typeName.escapedText === "...";
1251
- }
1252
- else {
1253
- return false;
1254
- }
1255
- }, matchValue_7)))) ? true : isUnresolved) ? true : (isExternal && !FSharpSet__Contains(knownExternalTypeNames, name))) {
1256
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1257
- }
1258
- else {
1259
- return new GlueType(/* TypeReference */ 13, [new GlueTypeReference((name.indexOf(".") >= 0) ? name : sanitizeTypeName(name), getFullNameOrEmpty(checker, typeReferenceNode.typeName), isLibraryName(reader, name) ? empty() : modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), isQualified, symbolOpt), truncateToDeclaredArity(reader, symbolOpt, readTypeArguments(reader, typeReferenceNode)), (isStandardLibrary ? true : isExternal) ? true : isLibraryName(reader, name))]);
1260
- }
1261
- }
1262
- else {
1263
- return matchValue_5;
1264
- }
1265
- }
1266
- };
1267
- if (((entityNameText(typeReferenceNode.typeName) === "NoInfer") && (typeReferenceNode.typeArguments != null)) && ((((option_11 = symbolOpt, (option_11 != null) ? ((symbol_4 = option_11, symbol_4.declarations)) : undefined)) == null) ? true : isFromEs5Lib(symbolOpt))) {
1268
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_8(typeReferenceNode.typeArguments)[0]);
1269
- }
1270
- else if (isFromEs5Lib(symbolOpt)) {
1271
- const matchValue_11 = getFullNameOrEmpty(checker, typeReferenceNode.typeName);
1272
- switch (matchValue_11) {
1273
- case "Exclude":
1274
- return UtilityType_readExclude(reader, typeReferenceNode);
1275
- case "Uppercase":
1276
- case "Lowercase":
1277
- case "Capitalize":
1278
- case "Uncapitalize": {
1279
- const literals = (typ_1) => {
1280
- const matchValue_8 = typ_1.flags;
1281
- if ($007CHasTypeFlags$007C_$007C(1024, matchValue_8) != null) {
1282
- const activePatternResult_4 = Type_StringLiteral_$007CString$007COther$007C(typ_1);
1283
- if (activePatternResult_4.tag === 1) {
1284
- return undefined;
1285
- }
1286
- else {
1287
- return singleton_1(new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_4.fields[0]])]));
1288
- }
1289
- }
1290
- else if ($007CHasTypeFlags$007C_$007C(134217728, matchValue_8) != null) {
1291
- return fold((acc, cases) => {
1292
- let matchResult_2, acc_1, cases_1;
1293
- if (acc != null) {
1294
- if (cases != null) {
1295
- matchResult_2 = 0;
1296
- acc_1 = acc;
1297
- cases_1 = cases;
1298
- }
1299
- else {
1300
- matchResult_2 = 1;
1301
- }
1302
- }
1303
- else {
1304
- matchResult_2 = 1;
1305
- }
1306
- switch (matchResult_2) {
1307
- case 0:
1308
- return append_1(acc_1, cases_1);
1309
- default:
1310
- return undefined;
1311
- }
1312
- }, empty(), map_1(literals, toList(typ_1.types)));
1313
- }
1314
- else {
1315
- return undefined;
1316
- }
1317
- };
1318
- if (typeReferenceNode.pos < 0) {
1319
- return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
1320
- }
1321
- else {
1322
- const matchValue_10 = literals(checker.getTypeFromTypeNode(typeReferenceNode));
1323
- let matchResult_3, single, cases_2;
1324
- if (matchValue_10 != null) {
1325
- if (!isEmpty(matchValue_10)) {
1326
- if (isEmpty(tail(matchValue_10))) {
1327
- matchResult_3 = 0;
1328
- single = head(matchValue_10);
1329
- }
1330
- else {
1331
- matchResult_3 = 1;
1332
- cases_2 = matchValue_10;
1333
- }
1334
- }
1335
- else {
1336
- matchResult_3 = 2;
1337
- }
1338
- }
1339
- else {
1340
- matchResult_3 = 2;
1341
- }
1342
- switch (matchResult_3) {
1343
- case 0:
1344
- return single;
1345
- case 1:
1346
- return new GlueType(/* Union */ 7, [new GlueTypeUnion(cases_2)]);
1347
- default:
1348
- return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
1349
- }
1350
- }
1351
- }
1352
- case "Partial":
1353
- return UtilityType_readPartial(reader, typeReferenceNode);
1354
- case "Record":
1355
- return UtilityType_readRecord(reader, typeReferenceNode);
1356
- case "ReturnType":
1357
- return UtilityType_readReturnType(reader, typeReferenceNode);
1358
- case "ThisParameterType":
1359
- return UtilityType_readThisParameterType(reader, typeReferenceNode);
1360
- case "Omit":
1361
- return UtilityType_readOmit(reader, typeReferenceNode);
1362
- case "Readonly":
1363
- return UtilityType_readReadonly(reader, typeReferenceNode);
1364
- default:
1365
- return readTypeReference(true);
1366
- }
1367
- }
1368
- else {
1369
- return readTypeReference(isFromEsLib(symbolOpt));
1370
- }
1371
- }
1372
- case 185: {
1373
- const functionTypeNode = typeNode;
1374
- let typeParameters;
1375
- const collectEnclosing = (node_mut, acc_2_mut) => {
1376
- collectEnclosing:
1377
- while (true) {
1378
- const node = node_mut, acc_2 = acc_2_mut;
1379
- if (Operators_IsNull(node)) {
1380
- return acc_2;
1381
- }
1382
- else if (((Operators_IsNull(node.parent) && (node.pos < 0)) && (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]() != null)) && !(node === value_8(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]()))) {
1383
- node_mut = value_8(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]());
1384
- acc_2_mut = acc_2;
1385
- continue collectEnclosing;
1386
- }
1387
- else if (node.kind === 169) {
1388
- return empty();
1389
- }
1390
- else {
1391
- const ownTypeParameters = node.typeParameters;
1392
- const acc_3 = (ownTypeParameters == null) ? acc_2 : append_1(acc_2, toList(ownTypeParameters));
1393
- node_mut = node.parent;
1394
- acc_2_mut = acc_3;
1395
- continue collectEnclosing;
1396
- }
1397
- break;
1398
- }
1399
- };
1400
- const matchValue_13 = List_distinctBy((typeParameter) => identifierText(typeParameter.name), collectEnclosing(functionTypeNode, empty()), {
1401
- Equals: (x, y) => (x === y),
1402
- GetHashCode: (x) => (stringHash(x) | 0),
1403
- });
1404
- typeParameters = (isEmpty(matchValue_13) ? empty() : reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"]((ts.factory).createNodeArray(Array.from(matchValue_13))));
1405
- 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_14 = functionTypeNode.typeParameters, (matchValue_14 == null) ? empty() : toList(map((typeParameter_1) => identifierText(typeParameter_1.name), matchValue_14))), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](functionTypeNode.parameters))]);
1406
- }
2335
+ case 184:
2336
+ return readTypeReference(reader, typeNode);
2337
+ case 185:
2338
+ return readFunctionType(reader, typeNode);
1407
2339
  case 186: {
1408
2340
  const constructorTypeNode = typeNode;
1409
2341
  return new GlueType(/* ConstructorType */ 29, [new GlueConstructSignature(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](constructorTypeNode.parameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constructorTypeNode.type))]);
@@ -1412,7 +2344,7 @@ export function readTypeNode(reader, typeNode) {
1412
2344
  return readTypeQueryNode(reader, typeNode);
1413
2345
  case 188: {
1414
2346
  const typeLiteralNode = typeNode;
1415
- return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(map_1((declaration_7) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_7), toList(typeLiteralNode.members)), typeLiteralId(typeLiteralNode))]);
2347
+ return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(map_1((declaration) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration), toList(typeLiteralNode.members)), typeLiteralId(typeLiteralNode))]);
1416
2348
  }
1417
2349
  case 189: {
1418
2350
  const arrayTypeNode = typeNode;
@@ -1420,13 +2352,13 @@ export function readTypeNode(reader, typeNode) {
1420
2352
  }
1421
2353
  case 190: {
1422
2354
  const tupleTypeNode = typeNode;
1423
- const elements = map_1((value_4) => value_4, toList(tupleTypeNode.elements));
2355
+ const elements = map_1((value) => value, toList(tupleTypeNode.elements));
1424
2356
  if (exists_1((element) => (element.kind === 192), elements)) {
1425
2357
  const elementTypes = List_distinct(map_1((element_1) => {
1426
2358
  if (element_1.kind === 192) {
1427
- const matchValue_21 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](element_1.type);
1428
- if (matchValue_21.tag === 14) {
1429
- return matchValue_21.fields[0];
2359
+ const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](element_1.type);
2360
+ if (matchValue_3.tag === 14) {
2361
+ return matchValue_3.fields[0];
1430
2362
  }
1431
2363
  else {
1432
2364
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -1437,22 +2369,22 @@ export function readTypeNode(reader, typeNode) {
1437
2369
  }
1438
2370
  }, elements), {
1439
2371
  Equals: equals,
1440
- GetHashCode: (x_3) => (safeHash(x_3) | 0),
2372
+ GetHashCode: (x) => (safeHash(x) | 0),
1441
2373
  });
1442
- let matchResult_4, elementType_2;
2374
+ let matchResult, elementType_2;
1443
2375
  if (!isEmpty(elementTypes)) {
1444
2376
  if (isEmpty(tail(elementTypes))) {
1445
- matchResult_4 = 0;
2377
+ matchResult = 0;
1446
2378
  elementType_2 = head(elementTypes);
1447
2379
  }
1448
2380
  else {
1449
- matchResult_4 = 1;
2381
+ matchResult = 1;
1450
2382
  }
1451
2383
  }
1452
2384
  else {
1453
- matchResult_4 = 1;
2385
+ matchResult = 1;
1454
2386
  }
1455
- switch (matchResult_4) {
2387
+ switch (matchResult) {
1456
2388
  case 0:
1457
2389
  return new GlueType(/* Array */ 14, [elementType_2]);
1458
2390
  default:
@@ -1460,7 +2392,7 @@ export function readTypeNode(reader, typeNode) {
1460
2392
  }
1461
2393
  }
1462
2394
  else {
1463
- return new GlueType(/* TupleType */ 18, [map_1((typNode_3) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode_3), elements)]);
2395
+ return new GlueType(/* TupleType */ 18, [map_1((typNode) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode), elements)]);
1464
2396
  }
1465
2397
  }
1466
2398
  case 191: {
@@ -1472,224 +2404,44 @@ export function readTypeNode(reader, typeNode) {
1472
2404
  case 193:
1473
2405
  return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadUnionTypeNodeZ5A082EC2"](typeNode);
1474
2406
  case 194:
1475
- if (exists((inProgress) => (inProgress === checker.getTypeAtLocation(typeNode)), intersectionsInProgress)) {
2407
+ if (exists((inProgress) => (inProgress === checker.getTypeAtLocation(typeNode)), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections)) {
1476
2408
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1477
2409
  }
1478
2410
  else if (exists(isGlobalThisQuery, typeNode.types)) {
1479
- const matchValue_22 = toList(filter_1((arg_3) => !isGlobalThisQuery(arg_3), typeNode.types));
1480
- let matchResult_5, single_1;
1481
- if (!isEmpty(matchValue_22)) {
1482
- if (isEmpty(tail(matchValue_22))) {
1483
- matchResult_5 = 0;
1484
- single_1 = head(matchValue_22);
2411
+ const matchValue_4 = toList(filter((arg) => !isGlobalThisQuery(arg), typeNode.types));
2412
+ let matchResult_1, single;
2413
+ if (!isEmpty(matchValue_4)) {
2414
+ if (isEmpty(tail(matchValue_4))) {
2415
+ matchResult_1 = 0;
2416
+ single = head(matchValue_4);
1485
2417
  }
1486
2418
  else {
1487
- matchResult_5 = 1;
2419
+ matchResult_1 = 1;
1488
2420
  }
1489
2421
  }
1490
2422
  else {
1491
- matchResult_5 = 1;
2423
+ matchResult_1 = 1;
1492
2424
  }
1493
- switch (matchResult_5) {
2425
+ switch (matchResult_1) {
1494
2426
  case 0:
1495
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](single_1);
2427
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](single);
1496
2428
  default:
1497
2429
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1498
2430
  }
1499
2431
  }
1500
2432
  else {
1501
- const intersectionTypeNode = typeNode;
1502
- const unionOrIntersectionType = checker.getTypeAtLocation(intersectionTypeNode);
1503
- void (intersectionsInProgress.push(unionOrIntersectionType));
1504
- const _guard = {
1505
- Dispose() {
1506
- intersectionsInProgress.splice(intersectionsInProgress.length - 1, 1);
1507
- },
1508
- };
1509
- try {
1510
- const properties_1 = choose((property_1) => {
1511
- const matchValue_24 = property_1.declarations;
1512
- if (matchValue_24 == null) {
1513
- return new IntersectionTypePropertyResult(/* WithoutDeclaration */ 1, [property_1]);
1514
- }
1515
- else {
1516
- const declarations_3 = matchValue_24;
1517
- if (declarations_3.length === 1) {
1518
- return new IntersectionTypePropertyResult(/* Single */ 0, [property_1, item_4(0, declarations_3)]);
1519
- }
1520
- else if (forAll((declaration_2) => {
1521
- if (declaration_2.kind === 172) {
1522
- return true;
1523
- }
1524
- else {
1525
- return declaration_2.kind === 173;
1526
- }
1527
- }, declarations_3)) {
1528
- return new IntersectionTypePropertyResult(/* WithoutDeclaration */ 1, [property_1]);
1529
- }
1530
- else {
1531
- return IntersectionTypePropertyResult.ForceAny;
1532
- }
1533
- }
1534
- }, unionOrIntersectionType.isUnion() ? List_distinct(concat_2(map_1((arg_4) => toList(checker.getPropertiesOfType(arg_4)), toList(unionOrIntersectionType.types))), {
1535
- Equals: equals,
1536
- GetHashCode: (x_4) => (structuralHash(x_4) | 0),
1537
- }) : ((matchValue_23 = toList(unionOrIntersectionType.getProperties()), isEmpty(matchValue_23) ? ((intersectionTypeNode.pos >= 0) ? List_distinctBy((property) => property.name, collect_1((constituent) => {
1538
- let type_1;
1539
- return toList((type_1 = checker.getTypeAtLocation(constituent), checker.getPropertiesOfType(type_1)));
1540
- }, toList(intersectionTypeNode.types)), {
1541
- Equals: (x_5, y_5) => (x_5 === y_5),
1542
- GetHashCode: (x_5) => (stringHash(x_5) | 0),
1543
- }) : matchValue_23) : matchValue_23)));
1544
- const hasUnsupportedProperties = exists_1((property_2) => {
1545
- switch (property_2.tag) {
1546
- case 1:
1547
- return false;
1548
- case 0:
1549
- if (property_2.fields[1].kind === 175) {
1550
- return true;
1551
- }
1552
- else {
1553
- return false;
1554
- }
1555
- default:
1556
- return true;
1557
- }
1558
- }, properties_1);
1559
- const callSignatures = unionOrIntersectionType.isUnion() ? empty() : choose((signature) => {
1560
- const flags_1 = 1 | 16384;
1561
- const synthesized = checker.signatureToSignatureDeclaration(signature, 180, typeNode, flags_1);
1562
- if (synthesized == null) {
1563
- return undefined;
1564
- }
1565
- else {
1566
- const declaration_4 = synthesized;
1567
- declaration_4.parent = typeNode;
1568
- const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
1569
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](declaration_4);
1570
- try {
1571
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_4);
1572
- }
1573
- finally {
1574
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
1575
- }
1576
- }
1577
- }, toList(checker.getSignaturesOfType(unionOrIntersectionType, 0)));
1578
- if (hasUnsupportedProperties) {
1579
- const references = map_1((constituent_1) => {
1580
- if (constituent_1.kind === 184) {
1581
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constituent_1);
1582
- }
1583
- else {
1584
- return GlueType.Discard;
1585
- }
1586
- }, toList(intersectionTypeNode.types));
1587
- return (!isEmpty(references) && forAll_1((_arg) => {
1588
- if (_arg.tag === 13) {
1589
- return true;
1590
- }
1591
- else {
1592
- return false;
1593
- }
1594
- }, references)) ? (new GlueType(/* IntersectionOfReferences */ 21, [references])) : (new GlueType(/* Primitive */ 3, [GluePrimitive.Any]));
1595
- }
1596
- else {
1597
- return new GlueType(/* IntersectionType */ 20, [append_1(choose((_arg_1) => {
1598
- switch (_arg_1.tag) {
1599
- case 1:
1600
- return readPropertyWithoutDeclaration(reader, typeNode, _arg_1.fields[0]);
1601
- case 2:
1602
- throw new Exception("Sould not happen here");
1603
- default:
1604
- return readInstantiatedMember(reader, typeNode, _arg_1.fields[0], _arg_1.fields[1]);
1605
- }
1606
- }, properties_1), append_1(callSignatures, collect_1((constituent_2) => {
1607
- if (constituent_2.kind === 188) {
1608
- return map_1((declaration_6) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_6), filter((element_2) => (element_2.kind === 182), toList(constituent_2.members)));
1609
- }
1610
- else {
1611
- return empty();
1612
- }
1613
- }, toList(intersectionTypeNode.types))))]);
1614
- }
1615
- }
1616
- finally {
1617
- disposeSafe(_guard);
1618
- }
1619
- }
1620
- case 195: {
1621
- const conditionalTypeNode = typeNode;
1622
- const typ_4 = checker.getTypeAtLocation(conditionalTypeNode);
1623
- if (isDeferredConditional(typ_4)) {
1624
- const warningsCount = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length | 0;
1625
- const inferred = ofList(map_1((inferTypeNode) => [inferTypeNode.typeParameter.name.getText(), inferredConstraint(reader, inferTypeNode)], inferTypeNodes(conditionalTypeNode.extendsType)), {
1626
- Compare: (x_6, y_6) => (comparePrimitives(x_6, y_6) | 0),
1627
- });
1628
- const conditionalType = new GlueConditionalType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.checkType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.extendsType), GlueSubstitution_substitute(inferred, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.trueType)), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.falseType));
1629
- if (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length > warningsCount) {
1630
- reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().splice(warningsCount, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length - warningsCount);
1631
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1632
- }
1633
- else {
1634
- return new GlueType(/* ConditionalType */ 33, [conditionalType]);
1635
- }
1636
- }
1637
- else {
1638
- const matchValue_31 = readTypeUsingFlags(reader, typ_4);
1639
- let matchResult_6, forward;
1640
- if (matchValue_31.tag === 3) {
1641
- if (matchValue_31.fields[0].tag === 6) {
1642
- matchResult_6 = 0;
1643
- }
1644
- else {
1645
- matchResult_6 = 1;
1646
- forward = matchValue_31;
1647
- }
1648
- }
1649
- else {
1650
- matchResult_6 = 1;
1651
- forward = matchValue_31;
1652
- }
1653
- switch (matchResult_6) {
1654
- case 0:
1655
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.checkType);
1656
- default:
1657
- return forward;
1658
- }
2433
+ return readIntersectionType(reader, typeNode);
1659
2434
  }
1660
- }
2435
+ case 195:
2436
+ return readConditionalType(reader, typeNode);
1661
2437
  case 196:
1662
- return inferredConstraint(reader, typeNode);
2438
+ return new GlueType(/* TypeParameter */ 16, [typeNode.typeParameter.name.getText()]);
1663
2439
  case 197: {
1664
2440
  const parenthesizedTypeNode = typeNode;
1665
2441
  return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](parenthesizedTypeNode.type);
1666
2442
  }
1667
- case 198: {
1668
- const thisTypeNode = typeNode;
1669
- const typ_2 = checker.getTypeAtLocation(thisTypeNode);
1670
- let typParameters_1;
1671
- const matchValue_19 = Operators_IsNull(typ_2.symbol) ? undefined : typ_2.symbol.declarations;
1672
- typParameters_1 = ((matchValue_19 == null) ? empty() : defaultArg((option_14 = tryHead(sortByDescending((typeParameters_1) => (~~typeParameters_1.length | 0), choose_1((declaration_1) => {
1673
- const matchValue_20 = declaration_1.kind;
1674
- switch (matchValue_20) {
1675
- case 264:
1676
- case 265: {
1677
- const classDeclaration = declaration_1;
1678
- return classDeclaration.typeParameters;
1679
- }
1680
- default:
1681
- return undefined;
1682
- }
1683
- }, matchValue_19), {
1684
- Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
1685
- })), (option_14 != null) ? ((arg_2 = option_14, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](arg_2))) : undefined), empty()));
1686
- if (Operators_IsNull(typ_2.symbol)) {
1687
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1688
- }
1689
- else {
1690
- return new GlueType(/* ThisType */ 17, [new GlueThisType(defaultArg(declaredName(typ_2.symbol), typ_2.symbol.name), typParameters_1)]);
1691
- }
1692
- }
2443
+ case 198:
2444
+ return readThisType(reader, typeNode);
1693
2445
  case 199: {
1694
2446
  const typeOperatorNode = typeNode;
1695
2447
  return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeOperatorNodeZ6830FC33"](typeOperatorNode);
@@ -1702,130 +2454,24 @@ export function readTypeNode(reader, typeNode) {
1702
2454
  return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadMappedTypeNode28272C00"](typeNode);
1703
2455
  case 202: {
1704
2456
  const literalTypeNode = typeNode;
1705
- const matchValue_18 = tryReadLiteral(checker, literalTypeNode.literal);
1706
- if (matchValue_18 == null) {
1707
- throw new Exception(Report_readerError_Z19516DCE("type node - literal type", "Could not read literal type", typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1276));
2457
+ const matchValue_2 = tryReadLiteral(checker, literalTypeNode.literal);
2458
+ if (matchValue_2 == null) {
2459
+ throw new Exception(Report_readerError_Z19516DCE("type node - literal type", "Could not read literal type", typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 2239));
1708
2460
  }
1709
2461
  else {
1710
- return new GlueType(/* Literal */ 8, [matchValue_18]);
2462
+ return new GlueType(/* Literal */ 8, [matchValue_2]);
1711
2463
  }
1712
2464
  }
1713
2465
  case 203:
1714
2466
  return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNamedTupleMemberZ6E17C942"](typeNode);
1715
- case 204: {
1716
- const templateLiteralTypeNode = typeNode;
1717
- const readResolvedLiterals = (typ_6) => {
1718
- const matchValue_32 = typ_6.flags;
1719
- if ($007CHasTypeFlags$007C_$007C(1024, matchValue_32) != null) {
1720
- const activePatternResult_7 = Type_StringLiteral_$007CString$007COther$007C(typ_6);
1721
- if (activePatternResult_7.tag === 1) {
1722
- return empty();
1723
- }
1724
- else {
1725
- return singleton_1(new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_7.fields[0]])]));
1726
- }
1727
- }
1728
- else if ($007CHasTypeFlags$007C_$007C(134217728, matchValue_32) != null) {
1729
- return collect_1(readResolvedLiterals, toList(typ_6.types));
1730
- }
1731
- else {
1732
- return empty();
1733
- }
1734
- };
1735
- const matchValue_33 = readResolvedLiterals(checker.getTypeAtLocation(templateLiteralTypeNode));
1736
- if (!isEmpty(matchValue_33)) {
1737
- if (isEmpty(tail(matchValue_33))) {
1738
- return head(matchValue_33);
1739
- }
1740
- else {
1741
- return new GlueType(/* Union */ 7, [new GlueTypeUnion(matchValue_33)]);
1742
- }
1743
- }
1744
- else {
1745
- return GlueType.TemplateLiteral;
1746
- }
1747
- }
1748
- case 206: {
1749
- const importTypeNode = typeNode;
1750
- let unresolvedModule;
1751
- if (importTypeNode.pos < 0) {
1752
- unresolvedModule = undefined;
1753
- }
1754
- else if (importTypeNode.argument.kind === 202) {
1755
- const literal = importTypeNode.argument.literal;
1756
- unresolvedModule = ((symbolAtLocation(checker, literal) != null) ? undefined : literal.text);
1757
- }
1758
- else {
1759
- unresolvedModule = undefined;
1760
- }
1761
- const matchValue_16 = importTypeNode.qualifier;
1762
- if (unresolvedModule == null) {
1763
- if (matchValue_16 == null) {
1764
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1765
- }
1766
- else if (importTypeNode.isTypeOf) {
1767
- const qualifier_1 = matchValue_16;
1768
- const typNode_1 = (ts.factory).createTypeQueryNode(qualifier_1);
1769
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode_1);
1770
- }
1771
- else {
1772
- const qualifier_2 = matchValue_16;
1773
- const typNode_2 = (ts.factory).createTypeReferenceNode(qualifier_2, unwrap(importTypeNode.typeArguments));
1774
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode_2);
1775
- }
1776
- }
1777
- else {
1778
- const moduleName = unresolvedModule;
1779
- const warning = concat("\'", moduleName, "\' is not installed, the types imported from it are generated as \'obj\'");
1780
- if (!contains_2(warning, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), {
1781
- Equals: (x_1, y_1) => (x_1 === y_1),
1782
- GetHashCode: (x_1) => (stringHash(x_1) | 0),
1783
- })) {
1784
- void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning));
1785
- }
1786
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
1787
- }
1788
- }
1789
- case 234: {
1790
- const expression = typeNode;
1791
- const typ_3 = checker.getTypeFromTypeNode(expression);
1792
- const symbolOpt_1 = orElse(orElse(typ_3.aliasSymbol, Operators_IsNull(typ_3.symbol) ? undefined : typ_3.symbol), checker.getSymbolAtLocation(expression.expression));
1793
- const matchValue_26 = isFromEs5Lib(symbolOpt_1);
1794
- const matchValue_27 = getFullNameOrEmpty(checker, expression.expression);
1795
- let matchResult_7;
1796
- if (matchValue_26) {
1797
- if (matchValue_27 === "Omit") {
1798
- matchResult_7 = 0;
1799
- }
1800
- else {
1801
- matchResult_7 = 1;
1802
- }
1803
- }
1804
- else {
1805
- matchResult_7 = 1;
1806
- }
1807
- switch (matchResult_7) {
1808
- case 0:
1809
- return UtilityType_readOmit(reader, expression);
1810
- default: {
1811
- const isQualified_1 = expression.expression.kind === 212;
1812
- const name_1 = (symbolOpt_1 != null) ? (((symbol_5 = symbolOpt_1, symbol_5.name === "default")) ? ((symbol_7 = symbolOpt_1, defaultArg(declaredName(symbol_7), symbol_7.name))) : ((!isFromEs5Lib(symbolOpt_1)) ? ((symbol_8 = symbolOpt_1, symbol_8.name)) : (isQualified_1 ? expression.expression.name.text : expression.expression.getText()))) : (isQualified_1 ? expression.expression.name.text : expression.expression.getText());
1813
- const isExternal_1 = isExternalToPackages(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbolOpt_1);
1814
- if (((symbolOpt_1 == null) ? false : ((symbol_9 = symbolOpt_1, (symbol_9.name === "__type") ? true : (symbol_9.name === "__object")))) ? true : ((isExternal_1 && !FSharpSet__Contains(knownExternalTypeNames, name_1)) && !(isFromEs5Lib(symbolOpt_1) && (name_1 === "Partial")))) {
1815
- return GlueType.Discard;
1816
- }
1817
- else {
1818
- return new GlueType(/* TypeReference */ 13, [new GlueTypeReference((name_1.indexOf(".") >= 0) ? name_1 : sanitizeTypeName(name_1), (matchValue_29 = ((option_21 = symbolOpt_1, (option_21 != null) ? resolveAlias(checker, option_21) : undefined)), (matchValue_29 == null) ? getFullNameOrEmpty(checker, expression.expression) : ((symbol_11 = matchValue_29, checker.getFullyQualifiedName(symbol_11)))), isLibraryName(reader, name_1) ? empty() : modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), isQualified_1, symbolOpt_1), (matchValue_30 = readTypeArguments(reader, expression), isEmpty(matchValue_30) ? map_1((argument) => {
1819
- const flags_2 = 1 | 16384;
1820
- const typNode_4 = checker.typeToTypeNode(argument, undefined, flags_2);
1821
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode_4);
1822
- }, resolvedBaseTypeArguments(checker, expression)) : matchValue_30), (isFromEs5Lib(symbolOpt_1) ? true : isExternal_1) ? true : isLibraryName(reader, name_1))]);
1823
- }
1824
- }
1825
- }
1826
- }
2467
+ case 204:
2468
+ return readTemplateLiteralType(reader, typeNode);
2469
+ case 206:
2470
+ return readImportType(reader, typeNode);
2471
+ case 234:
2472
+ return readExpressionWithTypeArguments(reader, typeNode);
1827
2473
  default: {
1828
- 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", 1766);
2474
+ 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", 2365);
1829
2475
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1830
2476
  void (objectArg.push(item));
1831
2477
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);