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

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 (155) hide show
  1. package/README.md +16 -0
  2. package/dist/Glutinum.Converter/Abbreviations.js +16 -39
  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 +117 -66
  6. package/dist/Glutinum.Converter/Generate.js +52 -26
  7. package/dist/Glutinum.Converter/GlueAST.js +85 -46
  8. package/dist/Glutinum.Converter/Hosting.js +148 -174
  9. package/dist/Glutinum.Converter/Merge.js +463 -355
  10. package/dist/Glutinum.Converter/Packages.js +387 -97
  11. package/dist/Glutinum.Converter/Printer.js +439 -400
  12. package/dist/Glutinum.Converter/Read.js +362 -100
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
  14. package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
  15. package/dist/Glutinum.Converter/Reader/Declaration.js +13 -19
  16. package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
  17. package/dist/Glutinum.Converter/Reader/Documentation.js +28 -40
  18. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +2 -2
  19. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +104 -37
  20. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +24 -39
  21. package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
  22. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +30 -17
  23. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +16 -22
  24. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +49 -6
  25. package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
  26. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +4 -4
  27. package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
  28. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +54 -6
  29. package/dist/Glutinum.Converter/Reader/Node.js +11 -14
  30. package/dist/Glutinum.Converter/Reader/Parameters.js +39 -30
  31. package/dist/Glutinum.Converter/Reader/Report.js +4 -4
  32. package/dist/Glutinum.Converter/Reader/TypeNode.js +390 -1584
  33. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +80 -53
  34. package/dist/Glutinum.Converter/Reader/TypeParameters.js +2 -2
  35. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +24 -47
  36. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +24 -6
  37. package/dist/Glutinum.Converter/Reader/Types.js +297 -17
  38. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +16 -30
  39. package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
  40. package/dist/Glutinum.Converter/Reader/Utils.js +497 -111
  41. package/dist/Glutinum.Converter/Reader/VariableStatement.js +7 -8
  42. package/dist/Glutinum.Converter/Transform.js +2915 -8180
  43. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  44. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  45. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  46. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1087 -0
  47. package/dist/Glutinum.Converter/Transformer/Context.js +678 -0
  48. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  49. package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
  50. package/dist/Glutinum.Converter/Transformer/Heritage.js +493 -0
  51. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  52. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
  53. package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
  54. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  55. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +338 -0
  56. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  57. package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
  58. package/dist/Glutinum.Converter/Utils/Keywords.js +3 -3
  59. package/dist/Glutinum.Converter/Utils/List.js +2 -2
  60. package/dist/Glutinum.Converter/Utils/Naming.js +6 -6
  61. package/dist/Glutinum.Converter/Utils/String.js +16 -5
  62. package/dist/Program.js +104 -241
  63. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +2 -2
  64. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +4 -4
  65. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +2 -2
  66. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +5 -5
  67. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +4 -4
  68. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +3 -3
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +1 -1
  70. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +3 -3
  71. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +1 -1
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +1 -1
  73. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +4 -4
  74. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +1 -1
  75. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +3 -3
  76. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +1 -1
  77. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +1 -1
  78. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +1 -1
  79. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +2 -2
  80. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +2 -2
  81. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +1 -1
  82. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +7 -7
  83. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +1 -1
  84. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Async.js +21 -7
  85. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/AsyncBuilder.js +51 -6
  86. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/CHANGELOG.md +23 -1
  87. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/CollectionUtil.js +10 -16
  88. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MailboxProcessor.js +19 -3
  89. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MutableMap.js +5 -1
  90. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MutableSet.js +5 -1
  91. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Util.js +15 -3
  92. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/package.json +1 -1
  93. package/package.json +3 -2
  94. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Array.js +0 -0
  95. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/BigInt.js +0 -0
  96. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/BitConverter.js +0 -0
  97. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Boolean.js +0 -0
  98. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Char.js +0 -0
  99. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Choice.js +0 -0
  100. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/ConditionalWeakTable.js +0 -0
  101. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Date.js +0 -0
  102. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOffset.js +0 -0
  103. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOnly.js +0 -0
  104. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOnlyTemporal.js +0 -0
  105. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeFormat.js +0 -0
  106. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeOffsetTemporal.js +0 -0
  107. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeTemporal.js +0 -0
  108. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Decimal.js +0 -0
  109. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Directory.js +0 -0
  110. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Double.js +0 -0
  111. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Encoding.js +0 -0
  112. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Environment.js +0 -0
  113. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Event.js +0 -0
  114. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Collections.js +0 -0
  115. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Core.CompilerServices.js +0 -0
  116. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Core.js +0 -0
  117. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/File.js +0 -0
  118. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Global.js +0 -0
  119. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Guid.js +0 -0
  120. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Int32.js +0 -0
  121. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/List.js +0 -0
  122. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Long.js +0 -0
  123. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Map.js +0 -0
  124. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MapUtil.js +0 -0
  125. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Native.js +0 -0
  126. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Numeric.js +0 -0
  127. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Observable.js +0 -0
  128. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Option.js +0 -0
  129. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Path.js +0 -0
  130. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/README.md +0 -0
  131. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Random.js +0 -0
  132. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Range.js +0 -0
  133. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Reflection.js +0 -0
  134. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/RegExp.js +0 -0
  135. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Result.js +0 -0
  136. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Seq.js +0 -0
  137. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Seq2.js +0 -0
  138. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Set.js +0 -0
  139. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/String.js +0 -0
  140. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.Collections.Generic.js +0 -0
  141. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.Text.js +0 -0
  142. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.js +0 -0
  143. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Task.js +0 -0
  144. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TaskBuilder.js +0 -0
  145. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeOnly.js +0 -0
  146. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeOnlyTemporal.js +0 -0
  147. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeSpan.js +0 -0
  148. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeSpanTemporal.js +0 -0
  149. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Timer.js +0 -0
  150. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Types.js +0 -0
  151. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Unicode.13.0.0.js +0 -0
  152. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Uri.js +0 -0
  153. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/big.d.ts +0 -0
  154. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/lib/big.js +0 -0
  155. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/quotation.js +0 -0
@@ -1,22 +1,43 @@
1
1
 
2
- import { Exception, safeHash, equals, compareArrays, arrayHash, equalArrays, defaultOf, comparePrimitives, int32ToString, disposeSafe, getEnumerator } from "../fable_modules/fable-library-js.5.17.2/Util.js";
3
- import { ofSeq as ofSeq_1, maxBy, skip, take, forAll2, ofArray, indexed, sortBy, exists, forAll, filter, empty as empty_1, collect, head, tail, zip, length, map, choose, singleton, append, isEmpty as isEmpty_1 } from "../fable_modules/fable-library-js.5.17.2/List.js";
4
- import { concat, join } from "../fable_modules/fable-library-js.5.17.2/String.js";
5
- import { FSharpClass, FSharpModule, FSharpInterface, FSharpStaticMemberInfo, FSharpMember, FSharpMemberInfo, FSharpUnion, FSharpUnionCase, FSharpFunctionType, FSharpParameter, FSharpJSApi, FSharpTypeReference, FSharpType } from "./FsharpAST.js";
6
- import { ofList, tryFind } from "../fable_modules/fable-library-js.5.17.2/Map.js";
7
- import { addToDict, addToSet, tryGetValue, getItemFromDict } from "../fable_modules/fable-library-js.5.17.2/MapUtil.js";
8
- import { value } from "../fable_modules/fable-library-js.5.17.2/Option.js";
9
- import { FSharpSet__get_IsEmpty, ofSeq, empty, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.17.2/Set.js";
10
- import { FSharpRef } from "../fable_modules/fable-library-js.5.17.2/Types.js";
11
- import { List_distinctBy, List_distinct, List_groupBy } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
12
- import { FSharpChoice$3 } from "../fable_modules/fable-library-js.5.17.2/Choice.js";
13
- import { contains, setItem, item } from "../fable_modules/fable-library-js.5.17.2/Array.js";
2
+ import { FSharpRef, Record } from "../fable_modules/fable-library-js.5.21.0/Types.js";
3
+ import { record_type, tuple_type, list_type, class_type, string_type } from "../fable_modules/fable-library-js.5.21.0/Reflection.js";
4
+ import { FSharpClass, FSharpModule, FSharpInterface, FSharpStaticMemberInfo, FSharpMember, FSharpMemberInfo, FSharpTypeModule_children, FSharpFunctionType, FSharpParameter, FSharpTypeModule_mapChildren, FSharpTypeReference, FSharpType, FSharpType_$reflection } from "./FsharpAST.js";
5
+ import { ofList, FSharpMap__TryFind, tryFind, ofSeq, empty } from "../fable_modules/fable-library-js.5.21.0/Map.js";
6
+ import { Exception, safeHash, equals, compare, compareArrays, arrayHash, equalArrays, defaultOf, int32ToString, disposeSafe, getEnumerator, comparePrimitives } from "../fable_modules/fable-library-js.5.21.0/Util.js";
7
+ import { mapIndexed, tryFindIndex, ofSeq as ofSeq_2, maxBy, skip, take, forAll2, ofArray, indexed, sortBy, exists, forAll, filter, collect, head, tail, zip, empty as empty_1, length, map, choose, singleton, append, isEmpty as isEmpty_1 } from "../fable_modules/fable-library-js.5.21.0/List.js";
8
+ import { concat, join } from "../fable_modules/fable-library-js.5.21.0/String.js";
9
+ import { map as map_1 } from "../fable_modules/fable-library-js.5.21.0/Seq.js";
10
+ import { isSubset, singleton as singleton_1, FSharpSet__get_IsEmpty, ofSeq as ofSeq_1, empty as empty_2, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.21.0/Set.js";
11
+ import { addToDict, getItemFromDict, addToSet, tryGetValue } from "../fable_modules/fable-library-js.5.21.0/MapUtil.js";
12
+ import { List_distinctBy, List_distinct, List_groupBy } from "../fable_modules/fable-library-js.5.21.0/Seq2.js";
13
+ import { FSharpChoice$3 } from "../fable_modules/fable-library-js.5.21.0/Choice.js";
14
+ import { contains, setItem, item } from "../fable_modules/fable-library-js.5.21.0/Array.js";
15
+ import { HashSet } from "../fable_modules/fable-library-js.5.21.0/MutableSet.js";
14
16
 
15
- const aliasTargets = new Map([]);
17
+ /**
18
+ * The type aliases of the output, two references are the same type when they alias the same one
19
+ */
20
+ export class Aliases extends Record {
21
+ constructor(Targets, Generic) {
22
+ super();
23
+ this.Targets = Targets;
24
+ this.Generic = Generic;
25
+ }
26
+ }
27
+
28
+ export function Aliases_$reflection() {
29
+ return record_type("Glutinum.Converter.Merge.Aliases", [], Aliases, () => [["Targets", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, FSharpType_$reflection()])], ["Generic", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, tuple_type(list_type(string_type), FSharpType_$reflection())])]]);
30
+ }
16
31
 
17
- const genericAliasTargets = new Map([]);
32
+ export function Aliases_get_Empty() {
33
+ return new Aliases(empty({
34
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
35
+ }), empty({
36
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
37
+ }));
38
+ }
18
39
 
19
- function collectAliases(path, types) {
40
+ function collectAliases(aliasTargets, genericAliasTargets, path, types) {
20
41
  const enumerator = getEnumerator(types);
21
42
  try {
22
43
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
@@ -62,7 +83,7 @@ function collectAliases(path, types) {
62
83
  break;
63
84
  }
64
85
  case 4: {
65
- collectAliases(append(path, singleton(typ.fields[0].Name)), typ.fields[0].Types);
86
+ collectAliases(aliasTargets, genericAliasTargets, append(path, singleton(typ.fields[0].Name)), typ.fields[0].Types);
66
87
  break;
67
88
  }
68
89
  default:
@@ -75,57 +96,47 @@ function collectAliases(path, types) {
75
96
  }
76
97
  }
77
98
 
99
+ /**
100
+ * The aliases the types declare
101
+ */
102
+ export function aliasesOf(types) {
103
+ const aliasTargets = new Map([]);
104
+ const genericAliasTargets = new Map([]);
105
+ collectAliases(aliasTargets, genericAliasTargets, empty_1(), types);
106
+ return new Aliases(ofSeq(map_1((_arg) => {
107
+ const activePatternResult = _arg;
108
+ return [activePatternResult[0], activePatternResult[1]];
109
+ }, aliasTargets), {
110
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
111
+ }), ofSeq(map_1((_arg_1) => {
112
+ const activePatternResult_1 = _arg_1;
113
+ return [activePatternResult_1[0], activePatternResult_1[1]];
114
+ }, genericAliasTargets), {
115
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
116
+ }));
117
+ }
118
+
78
119
  function substitute(substitutions, typ) {
79
- const substitute_1 = (typ_1) => substitute(substitutions, typ_1);
80
- switch (typ.tag) {
81
- case 13: {
82
- const matchValue = tryFind(typ.fields[0], substitutions);
83
- if (matchValue == null) {
84
- return typ;
85
- }
86
- else {
87
- return matchValue;
88
- }
89
- }
90
- case 11: {
91
- const typeReference = typ.fields[0];
92
- return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(typeReference.Name, typeReference.FullName, typeReference.ModulePath, map(substitute_1, typeReference.TypeArguments), typeReference.Type)]);
93
- }
94
- case 3:
95
- return new FSharpType(/* Option */ 3, [substitute_1(typ.fields[0])]);
96
- case 14:
97
- return new FSharpType(/* ResizeArray */ 14, [substitute_1(typ.fields[0])]);
98
- case 19:
99
- return new FSharpType(/* JSApi */ 19, [new FSharpJSApi(substitute_1(typ.fields[0].fields[0]))]);
100
- case 12:
101
- return new FSharpType(/* Tuple */ 12, [map(substitute_1, typ.fields[0])]);
102
- case 16: {
103
- const functionType = typ.fields[0];
104
- return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => (new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, substitute_1(parameter.Type), parameter.OriginalGlueMember)), functionType.Parameters), substitute_1(functionType.ReturnType))]);
105
- }
106
- case 1: {
107
- const unionInfo = typ.fields[0];
108
- return new FSharpType(/* Union */ 1, [new FSharpUnion(unionInfo.Attributes, unionInfo.Name, map((_arg) => {
109
- switch (_arg.tag) {
110
- case 1:
111
- return new FSharpUnionCase(/* Typed */ 1, [substitute_1(_arg.fields[0])]);
112
- case 2:
113
- return new FSharpUnionCase(/* Field */ 2, [_arg.fields[0], substitute_1(_arg.fields[1])]);
114
- default:
115
- return _arg;
116
- }
117
- }, unionInfo.Cases), unionInfo.IsOptional, unionInfo.TypeParameters, unionInfo.Constants)]);
118
- }
119
- default:
120
+ if (typ.tag === 13) {
121
+ const matchValue = tryFind(typ.fields[0], substitutions);
122
+ if (matchValue == null) {
120
123
  return typ;
124
+ }
125
+ else {
126
+ return matchValue;
127
+ }
128
+ }
129
+ else {
130
+ return FSharpTypeModule_mapChildren((typ_3) => substitute(substitutions, typ_3), typ);
121
131
  }
122
132
  }
123
133
 
124
- function tryGenericAliasTarget(typeReference) {
134
+ function tryGenericAliasTarget(aliases, typeReference) {
125
135
  let tupledArg;
126
136
  const arity = "`" + int32ToString(length(typeReference.TypeArguments));
127
- const key = join(".", append(typeReference.ModulePath, singleton(typeReference.Name))) + arity;
128
- const option_1 = genericAliasTargets.has(key) ? getItemFromDict(genericAliasTargets, key) : ((isEmpty_1(typeReference.ModulePath) && genericAliasTargets.has(typeReference.Name + arity)) ? getItemFromDict(genericAliasTargets, typeReference.Name + arity) : undefined);
137
+ let option_1;
138
+ const matchValue = FSharpMap__TryFind(aliases.Generic, join(".", append(typeReference.ModulePath, singleton(typeReference.Name))) + arity);
139
+ option_1 = ((matchValue == null) ? (isEmpty_1(typeReference.ModulePath) ? FSharpMap__TryFind(aliases.Generic, typeReference.Name + arity) : undefined) : matchValue);
129
140
  if (option_1 != null) {
130
141
  return (tupledArg = option_1, substitute(ofList(zip(tupledArg[0], typeReference.TypeArguments), {
131
142
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
@@ -136,298 +147,183 @@ function tryGenericAliasTarget(typeReference) {
136
147
  }
137
148
  }
138
149
 
139
- function signatureTypeAt(depth, typ) {
140
- let typeReference, typeReference_1;
141
- let signatureType_1;
142
- const depth_1 = (depth + 1) | 0;
143
- signatureType_1 = ((typ_1) => signatureTypeAt(depth_1, typ_1));
144
- let matchResult, typeReference_2, typeReference_3, typeArgument, typeReference_4, typ_2, typ_3, typ_4, unionInfo, types, functionType, typ_7;
145
- switch (typ.tag) {
146
- case 11: {
147
- if ((typeReference = typ.fields[0], ((depth < 8) && isEmpty_1(typeReference.TypeArguments)) && (aliasTargets.has(join(".", append(typeReference.ModulePath, singleton(typeReference.Name)))) ? true : (isEmpty_1(typeReference.ModulePath) && aliasTargets.has(typeReference.Name))))) {
148
- matchResult = 0;
149
- typeReference_2 = typ.fields[0];
150
- }
151
- else if ((typeReference_1 = typ.fields[0], ((depth < 8) && !isEmpty_1(typeReference_1.TypeArguments)) && (tryGenericAliasTarget(typeReference_1) != null))) {
152
- matchResult = 1;
153
- typeReference_3 = typ.fields[0];
154
- }
155
- else if (typ.fields[0].Name === "ResizeArray") {
156
- if (!isEmpty_1(typ.fields[0].TypeArguments)) {
157
- if (isEmpty_1(tail(typ.fields[0].TypeArguments))) {
158
- matchResult = 2;
159
- typeArgument = head(typ.fields[0].TypeArguments);
160
- }
161
- else {
162
- matchResult = 3;
163
- typeReference_4 = typ.fields[0];
164
- }
165
- }
166
- else {
167
- matchResult = 3;
168
- typeReference_4 = typ.fields[0];
169
- }
150
+ function tryAliasTarget(aliases, typeReference) {
151
+ if (!isEmpty_1(typeReference.TypeArguments)) {
152
+ return tryGenericAliasTarget(aliases, typeReference);
153
+ }
154
+ else {
155
+ const matchValue = FSharpMap__TryFind(aliases.Targets, join(".", append(typeReference.ModulePath, singleton(typeReference.Name))));
156
+ if (matchValue == null) {
157
+ if (isEmpty_1(typeReference.ModulePath)) {
158
+ return FSharpMap__TryFind(aliases.Targets, typeReference.Name);
170
159
  }
171
160
  else {
172
- matchResult = 3;
173
- typeReference_4 = typ.fields[0];
161
+ return undefined;
174
162
  }
175
- break;
176
- }
177
- case 3: {
178
- matchResult = 4;
179
- typ_2 = typ.fields[0];
180
- break;
181
- }
182
- case 14: {
183
- matchResult = 5;
184
- typ_3 = typ.fields[0];
185
- break;
186
- }
187
- case 19: {
188
- matchResult = 6;
189
- typ_4 = typ.fields[0].fields[0];
190
- break;
191
- }
192
- case 1: {
193
- matchResult = 7;
194
- unionInfo = typ.fields[0];
195
- break;
196
- }
197
- case 12: {
198
- matchResult = 8;
199
- types = typ.fields[0];
200
- break;
201
163
  }
202
- case 16: {
203
- matchResult = 9;
204
- functionType = typ.fields[0];
205
- break;
164
+ else {
165
+ return matchValue;
206
166
  }
207
- case 8: {
208
- if (typ.fields[0].tag === 6) {
209
- matchResult = 10;
210
- }
211
- else {
212
- matchResult = 11;
213
- typ_7 = typ;
214
- }
215
- break;
167
+ }
168
+ }
169
+
170
+ function $007CAliasTarget$007C_$007C(aliases, typ) {
171
+ if (typ.tag === 11) {
172
+ return tryAliasTarget(aliases, typ.fields[0]);
173
+ }
174
+ else {
175
+ return undefined;
176
+ }
177
+ }
178
+
179
+ function signatureTypeAt(aliases, depth, typ) {
180
+ let signatureType_1;
181
+ const depth_1 = (depth + 1) | 0;
182
+ signatureType_1 = ((typ_1) => signatureTypeAt(aliases, depth_1, typ_1));
183
+ let matchResult, target_1;
184
+ const activePatternResult = $007CAliasTarget$007C_$007C(aliases, typ);
185
+ if (activePatternResult != null) {
186
+ if (depth < 8) {
187
+ matchResult = 0;
188
+ target_1 = activePatternResult;
216
189
  }
217
- default: {
218
- matchResult = 11;
219
- typ_7 = typ;
190
+ else {
191
+ matchResult = 1;
220
192
  }
221
193
  }
194
+ else {
195
+ matchResult = 1;
196
+ }
222
197
  switch (matchResult) {
223
- case 0: {
224
- const fullPath = join(".", append(typeReference_2.ModulePath, singleton(typeReference_2.Name)));
225
- return signatureType_1(aliasTargets.has(fullPath) ? getItemFromDict(aliasTargets, fullPath) : getItemFromDict(aliasTargets, typeReference_2.Name));
226
- }
227
- case 1:
228
- return signatureType_1(value(tryGenericAliasTarget(typeReference_3)));
229
- case 2:
230
- return new FSharpType(/* ResizeArray */ 14, [signatureType_1(typeArgument)]);
231
- case 3:
232
- return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference((typeReference_4.Name === "JS.Uint8ClampedArray") ? "JS.Uint8Array" : typeReference_4.Name, "", typeReference_4.ModulePath, map(signatureType_1, typeReference_4.TypeArguments), FSharpType.Discard)]);
233
- case 4:
234
- return new FSharpType(/* Option */ 3, [signatureType_1(typ_2)]);
235
- case 5:
236
- return new FSharpType(/* ResizeArray */ 14, [signatureType_1(typ_3)]);
237
- case 6:
238
- return new FSharpType(/* JSApi */ 19, [new FSharpJSApi(signatureType_1(typ_4))]);
239
- case 7:
240
- return new FSharpType(/* Union */ 1, [new FSharpUnion(unionInfo.Attributes, unionInfo.Name, map((_arg) => {
241
- switch (_arg.tag) {
242
- case 1:
243
- return new FSharpUnionCase(/* Typed */ 1, [signatureType_1(_arg.fields[0])]);
244
- case 2:
245
- return new FSharpUnionCase(/* Field */ 2, [_arg.fields[0], signatureType_1(_arg.fields[1])]);
246
- default:
247
- return _arg;
198
+ case 0:
199
+ return signatureType_1(target_1);
200
+ default: {
201
+ let matchResult_1, typeArgument, typeReference, functionType, typ_2;
202
+ switch (typ.tag) {
203
+ case 11: {
204
+ if (typ.fields[0].Name === "ResizeArray") {
205
+ if (!isEmpty_1(typ.fields[0].TypeArguments)) {
206
+ if (isEmpty_1(tail(typ.fields[0].TypeArguments))) {
207
+ matchResult_1 = 0;
208
+ typeArgument = head(typ.fields[0].TypeArguments);
209
+ }
210
+ else {
211
+ matchResult_1 = 1;
212
+ typeReference = typ.fields[0];
213
+ }
214
+ }
215
+ else {
216
+ matchResult_1 = 1;
217
+ typeReference = typ.fields[0];
218
+ }
219
+ }
220
+ else {
221
+ matchResult_1 = 1;
222
+ typeReference = typ.fields[0];
223
+ }
224
+ break;
248
225
  }
249
- }, unionInfo.Cases), unionInfo.IsOptional, unionInfo.TypeParameters, unionInfo.Constants)]);
250
- case 8:
251
- return new FSharpType(/* Tuple */ 12, [map(signatureType_1, types)]);
252
- case 9:
253
- return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => (new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, signatureType_1(parameter.Type), undefined)), functionType.Parameters), signatureType_1(functionType.ReturnType))]);
254
- case 10:
255
- return FSharpType.Object$;
256
- default:
257
- return typ_7;
226
+ case 16: {
227
+ matchResult_1 = 2;
228
+ functionType = typ.fields[0];
229
+ break;
230
+ }
231
+ case 8: {
232
+ if (typ.fields[0].tag === 6) {
233
+ matchResult_1 = 3;
234
+ }
235
+ else {
236
+ matchResult_1 = 4;
237
+ typ_2 = typ;
238
+ }
239
+ break;
240
+ }
241
+ default: {
242
+ matchResult_1 = 4;
243
+ typ_2 = typ;
244
+ }
245
+ }
246
+ switch (matchResult_1) {
247
+ case 0:
248
+ return new FSharpType(/* ResizeArray */ 14, [signatureType_1(typeArgument)]);
249
+ case 1:
250
+ return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference((typeReference.Name === "JS.Uint8ClampedArray") ? "JS.Uint8Array" : typeReference.Name, "", typeReference.ModulePath, map(signatureType_1, typeReference.TypeArguments), FSharpType.Discard)]);
251
+ case 2:
252
+ return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => (new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, signatureType_1(parameter.Type), undefined)), functionType.Parameters), signatureType_1(functionType.ReturnType))]);
253
+ case 3:
254
+ return FSharpType.Object$;
255
+ default:
256
+ return FSharpTypeModule_mapChildren(signatureType_1, typ_2);
257
+ }
258
+ }
258
259
  }
259
260
  }
260
261
 
261
- export function signatureType(typ) {
262
- return signatureTypeAt(0, typ);
262
+ export function signatureType(aliases, typ) {
263
+ return signatureTypeAt(aliases, 0, typ);
263
264
  }
264
265
 
265
266
  function canonicalTypeParameters(erased, names, typ) {
266
- const canonical = (typ_1) => canonicalTypeParameters(erased, names, typ_1);
267
- switch (typ.tag) {
268
- case 13:
269
- if (FSharpSet__Contains(erased, typ.fields[0])) {
270
- return FSharpType.Object$;
267
+ if (typ.tag === 13) {
268
+ if (FSharpSet__Contains(erased, typ.fields[0])) {
269
+ return FSharpType.Object$;
270
+ }
271
+ else {
272
+ let matchValue;
273
+ let outArg = defaultOf();
274
+ matchValue = [tryGetValue(names, typ.fields[0], new FSharpRef(() => outArg, (v) => {
275
+ outArg = v;
276
+ })), outArg];
277
+ if (matchValue[0]) {
278
+ return new FSharpType(/* TypeParameter */ 13, [matchValue[1]]);
271
279
  }
272
280
  else {
273
- let matchValue;
274
- let outArg = defaultOf();
275
- matchValue = [tryGetValue(names, typ.fields[0], new FSharpRef(() => outArg, (v) => {
276
- outArg = v;
277
- })), outArg];
278
- if (matchValue[0]) {
279
- return new FSharpType(/* TypeParameter */ 13, [matchValue[1]]);
280
- }
281
- else {
282
- const canonicalName_1 = `T${names.size}`;
283
- names.set(typ.fields[0], canonicalName_1);
284
- return new FSharpType(/* TypeParameter */ 13, [canonicalName_1]);
285
- }
281
+ const canonicalName_1 = `T${names.size}`;
282
+ names.set(typ.fields[0], canonicalName_1);
283
+ return new FSharpType(/* TypeParameter */ 13, [canonicalName_1]);
286
284
  }
287
- case 11:
288
- return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(typ.fields[0].Name, typ.fields[0].FullName, typ.fields[0].ModulePath, map(canonical, typ.fields[0].TypeArguments), typ.fields[0].Type)]);
289
- case 3:
290
- return new FSharpType(/* Option */ 3, [canonical(typ.fields[0])]);
291
- case 14:
292
- return new FSharpType(/* ResizeArray */ 14, [canonical(typ.fields[0])]);
293
- case 19:
294
- return new FSharpType(/* JSApi */ 19, [new FSharpJSApi(canonical(typ.fields[0].fields[0]))]);
295
- case 1:
296
- return new FSharpType(/* Union */ 1, [new FSharpUnion(typ.fields[0].Attributes, typ.fields[0].Name, map((_arg) => {
297
- switch (_arg.tag) {
298
- case 1:
299
- return new FSharpUnionCase(/* Typed */ 1, [canonical(_arg.fields[0])]);
300
- case 2:
301
- return new FSharpUnionCase(/* Field */ 2, [_arg.fields[0], canonical(_arg.fields[1])]);
302
- default:
303
- return _arg;
304
- }
305
- }, typ.fields[0].Cases), typ.fields[0].IsOptional, typ.fields[0].TypeParameters, typ.fields[0].Constants)]);
306
- case 12:
307
- return new FSharpType(/* Tuple */ 12, [map(canonical, typ.fields[0])]);
308
- case 16:
309
- return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => (new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, canonical(parameter.Type), parameter.OriginalGlueMember)), typ.fields[0].Parameters), canonical(typ.fields[0].ReturnType))]);
310
- default:
311
- return typ;
285
+ }
286
+ }
287
+ else {
288
+ return FSharpTypeModule_mapChildren((typ_1) => canonicalTypeParameters(erased, names, typ_1), typ);
312
289
  }
313
290
  }
314
291
 
315
- export function parametersSignatureWith(erased, parameters) {
292
+ export function parametersSignatureWith(aliases, erased, parameters) {
316
293
  const names = new Map([]);
317
- return map((parameter) => [canonicalTypeParameters(erased, names, signatureType(parameter.Type)), parameter.IsOptional], parameters);
294
+ return map((parameter) => [canonicalTypeParameters(erased, names, signatureType(aliases, parameter.Type)), parameter.IsOptional], parameters);
318
295
  }
319
296
 
320
- export function parametersSignature(parameters) {
321
- return parametersSignatureWith(empty({
297
+ export function parametersSignature(aliases, parameters) {
298
+ return parametersSignatureWith(aliases, empty_2({
322
299
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
323
300
  }), parameters);
324
301
  }
325
302
 
326
303
  function distinguishableTypeParameters(typeParameters, parameters) {
327
- const namesOf = (typ_mut) => {
328
- namesOf:
329
- while (true) {
330
- const typ = typ_mut;
331
- let matchResult, typ_1;
332
- switch (typ.tag) {
333
- case 13: {
334
- matchResult = 0;
335
- break;
336
- }
337
- case 11: {
338
- matchResult = 1;
339
- break;
340
- }
341
- case 3: {
342
- matchResult = 2;
343
- typ_1 = typ.fields[0];
344
- break;
345
- }
346
- case 14: {
347
- matchResult = 2;
348
- typ_1 = typ.fields[0];
349
- break;
350
- }
351
- case 19: {
352
- matchResult = 2;
353
- typ_1 = typ.fields[0].fields[0];
354
- break;
355
- }
356
- case 1: {
357
- matchResult = 3;
358
- break;
359
- }
360
- case 12: {
361
- matchResult = 4;
362
- break;
363
- }
364
- case 16: {
365
- matchResult = 5;
366
- break;
367
- }
368
- default:
369
- matchResult = 6;
370
- }
371
- switch (matchResult) {
372
- case 0:
373
- return singleton(typ.fields[0]);
374
- case 1:
375
- return collect(namesOf, typ.fields[0].TypeArguments);
376
- case 2: {
377
- typ_mut = typ_1;
378
- continue namesOf;
379
- }
380
- case 3:
381
- return collect((_arg) => {
382
- let matchResult_1, typ_2;
383
- switch (_arg.tag) {
384
- case 1: {
385
- matchResult_1 = 0;
386
- typ_2 = _arg.fields[0];
387
- break;
388
- }
389
- case 2: {
390
- matchResult_1 = 0;
391
- typ_2 = _arg.fields[1];
392
- break;
393
- }
394
- default:
395
- matchResult_1 = 1;
396
- }
397
- switch (matchResult_1) {
398
- case 0:
399
- return namesOf(typ_2);
400
- default:
401
- return empty_1();
402
- }
403
- }, typ.fields[0].Cases);
404
- case 4:
405
- return collect(namesOf, typ.fields[0]);
406
- case 5: {
407
- const functionType = typ.fields[0];
408
- return append(namesOf(functionType.ReturnType), collect((parameter) => namesOf(parameter.Type), functionType.Parameters));
409
- }
410
- default:
411
- return empty_1();
412
- }
413
- break;
304
+ const namesOf = (typ) => {
305
+ if (typ.tag === 13) {
306
+ return singleton(typ.fields[0]);
307
+ }
308
+ else {
309
+ return collect(namesOf, FSharpTypeModule_children(typ));
414
310
  }
415
311
  };
416
- const mentioned = ofSeq(collect((parameter_1) => namesOf(parameter_1.Type), parameters), {
312
+ const mentioned = ofSeq_1(collect((parameter) => namesOf(parameter.Type), parameters), {
417
313
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
418
314
  });
419
- return length(filter((_arg_1) => {
420
- if (_arg_1.tag === 0) {
315
+ return length(filter((_arg) => {
316
+ if (_arg.tag === 0) {
421
317
  return true;
422
318
  }
423
319
  else {
424
- return !FSharpSet__Contains(mentioned, _arg_1.fields[0].Name);
320
+ return !FSharpSet__Contains(mentioned, _arg.fields[0].Name);
425
321
  }
426
322
  }, typeParameters)) | 0;
427
323
  }
428
324
 
429
325
  function ownTypeParameterNames(typeParameters) {
430
- return ofSeq(choose((_arg) => {
326
+ return ofSeq_1(choose((_arg) => {
431
327
  if (_arg.tag === 0) {
432
328
  return undefined;
433
329
  }
@@ -448,9 +344,9 @@ function withoutOption(typ) {
448
344
  }
449
345
  }
450
346
 
451
- function signatureKey(typeParameters, parameters) {
347
+ function signatureKey(aliases, typeParameters, parameters) {
452
348
  const erased = ownTypeParameterNames(typeParameters);
453
- return [distinguishableTypeParameters(typeParameters, parameters), map((arg) => withoutOption(arg[0]), parametersSignatureWith(erased, parameters))];
349
+ return [distinguishableTypeParameters(typeParameters, parameters), map((arg) => withoutOption(arg[0]), parametersSignatureWith(aliases, erased, parameters))];
454
350
  }
455
351
 
456
352
  function withParameterlessOverloads(members) {
@@ -462,7 +358,7 @@ function withParameterlessOverloads(members) {
462
358
  return false;
463
359
  }
464
360
  };
465
- const ambiguous = ofSeq(map((tuple) => tuple[0], filter((tupledArg_1) => {
361
+ const ambiguous = ofSeq_1(map((tuple) => tuple[0], filter((tupledArg_1) => {
466
362
  const group = tupledArg_1[1];
467
363
  if (length(filter((tupledArg_2) => tupledArg_2[2], group)) >= 2) {
468
364
  return !exists((tupledArg_3) => tupledArg_3[3], group);
@@ -493,7 +389,7 @@ function withParameterlessOverloads(members) {
493
389
  return members;
494
390
  }
495
391
  else {
496
- const preferred = ofSeq(map((tupledArg_5) => (head(sortBy((tupledArg_6) => [!tupledArg_6[0], tupledArg_6[1]], map((tuple_2) => tuple_2[1], tupledArg_5[1]), {
392
+ const preferred = ofSeq_1(map((tupledArg_5) => (head(sortBy((tupledArg_6) => [!tupledArg_6[0], tupledArg_6[1]], map((tuple_2) => tuple_2[1], tupledArg_5[1]), {
497
393
  Compare: (x_3, y_3) => (compareArrays(x_3, y_3) | 0),
498
394
  }))[1] | 0), List_groupBy((tuple_1) => tuple_1[0], choose((tupledArg_4) => {
499
395
  let info_2, info_3;
@@ -578,29 +474,71 @@ function withParameterlessOverloads(members) {
578
474
  }
579
475
  }
580
476
 
581
- function withoutSubsumedOverloads(members) {
477
+ function withoutSubsumedOverloads(aliases, members) {
582
478
  const signatureOf = (fsharpMember) => {
583
479
  switch (fsharpMember.tag) {
584
480
  case 2: {
585
481
  const info_1 = fsharpMember.fields[0];
586
- return [[info_1.Name, false, true], info_1.TypeParameters, parametersSignature(info_1.Parameters), info_1.Type];
482
+ return [[info_1.Name, false, true], info_1.TypeParameters, parametersSignature(aliases, info_1.Parameters), info_1.Type];
587
483
  }
588
484
  case 1:
589
485
  return undefined;
590
486
  default: {
591
487
  const info = fsharpMember.fields[0];
592
- return [[info.Name, true, info.IsStatic], info.TypeParameters, parametersSignature(info.Parameters), info.Type];
488
+ return [[info.Name, true, info.IsStatic], info.TypeParameters, parametersSignature(aliases, info.Parameters), info.Type];
593
489
  }
594
490
  }
595
491
  };
492
+ const caseTypes = (typ) => {
493
+ const typ_2 = (typ.tag === 3) ? typ.fields[0] : typ;
494
+ let matchResult, unionInfo_1, typ_4;
495
+ if (typ_2.tag === 1) {
496
+ if (forAll((_arg) => {
497
+ if (_arg.tag === 1) {
498
+ return true;
499
+ }
500
+ else {
501
+ return false;
502
+ }
503
+ }, typ_2.fields[0].Cases)) {
504
+ matchResult = 0;
505
+ unionInfo_1 = typ_2.fields[0];
506
+ }
507
+ else {
508
+ matchResult = 1;
509
+ typ_4 = typ_2;
510
+ }
511
+ }
512
+ else {
513
+ matchResult = 1;
514
+ typ_4 = typ_2;
515
+ }
516
+ switch (matchResult) {
517
+ case 0:
518
+ return ofSeq_1(choose((_arg_1) => {
519
+ if (_arg_1.tag === 1) {
520
+ return _arg_1.fields[0];
521
+ }
522
+ else {
523
+ return undefined;
524
+ }
525
+ }, unionInfo_1.Cases), {
526
+ Compare: (x, y) => (compare(x, y) | 0),
527
+ });
528
+ default:
529
+ return singleton_1(typ_4, {
530
+ Compare: (x_1, y_1) => (compare(x_1, y_1) | 0),
531
+ });
532
+ }
533
+ };
596
534
  return filter((candidate) => {
597
- const matchValue_3 = filter((other) => {
535
+ const matchValue_6 = filter((other) => {
598
536
  const matchValue = signatureOf(other);
599
537
  const matchValue_1 = signatureOf(candidate);
600
- let matchResult, longKey, longParameters, longType, longTypeParameters, shortKey, shortParameters, shortType, shortTypeParameters;
538
+ let matchResult_1, longKey, longParameters, longType, longTypeParameters, shortKey, shortParameters, shortType, shortTypeParameters;
601
539
  if (matchValue != null) {
602
540
  if (matchValue_1 != null) {
603
- matchResult = 0;
541
+ matchResult_1 = 0;
604
542
  longKey = matchValue[0];
605
543
  longParameters = matchValue[2];
606
544
  longType = matchValue[3];
@@ -611,13 +549,13 @@ function withoutSubsumedOverloads(members) {
611
549
  shortTypeParameters = matchValue_1[1];
612
550
  }
613
551
  else {
614
- matchResult = 1;
552
+ matchResult_1 = 1;
615
553
  }
616
554
  }
617
555
  else {
618
- matchResult = 1;
556
+ matchResult_1 = 1;
619
557
  }
620
- switch (matchResult) {
558
+ switch (matchResult_1) {
621
559
  case 0:
622
560
  if ((((equalArrays(longKey, shortKey) && equals(longTypeParameters, shortTypeParameters)) && equals(longType, shortType)) && (length(longParameters) > length(shortParameters))) && forAll2((tupledArg, tupledArg_1) => (equals(tupledArg[0], tupledArg_1[0]) && (!tupledArg_1[1] ? true : tupledArg[1])), take(length(shortParameters), longParameters), shortParameters)) {
623
561
  return forAll((tuple) => tuple[1], skip(length(shortParameters), longParameters));
@@ -629,30 +567,64 @@ function withoutSubsumedOverloads(members) {
629
567
  return false;
630
568
  }
631
569
  }, members);
632
- let matchResult_1;
633
- if (!isEmpty_1(matchValue_3)) {
634
- if (isEmpty_1(tail(matchValue_3))) {
635
- matchResult_1 = 0;
570
+ let matchResult_2;
571
+ if (!isEmpty_1(matchValue_6)) {
572
+ if (isEmpty_1(tail(matchValue_6))) {
573
+ matchResult_2 = 0;
636
574
  }
637
575
  else {
638
- matchResult_1 = 1;
576
+ matchResult_2 = 1;
639
577
  }
640
578
  }
641
579
  else {
642
- matchResult_1 = 1;
580
+ matchResult_2 = 1;
643
581
  }
644
- switch (matchResult_1) {
582
+ switch (matchResult_2) {
645
583
  case 0:
646
584
  return false;
647
585
  default:
648
- return true;
586
+ return !exists((other_1) => {
587
+ const matchValue_3 = signatureOf(other_1);
588
+ const matchValue_4 = signatureOf(candidate);
589
+ let matchResult_3, narrowKey, narrowParameters, narrowType, narrowTypeParameters, wideKey, wideParameters, wideType, wideTypeParameters;
590
+ if (matchValue_3 != null) {
591
+ if (matchValue_4 != null) {
592
+ matchResult_3 = 0;
593
+ narrowKey = matchValue_4[0];
594
+ narrowParameters = matchValue_4[2];
595
+ narrowType = matchValue_4[3];
596
+ narrowTypeParameters = matchValue_4[1];
597
+ wideKey = matchValue_3[0];
598
+ wideParameters = matchValue_3[2];
599
+ wideType = matchValue_3[3];
600
+ wideTypeParameters = matchValue_3[1];
601
+ }
602
+ else {
603
+ matchResult_3 = 1;
604
+ }
605
+ }
606
+ else {
607
+ matchResult_3 = 1;
608
+ }
609
+ switch (matchResult_3) {
610
+ case 0:
611
+ if ((((equalArrays(wideKey, narrowKey) && equals(wideTypeParameters, narrowTypeParameters)) && equals(wideType, narrowType)) && (length(wideParameters) === length(narrowParameters))) && !equals(wideParameters, narrowParameters)) {
612
+ return forAll2((tupledArg_2, tupledArg_3) => (isSubset(caseTypes(tupledArg_3[0]), caseTypes(tupledArg_2[0])) && (!tupledArg_3[1] ? true : tupledArg_2[1])), wideParameters, narrowParameters);
613
+ }
614
+ else {
615
+ return false;
616
+ }
617
+ default:
618
+ return false;
619
+ }
620
+ }, members);
649
621
  }
650
622
  }, members);
651
623
  }
652
624
 
653
- export function distinctBySignature(members) {
654
- const members_2 = withParameterlessOverloads(withoutSubsumedOverloads(members));
655
- const methodNames = ofSeq(choose((_arg) => {
625
+ export function distinctBySignature(aliases, members) {
626
+ const members_2 = withParameterlessOverloads(withoutSubsumedOverloads(aliases, members));
627
+ const methodNames = ofSeq_1(choose((_arg) => {
656
628
  if (_arg.tag === 0) {
657
629
  return _arg.fields[0].Name;
658
630
  }
@@ -691,16 +663,16 @@ export function distinctBySignature(members) {
691
663
  switch (_arg_2.tag) {
692
664
  case 1: {
693
665
  const info_3 = _arg_2.fields[0];
694
- return new FSharpChoice$3(/* Choice2Of3 */ 1, [[info_3.Name, map((tuple) => tuple[0], parametersSignature(info_3.Parameters))]]);
666
+ return new FSharpChoice$3(/* Choice2Of3 */ 1, [[info_3.Name, map((tuple) => tuple[0], parametersSignature(aliases, info_3.Parameters))]]);
695
667
  }
696
668
  case 2: {
697
669
  const info_4 = _arg_2.fields[0];
698
- const patternInput_1 = signatureKey(info_4.TypeParameters, info_4.Parameters);
670
+ const patternInput_1 = signatureKey(aliases, info_4.TypeParameters, info_4.Parameters);
699
671
  return new FSharpChoice$3(/* Choice3Of3 */ 2, [[info_4.Name, patternInput_1[0], patternInput_1[1]]]);
700
672
  }
701
673
  default: {
702
674
  const info_2 = _arg_2.fields[0];
703
- const patternInput = signatureKey(info_2.TypeParameters, info_2.Parameters);
675
+ const patternInput = signatureKey(aliases, info_2.TypeParameters, info_2.Parameters);
704
676
  return new FSharpChoice$3(/* Choice1Of3 */ 0, [[info_2.Name, patternInput[0], patternInput[1]]]);
705
677
  }
706
678
  }
@@ -717,9 +689,9 @@ export function distinctBySignature(members) {
717
689
  }));
718
690
  }
719
691
 
720
- function mergeTypes(types) {
692
+ function mergeTypes(aliases, types) {
721
693
  const indexes = new Map([]);
722
- const aliases = new Set([]);
694
+ const seenAliases = new Set([]);
723
695
  const result = [];
724
696
  const enumerator = getEnumerator(types);
725
697
  try {
@@ -729,7 +701,7 @@ function mergeTypes(types) {
729
701
  switch (typ.tag) {
730
702
  case 9: {
731
703
  const aliasInfo = typ.fields[0];
732
- if (addToSet(`${aliasInfo.Name}/${length(aliasInfo.TypeParameters)}`, aliases)) {
704
+ if (addToSet(`${aliasInfo.Name}/${length(aliasInfo.TypeParameters)}`, seenAliases)) {
733
705
  void (result.push(typ));
734
706
  }
735
707
  break;
@@ -741,7 +713,7 @@ function mergeTypes(types) {
741
713
  const existing = item(index, result);
742
714
  if (existing.tag === 5) {
743
715
  const existingInterfaceInfo = existing.fields[0];
744
- setItem(result, index, new FSharpType(/* Interface */ 5, [(Members = distinctBySignature(append(existingInterfaceInfo.Members, interfaceInfo.Members)), (Inheritance = List_distinct(append(existingInterfaceInfo.Inheritance, interfaceInfo.Inheritance), {
716
+ setItem(result, index, new FSharpType(/* Interface */ 5, [(Members = distinctBySignature(aliases, append(existingInterfaceInfo.Members, interfaceInfo.Members)), (Inheritance = List_distinct(append(existingInterfaceInfo.Inheritance, interfaceInfo.Inheritance), {
745
717
  Equals: equals,
746
718
  GetHashCode: (x) => (safeHash(x) | 0),
747
719
  }), new FSharpInterface(existingInterfaceInfo.Attributes, existingInterfaceInfo.Name, existingInterfaceInfo.XmlDoc, existingInterfaceInfo.OriginalName, (length(interfaceInfo.TypeParameters) > length(existingInterfaceInfo.TypeParameters)) ? interfaceInfo.TypeParameters : existingInterfaceInfo.TypeParameters, Members, Inheritance)))]));
@@ -767,7 +739,7 @@ function mergeTypes(types) {
767
739
  break;
768
740
  }
769
741
  case 17: {
770
- if (addToSet(concat("class/", typ.fields[0].Name), aliases)) {
742
+ if (addToSet(concat("class/", typ.fields[0].Name), seenAliases)) {
771
743
  void (result.push(typ));
772
744
  }
773
745
  break;
@@ -780,10 +752,10 @@ function mergeTypes(types) {
780
752
  finally {
781
753
  disposeSafe(enumerator);
782
754
  }
783
- return ofSeq_1(result);
755
+ return ofSeq_2(result);
784
756
  }
785
757
 
786
- function mergeModules(types) {
758
+ function mergeModules(aliases, types) {
787
759
  const indexes = new Map([]);
788
760
  const result = [];
789
761
  const enumerator = getEnumerator(types);
@@ -792,13 +764,13 @@ function mergeModules(types) {
792
764
  const typ = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
793
765
  if (typ.tag === 4) {
794
766
  const moduleInfo = typ.fields[0];
795
- const newModuleInfo = new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, mergeModules(mergeTypes(moduleInfo.Types)));
767
+ const newModuleInfo = new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, mergeModules(aliases, mergeTypes(aliases, moduleInfo.Types)));
796
768
  if (indexes.has(moduleInfo.Name)) {
797
769
  const index = getItemFromDict(indexes, moduleInfo.Name) | 0;
798
770
  const existing = item(index, result);
799
771
  if (existing.tag === 4) {
800
772
  const existingModuleInfo = existing.fields[0];
801
- setItem(result, index, new FSharpType(/* Module */ 4, [new FSharpModule(existingModuleInfo.Name, existingModuleInfo.IsRecursive, existingModuleInfo.ImportSpecifier, mergeModules(mergeTypes(append(existingModuleInfo.Types, newModuleInfo.Types))))]));
773
+ setItem(result, index, new FSharpType(/* Module */ 4, [new FSharpModule(existingModuleInfo.Name, existingModuleInfo.IsRecursive, existingModuleInfo.ImportSpecifier, mergeModules(aliases, mergeTypes(aliases, append(existingModuleInfo.Types, newModuleInfo.Types))))]));
802
774
  }
803
775
  else {
804
776
  throw new Exception("Invalid state");
@@ -817,7 +789,7 @@ function mergeModules(types) {
817
789
  finally {
818
790
  disposeSafe(enumerator);
819
791
  }
820
- return ofSeq_1(result);
792
+ return ofSeq_2(result);
821
793
  }
822
794
 
823
795
  function dropEmptyModules(types) {
@@ -841,23 +813,23 @@ function dropEmptyModules(types) {
841
813
  }, types);
842
814
  }
843
815
 
844
- function distinctMembers(types) {
816
+ function distinctMembers(aliases, types) {
845
817
  return map((typ) => {
846
818
  switch (typ.tag) {
847
819
  case 5: {
848
820
  const interfaceInfo = typ.fields[0];
849
- return new FSharpType(/* Interface */ 5, [new FSharpInterface(interfaceInfo.Attributes, interfaceInfo.Name, interfaceInfo.XmlDoc, interfaceInfo.OriginalName, interfaceInfo.TypeParameters, distinctBySignature(interfaceInfo.Members), interfaceInfo.Inheritance)]);
821
+ return new FSharpType(/* Interface */ 5, [new FSharpInterface(interfaceInfo.Attributes, interfaceInfo.Name, interfaceInfo.XmlDoc, interfaceInfo.OriginalName, interfaceInfo.TypeParameters, distinctBySignature(aliases, interfaceInfo.Members), interfaceInfo.Inheritance)]);
850
822
  }
851
823
  case 17: {
852
824
  const classInfo = typ.fields[0];
853
- return new FSharpType(/* Class */ 17, [new FSharpClass(classInfo.Attributes, classInfo.XmlDoc, classInfo.Name, classInfo.TypeParameters, classInfo.PrimaryConstructor, List_distinctBy((constructorInfo) => parametersSignature(constructorInfo.Parameters), classInfo.SecondaryConstructors, {
825
+ return new FSharpType(/* Class */ 17, [new FSharpClass(classInfo.Attributes, classInfo.XmlDoc, classInfo.Name, classInfo.TypeParameters, classInfo.PrimaryConstructor, List_distinctBy((constructorInfo) => parametersSignature(aliases, constructorInfo.Parameters), classInfo.SecondaryConstructors, {
854
826
  Equals: equals,
855
827
  GetHashCode: (x) => (safeHash(x) | 0),
856
828
  }), classInfo.ExplicitFields)]);
857
829
  }
858
830
  case 4: {
859
831
  const moduleInfo = typ.fields[0];
860
- return new FSharpType(/* Module */ 4, [new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, distinctMembers(moduleInfo.Types))]);
832
+ return new FSharpType(/* Module */ 4, [new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, distinctMembers(aliases, moduleInfo.Types))]);
861
833
  }
862
834
  default:
863
835
  return typ;
@@ -865,10 +837,146 @@ function distinctMembers(types) {
865
837
  }, types);
866
838
  }
867
839
 
840
+ /**
841
+ * TypeScript resolves a call to the first declaration it matches
842
+ */
843
+ export function disambiguateOverloads(aliases, types) {
844
+ const requiredKey = (fsharpMember) => {
845
+ const key = (name, isStatic, typeParameters, parameters) => {
846
+ if (isEmpty_1(parameters)) {
847
+ return undefined;
848
+ }
849
+ else {
850
+ return [name, isStatic, typeParameters, parametersSignature(aliases, filter((parameter) => !parameter.IsOptional, parameters))];
851
+ }
852
+ };
853
+ switch (fsharpMember.tag) {
854
+ case 2: {
855
+ const info_1 = fsharpMember.fields[0];
856
+ return key(info_1.Name, true, info_1.TypeParameters, info_1.Parameters);
857
+ }
858
+ case 1:
859
+ return undefined;
860
+ default: {
861
+ const info = fsharpMember.fields[0];
862
+ return key(info.Name, info.IsStatic, info.TypeParameters, info.Parameters);
863
+ }
864
+ }
865
+ };
866
+ return map((_arg_1) => {
867
+ let taken;
868
+ switch (_arg_1.tag) {
869
+ case 5: {
870
+ const interfaceInfo = _arg_1.fields[0];
871
+ return new FSharpType(/* Interface */ 5, [new FSharpInterface(interfaceInfo.Attributes, interfaceInfo.Name, interfaceInfo.XmlDoc, interfaceInfo.OriginalName, interfaceInfo.TypeParameters, (taken = (new HashSet([], {
872
+ Equals: equalArrays,
873
+ GetHashCode: (x) => (arrayHash(x) | 0),
874
+ })), choose((fsharpMember_2) => {
875
+ const matchValue_1 = requiredKey(fsharpMember_2);
876
+ if (matchValue_1 != null) {
877
+ const free = (candidate_mut, key_2_mut) => {
878
+ free:
879
+ while (true) {
880
+ const candidate = candidate_mut, key_2 = key_2_mut;
881
+ if (!taken.has(key_2)) {
882
+ addToSet(key_2, taken);
883
+ return candidate;
884
+ }
885
+ else {
886
+ let matchValue_2;
887
+ const fsharpMember_1 = candidate;
888
+ const promote = (parameters_2) => {
889
+ const matchValue = tryFindIndex((_arg) => _arg.IsOptional, parameters_2);
890
+ if (matchValue != null) {
891
+ const index = matchValue | 0;
892
+ return mapIndexed((currentIndex, parameter_1) => {
893
+ if (currentIndex === index) {
894
+ return new FSharpParameter(parameter_1.Attributes, parameter_1.Name, false, parameter_1.Type, parameter_1.OriginalGlueMember);
895
+ }
896
+ else {
897
+ return parameter_1;
898
+ }
899
+ }, parameters_2);
900
+ }
901
+ else {
902
+ return undefined;
903
+ }
904
+ };
905
+ switch (fsharpMember_1.tag) {
906
+ case 2: {
907
+ const info_3 = fsharpMember_1.fields[0];
908
+ const option_3 = promote(info_3.Parameters);
909
+ matchValue_2 = ((option_3 != null) ? (new FSharpMember(/* StaticMember */ 2, [new FSharpStaticMemberInfo(info_3.Attributes, info_3.Name, info_3.OriginalName, info_3.TypeParameters, option_3, info_3.Type, info_3.IsOptional, info_3.Accessor, info_3.Accessibility, info_3.XmlDoc)])) : undefined);
910
+ break;
911
+ }
912
+ case 1: {
913
+ matchValue_2 = fsharpMember_1;
914
+ break;
915
+ }
916
+ default: {
917
+ const info_2 = fsharpMember_1.fields[0];
918
+ const option_1 = promote(info_2.Parameters);
919
+ matchValue_2 = ((option_1 != null) ? (new FSharpMember(/* Method */ 0, [new FSharpMemberInfo(info_2.Attributes, info_2.Name, info_2.OriginalName, info_2.TypeParameters, option_1, info_2.Type, info_2.IsOptional, info_2.IsStatic, info_2.Accessor, info_2.Accessibility, info_2.XmlDoc, info_2.Body)])) : undefined);
920
+ }
921
+ }
922
+ if (matchValue_2 != null) {
923
+ const promoted = matchValue_2;
924
+ const matchValue_3 = requiredKey(promoted);
925
+ if (matchValue_3 != null) {
926
+ candidate_mut = promoted;
927
+ key_2_mut = matchValue_3;
928
+ continue free;
929
+ }
930
+ else {
931
+ return undefined;
932
+ }
933
+ }
934
+ else {
935
+ return undefined;
936
+ }
937
+ }
938
+ break;
939
+ }
940
+ };
941
+ return free(fsharpMember_2, matchValue_1);
942
+ }
943
+ else {
944
+ return fsharpMember_2;
945
+ }
946
+ }, interfaceInfo.Members)), interfaceInfo.Inheritance)]);
947
+ }
948
+ case 4: {
949
+ const moduleInfo = _arg_1.fields[0];
950
+ return new FSharpType(/* Module */ 4, [new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, disambiguateOverloads(aliases, moduleInfo.Types))]);
951
+ }
952
+ default:
953
+ return _arg_1;
954
+ }
955
+ }, types);
956
+ }
957
+
958
+ /**
959
+ * If a type is declared twice, merge them into one.
960
+ *
961
+ * This can happens because TypeScript allows multiple declarations of the same type.
962
+ *
963
+ * Example:
964
+ *
965
+ * <code lang="typescript">
966
+ * interface A {
967
+ * a: string;
968
+ * }
969
+ *
970
+ * interface A {
971
+ * b: number;
972
+ * }
973
+ * </code>
974
+ */
975
+ export function applyWith(aliases, types) {
976
+ return distinctMembers(aliases, dropEmptyModules(mergeModules(aliases, mergeTypes(aliases, types))));
977
+ }
978
+
868
979
  export function apply(types) {
869
- aliasTargets.clear();
870
- genericAliasTargets.clear();
871
- collectAliases(empty_1(), types);
872
- return distinctMembers(dropEmptyModules(mergeModules(mergeTypes(types))));
980
+ return applyWith(aliasesOf(types), types);
873
981
  }
874
982