@glutinum/cli 0.6.0 → 0.8.0

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 (146) hide show
  1. package/dist/Glutinum.Converter/FsharpAST.js +44 -12
  2. package/dist/Glutinum.Converter/FsharpAST.js.map +1 -1
  3. package/dist/Glutinum.Converter/GlueAST.js +73 -26
  4. package/dist/Glutinum.Converter/GlueAST.js.map +1 -1
  5. package/dist/Glutinum.Converter/Printer.js +91 -39
  6. package/dist/Glutinum.Converter/Printer.js.map +1 -1
  7. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
  8. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js.map +1 -1
  9. package/dist/Glutinum.Converter/Reader/Declaration.js +21 -7
  10. package/dist/Glutinum.Converter/Reader/Declaration.js.map +1 -1
  11. package/dist/Glutinum.Converter/Reader/Documentation.js +65 -22
  12. package/dist/Glutinum.Converter/Reader/Documentation.js.map +1 -1
  13. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +1 -1
  14. package/dist/Glutinum.Converter/Reader/ExportAssignment.js.map +1 -1
  15. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +3 -2
  16. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js.map +1 -1
  17. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +1 -1
  18. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js.map +1 -1
  19. package/dist/Glutinum.Converter/Reader/TypeNode.js +32 -29
  20. package/dist/Glutinum.Converter/Reader/TypeNode.js.map +1 -1
  21. package/dist/Glutinum.Converter/Reader/Utils.js +21 -1
  22. package/dist/Glutinum.Converter/Reader/Utils.js.map +1 -1
  23. package/dist/Glutinum.Converter/Reader/VariableStatement.js +8 -3
  24. package/dist/Glutinum.Converter/Reader/VariableStatement.js.map +1 -1
  25. package/dist/Glutinum.Converter/Transform.js +554 -304
  26. package/dist/Glutinum.Converter/Transform.js.map +1 -1
  27. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs +57 -0
  28. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs.js +105 -0
  29. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs.js.map +1 -0
  30. package/dist/fable_modules/Fable.Promise.3.2.0/Fable.Promise.fableproj +20 -0
  31. package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs +766 -0
  32. package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs.js +218 -0
  33. package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs.js.map +1 -0
  34. package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs +31 -0
  35. package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs.js +20 -0
  36. package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs.js.map +1 -0
  37. package/dist/fable_modules/fable-library-js.4.14.0/Array.d.ts +123 -0
  38. package/dist/fable_modules/fable-library-js.4.14.0/Array.js +1242 -0
  39. package/dist/fable_modules/fable-library-js.4.14.0/Async.d.ts +32 -0
  40. package/dist/fable_modules/fable-library-js.4.14.0/Async.js +158 -0
  41. package/dist/fable_modules/fable-library-js.4.14.0/AsyncBuilder.d.ts +59 -0
  42. package/dist/fable_modules/fable-library-js.4.14.0/AsyncBuilder.js +183 -0
  43. package/dist/fable_modules/fable-library-js.4.14.0/BigInt.d.ts +115 -0
  44. package/dist/fable_modules/fable-library-js.4.14.0/BigInt.js +282 -0
  45. package/dist/fable_modules/fable-library-js.4.14.0/BitConverter.d.ts +27 -0
  46. package/dist/fable_modules/fable-library-js.4.14.0/BitConverter.js +138 -0
  47. package/dist/fable_modules/fable-library-js.4.14.0/Boolean.d.ts +3 -0
  48. package/dist/fable_modules/fable-library-js.4.14.0/Boolean.js +21 -0
  49. package/dist/fable_modules/fable-library-js.4.14.0/CHANGELOG.md +37 -0
  50. package/dist/fable_modules/fable-library-js.4.14.0/Char.d.ts +65 -0
  51. package/dist/fable_modules/fable-library-js.4.14.0/Char.js +169 -0
  52. package/dist/fable_modules/fable-library-js.4.14.0/Choice.d.ts +121 -0
  53. package/dist/fable_modules/fable-library-js.4.14.0/Choice.js +184 -0
  54. package/dist/fable_modules/fable-library-js.4.14.0/Date.d.ts +70 -0
  55. package/dist/fable_modules/fable-library-js.4.14.0/Date.js +749 -0
  56. package/dist/fable_modules/fable-library-js.4.14.0/DateOffset.d.ts +63 -0
  57. package/dist/fable_modules/fable-library-js.4.14.0/DateOffset.js +268 -0
  58. package/dist/fable_modules/fable-library-js.4.14.0/DateOnly.d.ts +18 -0
  59. package/dist/fable_modules/fable-library-js.4.14.0/DateOnly.js +124 -0
  60. package/dist/fable_modules/fable-library-js.4.14.0/Decimal.d.ts +45 -0
  61. package/dist/fable_modules/fable-library-js.4.14.0/Decimal.js +212 -0
  62. package/dist/fable_modules/fable-library-js.4.14.0/Double.d.ts +11 -0
  63. package/dist/fable_modules/fable-library-js.4.14.0/Double.js +46 -0
  64. package/dist/fable_modules/fable-library-js.4.14.0/Encoding.d.ts +12 -0
  65. package/dist/fable_modules/fable-library-js.4.14.0/Encoding.js +173 -0
  66. package/dist/fable_modules/fable-library-js.4.14.0/Event.d.ts +31 -0
  67. package/dist/fable_modules/fable-library-js.4.14.0/Event.js +93 -0
  68. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Collections.d.ts +7 -0
  69. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Collections.js +27 -0
  70. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.CompilerServices.d.ts +12 -0
  71. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.CompilerServices.js +27 -0
  72. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.d.ts +17 -0
  73. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.js +69 -0
  74. package/dist/fable_modules/fable-library-js.4.14.0/Global.d.ts +24 -0
  75. package/dist/fable_modules/fable-library-js.4.14.0/Global.js +8 -0
  76. package/dist/fable_modules/fable-library-js.4.14.0/Guid.d.ts +10 -0
  77. package/dist/fable_modules/fable-library-js.4.14.0/Guid.js +142 -0
  78. package/dist/fable_modules/fable-library-js.4.14.0/Int32.d.ts +28 -0
  79. package/dist/fable_modules/fable-library-js.4.14.0/Int32.js +135 -0
  80. package/dist/fable_modules/fable-library-js.4.14.0/List.d.ts +143 -0
  81. package/dist/fable_modules/fable-library-js.4.14.0/List.js +1273 -0
  82. package/dist/fable_modules/fable-library-js.4.14.0/Long.d.ts +3 -0
  83. package/dist/fable_modules/fable-library-js.4.14.0/Long.js +46 -0
  84. package/dist/fable_modules/fable-library-js.4.14.0/MailboxProcessor.d.ts +25 -0
  85. package/dist/fable_modules/fable-library-js.4.14.0/MailboxProcessor.js +93 -0
  86. package/dist/fable_modules/fable-library-js.4.14.0/Map.d.ts +178 -0
  87. package/dist/fable_modules/fable-library-js.4.14.0/Map.js +1396 -0
  88. package/dist/fable_modules/fable-library-js.4.14.0/MapUtil.d.ts +10 -0
  89. package/dist/fable_modules/fable-library-js.4.14.0/MapUtil.js +112 -0
  90. package/dist/fable_modules/fable-library-js.4.14.0/MutableMap.d.ts +52 -0
  91. package/dist/fable_modules/fable-library-js.4.14.0/MutableMap.js +327 -0
  92. package/dist/fable_modules/fable-library-js.4.14.0/MutableSet.d.ts +39 -0
  93. package/dist/fable_modules/fable-library-js.4.14.0/MutableSet.js +233 -0
  94. package/dist/fable_modules/fable-library-js.4.14.0/Native.d.ts +2 -0
  95. package/dist/fable_modules/fable-library-js.4.14.0/Native.js +8 -0
  96. package/dist/fable_modules/fable-library-js.4.14.0/Numeric.d.ts +19 -0
  97. package/dist/fable_modules/fable-library-js.4.14.0/Numeric.js +71 -0
  98. package/dist/fable_modules/fable-library-js.4.14.0/Observable.d.ts +32 -0
  99. package/dist/fable_modules/fable-library-js.4.14.0/Observable.js +113 -0
  100. package/dist/fable_modules/fable-library-js.4.14.0/Option.d.ts +28 -0
  101. package/dist/fable_modules/fable-library-js.4.14.0/Option.js +96 -0
  102. package/dist/fable_modules/fable-library-js.4.14.0/README.md +3 -0
  103. package/dist/fable_modules/fable-library-js.4.14.0/Random.d.ts +37 -0
  104. package/dist/fable_modules/fable-library-js.4.14.0/Random.js +170 -0
  105. package/dist/fable_modules/fable-library-js.4.14.0/Range.d.ts +12 -0
  106. package/dist/fable_modules/fable-library-js.4.14.0/Range.js +45 -0
  107. package/dist/fable_modules/fable-library-js.4.14.0/Reflection.d.ts +119 -0
  108. package/dist/fable_modules/fable-library-js.4.14.0/Reflection.js +461 -0
  109. package/dist/fable_modules/fable-library-js.4.14.0/RegExp.d.ts +10 -0
  110. package/dist/fable_modules/fable-library-js.4.14.0/RegExp.js +132 -0
  111. package/dist/fable_modules/fable-library-js.4.14.0/Result.d.ts +37 -0
  112. package/dist/fable_modules/fable-library-js.4.14.0/Result.js +165 -0
  113. package/dist/fable_modules/fable-library-js.4.14.0/Seq.d.ts +165 -0
  114. package/dist/fable_modules/fable-library-js.4.14.0/Seq.js +1379 -0
  115. package/dist/fable_modules/fable-library-js.4.14.0/Seq2.d.ts +18 -0
  116. package/dist/fable_modules/fable-library-js.4.14.0/Seq2.js +111 -0
  117. package/dist/fable_modules/fable-library-js.4.14.0/Set.d.ts +190 -0
  118. package/dist/fable_modules/fable-library-js.4.14.0/Set.js +1789 -0
  119. package/dist/fable_modules/fable-library-js.4.14.0/String.d.ts +50 -0
  120. package/dist/fable_modules/fable-library-js.4.14.0/String.js +543 -0
  121. package/dist/fable_modules/fable-library-js.4.14.0/System.Collections.Generic.d.ts +79 -0
  122. package/dist/fable_modules/fable-library-js.4.14.0/System.Collections.Generic.js +317 -0
  123. package/dist/fable_modules/fable-library-js.4.14.0/System.Text.d.ts +38 -0
  124. package/dist/fable_modules/fable-library-js.4.14.0/System.Text.js +162 -0
  125. package/dist/fable_modules/fable-library-js.4.14.0/SystemException.d.ts +5 -0
  126. package/dist/fable_modules/fable-library-js.4.14.0/SystemException.js +5 -0
  127. package/dist/fable_modules/fable-library-js.4.14.0/TimeOnly.d.ts +15 -0
  128. package/dist/fable_modules/fable-library-js.4.14.0/TimeOnly.js +122 -0
  129. package/dist/fable_modules/fable-library-js.4.14.0/TimeSpan.d.ts +34 -0
  130. package/dist/fable_modules/fable-library-js.4.14.0/TimeSpan.js +177 -0
  131. package/dist/fable_modules/fable-library-js.4.14.0/Timer.d.ts +19 -0
  132. package/dist/fable_modules/fable-library-js.4.14.0/Timer.js +67 -0
  133. package/dist/fable_modules/fable-library-js.4.14.0/Types.d.ts +58 -0
  134. package/dist/fable_modules/fable-library-js.4.14.0/Types.js +208 -0
  135. package/dist/fable_modules/fable-library-js.4.14.0/Unicode.13.0.0.d.ts +2 -0
  136. package/dist/fable_modules/fable-library-js.4.14.0/Unicode.13.0.0.js +4 -0
  137. package/dist/fable_modules/fable-library-js.4.14.0/Uri.d.ts +29 -0
  138. package/dist/fable_modules/fable-library-js.4.14.0/Uri.js +142 -0
  139. package/dist/fable_modules/fable-library-js.4.14.0/Util.d.ts +207 -0
  140. package/dist/fable_modules/fable-library-js.4.14.0/Util.js +770 -0
  141. package/dist/fable_modules/fable-library-js.4.14.0/big.d.ts +338 -0
  142. package/dist/fable_modules/fable-library-js.4.14.0/lib/big.d.ts +5 -0
  143. package/dist/fable_modules/fable-library-js.4.14.0/lib/big.js +826 -0
  144. package/dist/fable_modules/fable-library-js.4.14.0/package.json +24 -0
  145. package/dist/fable_modules/project_cracked.json +1 -0
  146. package/package.json +1 -1
@@ -1,12 +1,13 @@
1
- import { printf, toFail, interpolate, toText, trimStart } from "../fable_modules/fable-library-js.4.14.0/String.js";
2
- import { class_type } from "../fable_modules/fable-library-js.4.14.0/Reflection.js";
1
+ import { printf, toFail, interpolate, toText, join, trimStart } from "../fable_modules/fable-library-js.4.14.0/String.js";
2
+ import { record_type, list_type, class_type } from "../fable_modules/fable-library-js.4.14.0/Reflection.js";
3
+ import { Record } from "../fable_modules/fable-library-js.4.14.0/Types.js";
4
+ import { FSharpTypeParameter_Create_Z6CFD3565, FSharpTypeAlias, FSharpEnum, FSharpEnumCase, FSharpStaticMemberInfo, FSharpAccessor, FSharpMapped, FSharpMember, FSharpMemberInfo, FSharpMemberInfoBody, FSharpInterface, FSharpClass, FSharpConstructor, FSharpAccessibility, FSharpExplicitField, FSharpParameter, FSharpFunctionType, FSharpTypeReference, FSharpUnion, FSharpUnionCase, FSharpPrimitive, FSharpLiteral, FSharpCommentTypeParam, FSharpCommentParam, FSharpXmlDoc, FSharpAttribute, FSharpType, FSharpModule, FSharpXmlDoc_$reflection, FSharpAttribute_$reflection } from "./FsharpAST.js";
3
5
  import { empty as empty_1, singleton as singleton_1, collect, append, delay, toList } from "../fable_modules/fable-library-js.4.14.0/Seq.js";
4
- import { exists, append as append_1, forAll, tail, filter, choose, collect as collect_1, ofArray, sortBy, head as head_1, length, map, partition, singleton, empty, isEmpty } from "../fable_modules/fable-library-js.4.14.0/List.js";
5
- import { FSharpTypeParameter_Create_Z6CFD3565, FSharpTypeAlias, FSharpEnum, FSharpEnumCase, FSharpStaticMemberInfo, FSharpInterface, FSharpAccessor, FSharpMapped, FSharpMember, FSharpMemberInfo, FSharpClass, FSharpConstructor, FSharpAccessibility, FSharpExplicitField, FSharpParameter, FSharpFunctionType, FSharpTypeReference, FSharpUnion, FSharpUnionCase, FSharpPrimitive, FSharpLiteral, FSharpCommentParam, FSharpXmlDoc, FSharpAttribute, FSharpType, FSharpModule } from "./FsharpAST.js";
6
+ import { exists, filter, tryFind, choose, collect as collect_1, ofArray, forAll, length, partition, sortBy, map, append as append_1, head as head_1, tail, singleton, empty, isEmpty } from "../fable_modules/fable-library-js.4.14.0/List.js";
6
7
  import { sanitizeNameWithResult, removeSurroundingQuotes, mapTypeNameToFableCoreAwareName, sanitizeName } from "./Utils/Naming.js";
7
- import { unwrap, map as map_1, defaultArg } from "../fable_modules/fable-library-js.4.14.0/Option.js";
8
- import { GlueType, GlueTypeUnion, GlueConstructor, GlueType__get_Name } from "./GlueAST.js";
8
+ import { unwrap, value as value_4, map as map_1, defaultArg } from "../fable_modules/fable-library-js.4.14.0/Option.js";
9
9
  import { int32ToString, safeHash, equals, comparePrimitives } from "../fable_modules/fable-library-js.4.14.0/Util.js";
10
+ import { GlueType, GlueTypeUnion, GlueMember, GlueProperty, GlueAccessor, GlueConstructor, GlueType__get_Name } from "./GlueAST.js";
10
11
  import { warn, error } from "./Log.js";
11
12
  import { List_distinct } from "../fable_modules/fable-library-js.4.14.0/Seq2.js";
12
13
 
@@ -31,6 +32,18 @@ export function TransformContext_$ctor_Z535BF207(currentScopeName, parent) {
31
32
  return new TransformContext(currentScopeName, parent);
32
33
  }
33
34
 
35
+ export class TransformCommentResult extends Record {
36
+ constructor(ObsoleteAttributes, XmlDoc) {
37
+ super();
38
+ this.ObsoleteAttributes = ObsoleteAttributes;
39
+ this.XmlDoc = XmlDoc;
40
+ }
41
+ }
42
+
43
+ export function TransformCommentResult_$reflection() {
44
+ return record_type("Glutinum.Converter.Transform.TransformCommentResult", [], TransformCommentResult, () => [["ObsoleteAttributes", list_type(FSharpAttribute_$reflection())], ["XmlDoc", list_type(FSharpXmlDoc_$reflection())]]);
45
+ }
46
+
34
47
  export function TransformContext__get_FullName(__) {
35
48
  return __["FullName@"];
36
49
  }
@@ -81,44 +94,112 @@ function sanitizeNameAndPushScope(name, context) {
81
94
  }
82
95
 
83
96
  function transformComment(comment) {
84
- const patternInput = partition((_arg) => {
85
- if (_arg.tag === 3) {
86
- return true;
87
- }
88
- else {
89
- return false;
90
- }
91
- }, comment);
92
- return {
93
- ObsoleteAttributes: map((_arg_1) => {
94
- if (_arg_1.tag === 3) {
95
- return new FSharpAttribute(8, [_arg_1.fields[0]]);
97
+ const categorize = (acc_mut, comments_mut) => {
98
+ categorize:
99
+ while (true) {
100
+ const acc = acc_mut, comments = comments_mut;
101
+ if (!isEmpty(comments)) {
102
+ const rest = tail(comments);
103
+ const comment_1 = head_1(comments);
104
+ switch (comment_1.tag) {
105
+ case 3: {
106
+ acc_mut = {
107
+ Deprecated: append_1(acc.Deprecated, singleton(comment_1.fields[0])),
108
+ Others: acc.Others,
109
+ Remarks: acc.Remarks,
110
+ Throws: acc.Throws,
111
+ };
112
+ comments_mut = rest;
113
+ continue categorize;
114
+ }
115
+ case 8: {
116
+ acc_mut = {
117
+ Deprecated: acc.Deprecated,
118
+ Others: acc.Others,
119
+ Remarks: acc.Remarks,
120
+ Throws: append_1(acc.Throws, singleton(comment_1.fields[0])),
121
+ };
122
+ comments_mut = rest;
123
+ continue categorize;
124
+ }
125
+ case 4: {
126
+ acc_mut = {
127
+ Deprecated: acc.Deprecated,
128
+ Others: acc.Others,
129
+ Remarks: append_1(acc.Remarks, singleton(comment_1.fields[0])),
130
+ Throws: acc.Throws,
131
+ };
132
+ comments_mut = rest;
133
+ continue categorize;
134
+ }
135
+ default: {
136
+ acc_mut = {
137
+ Deprecated: acc.Deprecated,
138
+ Others: append_1(acc.Others, singleton(comment_1)),
139
+ Remarks: acc.Remarks,
140
+ Throws: acc.Throws,
141
+ };
142
+ comments_mut = rest;
143
+ continue categorize;
144
+ }
145
+ }
96
146
  }
97
147
  else {
98
- throw new Error("Should not happen");
148
+ return acc;
99
149
  }
100
- }, patternInput[0]),
101
- Others: map((comment_1) => {
102
- switch (comment_1.tag) {
103
- case 0:
104
- return new FSharpXmlDoc(0, [comment_1.fields[0]]);
105
- case 1:
106
- return new FSharpXmlDoc(2, [comment_1.fields[0]]);
107
- case 2: {
108
- const param = comment_1.fields[0];
109
- return new FSharpXmlDoc(1, [new FSharpCommentParam(param.Name, defaultArg(map_1((content_1) => trimStart(trimStart(trimStart(content_1), "-")), param.Content), ""))]);
110
- }
111
- case 4:
112
- return new FSharpXmlDoc(3, [comment_1.fields[0]]);
113
- case 5:
114
- return new FSharpXmlDoc(4, [comment_1.fields[0]]);
115
- case 6:
116
- return new FSharpXmlDoc(5, [comment_1.fields[0]]);
117
- default:
118
- throw new Error("Should not happen");
119
- }
120
- }, patternInput[1]),
150
+ break;
151
+ }
121
152
  };
153
+ const categories = categorize({
154
+ Deprecated: empty(),
155
+ Others: empty(),
156
+ Remarks: empty(),
157
+ Throws: empty(),
158
+ }, comment);
159
+ const obsoleteAttributes = map((Item) => (new FSharpAttribute(9, [Item])), categories.Deprecated);
160
+ const remarks = (!isEmpty(categories.Remarks) ? true : !isEmpty(categories.Throws)) ? (new FSharpXmlDoc(3, [join("\n", toList(delay(() => append(categories.Remarks, delay(() => append(!isEmpty(categories.Throws) ? append(!isEmpty(categories.Remarks) ? singleton_1("") : empty_1(), delay(() => append(singleton_1("Throws:"), delay(() => singleton_1("-------"))))) : empty_1(), delay(() => collect((throws) => append(singleton_1(""), delay(() => singleton_1(throws))), categories.Throws))))))))])) : void 0;
161
+ const others = map((comment_2) => {
162
+ switch (comment_2.tag) {
163
+ case 0:
164
+ return new FSharpXmlDoc(0, [comment_2.fields[0]]);
165
+ case 1:
166
+ return new FSharpXmlDoc(2, [comment_2.fields[0]]);
167
+ case 2: {
168
+ const param = comment_2.fields[0];
169
+ return new FSharpXmlDoc(1, [new FSharpCommentParam(param.Name, defaultArg(map_1((content_3) => trimStart(trimStart(trimStart(content_3), "-")), param.Content), ""))]);
170
+ }
171
+ case 5:
172
+ return new FSharpXmlDoc(4, [comment_2.fields[0]]);
173
+ case 6:
174
+ return new FSharpXmlDoc(5, [comment_2.fields[0]]);
175
+ case 7: {
176
+ const typeParam = comment_2.fields[0];
177
+ return new FSharpXmlDoc(6, [new FSharpCommentTypeParam(typeParam.TypeName, defaultArg(typeParam.Content, ""))]);
178
+ }
179
+ default:
180
+ throw new Error("Should not happen");
181
+ }
182
+ }, categories.Others);
183
+ return new TransformCommentResult(obsoleteAttributes, sortBy((xmlDoc) => {
184
+ switch (xmlDoc.tag) {
185
+ case 4:
186
+ return 1;
187
+ case 3:
188
+ return 2;
189
+ case 5:
190
+ return 3;
191
+ case 1:
192
+ return 4;
193
+ case 6:
194
+ return 5;
195
+ case 2:
196
+ return 999;
197
+ default:
198
+ return 0;
199
+ }
200
+ }, toList(delay(() => append(others, delay(() => ((remarks != null) ? singleton_1(value_4(remarks)) : empty_1()))))), {
201
+ Compare: comparePrimitives,
202
+ }));
122
203
  }
123
204
 
124
205
  function transformLiteral(glueLiteral) {
@@ -156,6 +237,8 @@ function transformPrimitive(gluePrimitive) {
156
237
  return new FSharpPrimitive(6, []);
157
238
  case 9:
158
239
  return new FSharpPrimitive(6, []);
240
+ case 10:
241
+ return new FSharpPrimitive(6, []);
159
242
  default:
160
243
  return new FSharpPrimitive(0, []);
161
244
  }
@@ -166,6 +249,7 @@ function transformTupleType(context, glueTypes) {
166
249
  }
167
250
 
168
251
  function transformType(context_mut, glueType_mut) {
252
+ let originalInterface;
169
253
  transformType:
170
254
  while (true) {
171
255
  const context = context_mut, glueType = glueType_mut;
@@ -205,7 +289,14 @@ function transformType(context_mut, glueType_mut) {
205
289
  continue transformType;
206
290
  }
207
291
  else {
208
- return new FSharpType(1, [new FSharpUnion(empty(), `U${length(others)}`, map((caseType) => (new FSharpUnionCase(empty(), mapTypeNameToFableCoreAwareName(GlueType__get_Name(caseType)))), others), isOptional)]);
292
+ const matchValue = tryOptimizeUnionType(context, TransformContext__get_CurrentScopeName(context), others);
293
+ if (matchValue == null) {
294
+ return new FSharpType(1, [new FSharpUnion(empty(), `U${length(others)}`, map((caseType) => (new FSharpUnionCase(empty(), mapTypeNameToFableCoreAwareName(GlueType__get_Name(caseType)))), others), isOptional)]);
295
+ }
296
+ else {
297
+ TransformContext__ExposeType_Z1D58A540(context, matchValue);
298
+ return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
299
+ }
209
300
  }
210
301
  }
211
302
  case 13: {
@@ -227,19 +318,38 @@ function transformType(context_mut, glueType_mut) {
227
318
  case 1:
228
319
  return new FSharpType(4, [transformInterface(context, glueType.fields[0])]);
229
320
  case 22: {
230
- const typeLiteralParameters = sortBy((_arg) => _arg.IsOptional, map((parameter_1) => {
231
- const matchValue = parameter_1.Type;
232
- if (matchValue.tag === 2) {
233
- return new FSharpParameter(parameter_1.Attributes, parameter_1.Name, true, matchValue.fields[0]);
234
- }
235
- else {
236
- return parameter_1;
321
+ const typeLiteralInfo = glueType.fields[0];
322
+ if (forAll((_arg) => {
323
+ switch (_arg.tag) {
324
+ case 6:
325
+ case 1:
326
+ case 2:
327
+ case 3:
328
+ case 4:
329
+ case 0:
330
+ case 7:
331
+ return true;
332
+ default:
333
+ return false;
237
334
  }
238
- }, TransformMembers_toFSharpParameters(context, glueType.fields[0].Members)), {
239
- Compare: comparePrimitives,
240
- });
241
- const explicitFields = map((parameter_2) => (new FSharpExplicitField(parameter_2.Name, parameter_2.IsOptional ? (new FSharpType(2, [parameter_2.Type])) : parameter_2.Type)), typeLiteralParameters);
242
- TransformContext__ExposeType_Z1D58A540(context, new FSharpType(16, [new FSharpClass(ofArray([new FSharpAttribute(15, []), new FSharpAttribute(7, [])]), TransformContext__get_CurrentScopeName(context), empty(), new FSharpConstructor(typeLiteralParameters, ofArray([new FSharpAttribute(16, []), new FSharpAttribute(2, [])]), new FSharpAccessibility(0, [])), empty(), explicitFields)]));
335
+ }, typeLiteralInfo.Members)) {
336
+ const typeLiteralParameters = sortBy((_arg_1) => _arg_1.IsOptional, map((parameter_1) => {
337
+ const matchValue_1 = parameter_1.Type;
338
+ if (matchValue_1.tag === 2) {
339
+ return new FSharpParameter(parameter_1.Attributes, parameter_1.Name, true, matchValue_1.fields[0]);
340
+ }
341
+ else {
342
+ return parameter_1;
343
+ }
344
+ }, TransformMembers_toFSharpParameters(context, typeLiteralInfo.Members)), {
345
+ Compare: comparePrimitives,
346
+ });
347
+ const explicitFields = map((parameter_2) => (new FSharpExplicitField(parameter_2.Name, parameter_2.IsOptional ? (new FSharpType(2, [parameter_2.Type])) : parameter_2.Type)), typeLiteralParameters);
348
+ TransformContext__ExposeType_Z1D58A540(context, new FSharpType(16, [new FSharpClass(ofArray([new FSharpAttribute(17, []), new FSharpAttribute(8, [])]), TransformContext__get_CurrentScopeName(context), empty(), new FSharpConstructor(typeLiteralParameters, ofArray([new FSharpAttribute(18, []), new FSharpAttribute(2, [])]), new FSharpAccessibility(0, [])), empty(), explicitFields)]));
349
+ }
350
+ else {
351
+ TransformContext__ExposeType_Z1D58A540(context, new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), TransformContext__get_CurrentScopeName(context), "", empty(), TransformMembers_toFSharpMember(context, typeLiteralInfo.Members), empty())]));
352
+ }
243
353
  return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
244
354
  }
245
355
  case 25: {
@@ -253,12 +363,12 @@ function transformType(context_mut, glueType_mut) {
253
363
  continue transformType;
254
364
  }
255
365
  case 9: {
256
- const matchValue_1 = TypeAliasDeclaration_tryTransformKeyOf(TransformContext__get_CurrentScopeName(context), glueType.fields[0]);
257
- if (matchValue_1 == null) {
366
+ const matchValue_2 = TypeAliasDeclaration_tryTransformKeyOf(TransformContext__get_CurrentScopeName(context), glueType.fields[0]);
367
+ if (matchValue_2 == null) {
258
368
  return new FSharpType(17, []);
259
369
  }
260
370
  else {
261
- TransformContext__ExposeType_Z1D58A540(context, matchValue_1);
371
+ TransformContext__ExposeType_Z1D58A540(context, matchValue_2);
262
372
  return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
263
373
  }
264
374
  }
@@ -267,13 +377,17 @@ function transformType(context_mut, glueType_mut) {
267
377
  glueType_mut = glueType.fields[0].Type;
268
378
  continue transformType;
269
379
  }
380
+ case 14: {
381
+ TransformContext__ExposeType_Z1D58A540(context, new FSharpType(4, [(originalInterface = transformInterface(context, glueType.fields[0]), Interface_makePartial(TransformContext__get_CurrentScopeName(context), originalInterface))]));
382
+ return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
383
+ }
384
+ case 0:
385
+ return new FSharpType(17, []);
270
386
  case 11:
271
387
  case 10:
272
388
  case 8:
273
389
  case 4:
274
390
  case 5:
275
- case 0:
276
- case 14:
277
391
  case 21:
278
392
  case 6: {
279
393
  error(toText(interpolate("Could not transform type: %A%P()", [glueType])));
@@ -288,57 +402,61 @@ function transformType(context_mut, glueType_mut) {
288
402
 
289
403
  function transformExports(context, isTopLevel, exports) {
290
404
  const context_1 = TransformContext__PushScope_Z721C83C5(context, "Exports");
291
- return new FSharpType(4, [new FSharpInterface(singleton(new FSharpAttribute(6, [])), "Exports", "Exports", empty(), collect_1((_arg) => {
405
+ return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(6, [])]), "Exports", "Exports", empty(), collect_1((_arg) => {
292
406
  let Attributes_1, Parameters_1;
293
407
  switch (_arg.tag) {
294
408
  case 2: {
295
409
  const info = _arg.fields[0];
296
410
  const patternInput = sanitizeNameAndPushScope(info.Name, context_1);
297
- return singleton(new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(3, [info.Name, "REPLACE_ME_WITH_MODULE_NAME"])), patternInput[0], info.Name, empty(), empty(), transformType(patternInput[1], info.Type), false, true, void 0, new FSharpAccessibility(0, []), empty())]));
411
+ const xmlDocInfo = transformComment(info.Documentation);
412
+ return singleton(new FSharpMember(1, [new FSharpMemberInfo(toList(delay(() => append(singleton_1(new FSharpAttribute(3, [info.Name, "REPLACE_ME_WITH_MODULE_NAME"])), delay(() => xmlDocInfo.ObsoleteAttributes)))), patternInput[0], info.Name, empty(), empty(), transformType(patternInput[1], info.Type), false, true, void 0, new FSharpAccessibility(0, []), xmlDocInfo.XmlDoc, new FSharpMemberInfoBody(0, []))]));
298
413
  }
299
414
  case 6: {
300
415
  const info_1 = _arg.fields[0];
301
416
  const patternInput_1 = sanitizeNameAndPushScope(info_1.Name, context_1);
302
417
  const context_3 = patternInput_1[1];
303
- const xmlDocInfo = transformComment(info_1.Documentation);
304
- return singleton(new FSharpMember(0, [(Attributes_1 = toList(delay(() => append(singleton_1(new FSharpAttribute(3, [info_1.Name, "REPLACE_ME_WITH_MODULE_NAME"])), delay(() => xmlDocInfo.ObsoleteAttributes)))), (Parameters_1 = map((parameter) => transformParameter(context_3, parameter), info_1.Parameters), new FSharpMemberInfo(Attributes_1, patternInput_1[0], info_1.Name, transformTypeParameters(context_3, info_1.TypeParameters), Parameters_1, transformType(context_3, info_1.Type), false, true, void 0, new FSharpAccessibility(0, []), xmlDocInfo.Others)))]));
418
+ const xmlDocInfo_1 = transformComment(info_1.Documentation);
419
+ return singleton(new FSharpMember(0, [(Attributes_1 = toList(delay(() => append(isTopLevel ? singleton_1(new FSharpAttribute(3, [info_1.Name, "REPLACE_ME_WITH_MODULE_NAME"])) : singleton_1(new FSharpAttribute(15, [info_1.Name])), delay(() => xmlDocInfo_1.ObsoleteAttributes)))), (Parameters_1 = map((parameter) => transformParameter(context_3, parameter), info_1.Parameters), new FSharpMemberInfo(Attributes_1, patternInput_1[0], info_1.Name, transformTypeParameters(context_3, info_1.TypeParameters), Parameters_1, transformType(context_3, info_1.Type), false, isTopLevel, void 0, new FSharpAccessibility(0, []), xmlDocInfo_1.XmlDoc, new FSharpMemberInfoBody(0, []))))]));
305
420
  }
306
421
  case 12: {
307
422
  const info_2 = _arg.fields[0];
308
423
  const patternInput_2 = sanitizeNameAndPushScope(info_2.Name, context_1);
309
424
  const context_4 = patternInput_2[1];
310
- return map((_arg_1) => {
425
+ return map((constructorInfo) => {
311
426
  let Attributes_2, Parameters_2;
312
- return new FSharpMember(0, [(Attributes_2 = toList(delay(() => (isTopLevel ? append(singleton_1(new FSharpAttribute(3, [info_2.Name, "REPLACE_ME_WITH_MODULE_NAME"])), delay(() => singleton_1(new FSharpAttribute(12, [])))) : singleton_1(new FSharpAttribute(13, [info_2.Name]))))), (Parameters_2 = map((parameter_1) => transformParameter(context_4, parameter_1), _arg_1.fields[0]), new FSharpMemberInfo(Attributes_2, patternInput_2[0], info_2.Name, transformTypeParameters(context_4, info_2.TypeParameters), Parameters_2, new FSharpType(6, [new FSharpMapped(sanitizeName(info_2.Name), empty())]), false, true, void 0, new FSharpAccessibility(0, []), empty())))]);
313
- }, isEmpty(info_2.Constructors) ? singleton(new GlueConstructor(empty())) : info_2.Constructors);
427
+ const xmlDocInfo_2 = transformComment(constructorInfo.Documentation);
428
+ return new FSharpMember(0, [(Attributes_2 = toList(delay(() => append(isTopLevel ? append(singleton_1(new FSharpAttribute(3, [info_2.Name, "REPLACE_ME_WITH_MODULE_NAME"])), delay(() => singleton_1(new FSharpAttribute(13, [])))) : singleton_1(new FSharpAttribute(14, [info_2.Name])), delay(() => xmlDocInfo_2.ObsoleteAttributes)))), (Parameters_2 = map((parameter_1) => transformParameter(context_4, parameter_1), constructorInfo.Parameters), new FSharpMemberInfo(Attributes_2, patternInput_2[0], info_2.Name, transformTypeParameters(context_4, info_2.TypeParameters), Parameters_2, new FSharpType(6, [new FSharpMapped(sanitizeName(info_2.Name), empty(), transformTypeParameters(context_4, info_2.TypeParameters))]), false, isTopLevel, void 0, new FSharpAccessibility(0, []), xmlDocInfo_2.XmlDoc, new FSharpMemberInfoBody(0, []))))]);
429
+ }, isEmpty(info_2.Constructors) ? singleton(new GlueConstructor(empty(), empty())) : info_2.Constructors);
314
430
  }
315
431
  case 11: {
316
432
  const moduleDeclaration = _arg.fields[0];
317
433
  return choose((typ) => {
318
- if (typ.tag === 12) {
319
- return new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(4, ["REPLACE_ME_WITH_MODULE_NAME"])), moduleDeclaration.Name + "_", moduleDeclaration.Name, empty(), empty(), new FSharpType(6, [new FSharpMapped(`${moduleDeclaration.Name}.Exports`, empty())]), false, true, new FSharpAccessor(0, []), new FSharpAccessibility(0, []), empty())]);
320
- }
321
- else {
322
- return void 0;
434
+ switch (typ.tag) {
435
+ case 12:
436
+ return new FSharpMember(1, [new FSharpMemberInfo(ofArray([new FSharpAttribute(4, ["REPLACE_ME_WITH_MODULE_NAME"]), new FSharpAttribute(0, [`Emit("$0.${moduleDeclaration.Name}")`])]), moduleDeclaration.Name + "_", moduleDeclaration.Name, empty(), empty(), new FSharpType(6, [new FSharpMapped(`${moduleDeclaration.Name}.Exports`, empty(), empty())]), false, true, new FSharpAccessor(0, []), new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]);
437
+ case 6:
438
+ return new FSharpMember(1, [new FSharpMemberInfo(ofArray([new FSharpAttribute(4, ["REPLACE_ME_WITH_MODULE_NAME"]), new FSharpAttribute(0, [`Emit("$0.${moduleDeclaration.Name}")`])]), moduleDeclaration.Name + "_", `${moduleDeclaration.Name}.Exports`, empty(), empty(), new FSharpType(6, [new FSharpMapped(`${moduleDeclaration.Name}.Exports`, empty(), empty())]), false, isTopLevel, new FSharpAccessor(0, []), new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]);
439
+ default:
440
+ return void 0;
323
441
  }
324
442
  }, moduleDeclaration.Types);
325
443
  }
326
444
  case 25: {
327
445
  const glueType = _arg.fields[0];
328
446
  const patternInput_3 = sanitizeNameAndPushScope(GlueType__get_Name(glueType), context_1);
329
- return singleton(new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(5, ["REPLACE_ME_WITH_MODULE_NAME"])), patternInput_3[0], GlueType__get_Name(glueType), empty(), empty(), transformType(patternInput_3[1], glueType), false, true, void 0, new FSharpAccessibility(0, []), empty())]));
447
+ return singleton(new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(5, ["REPLACE_ME_WITH_MODULE_NAME"])), patternInput_3[0], GlueType__get_Name(glueType), empty(), empty(), transformType(patternInput_3[1], glueType), false, true, void 0, new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]));
330
448
  }
331
449
  default:
332
450
  return toFail(printf("Could not generate exportMembers for: %A"))(_arg);
333
451
  }
334
- }, exports))]);
452
+ }, exports), empty())]);
335
453
  }
336
454
 
337
455
  function transformParameter(context, parameter) {
338
456
  let typ;
339
457
  const computedType = transformType(TransformContext__PushScope_Z721C83C5(context, parameter.Name), parameter.Type);
340
458
  typ = (parameter.IsSpread ? ((computedType.tag === 13) ? computedType.fields[0] : computedType) : computedType);
341
- return new FSharpParameter(toList(delay(() => (parameter.IsSpread ? singleton_1(new FSharpAttribute(17, [])) : empty_1()))), sanitizeName(parameter.Name), parameter.IsOptional, typ);
459
+ return new FSharpParameter(toList(delay(() => (parameter.IsSpread ? singleton_1(new FSharpAttribute(19, [])) : empty_1()))), sanitizeName(parameter.Name), parameter.IsOptional, typ);
342
460
  }
343
461
 
344
462
  function transformAccessor(accessor) {
@@ -353,45 +471,61 @@ function transformAccessor(accessor) {
353
471
  }
354
472
 
355
473
  function TransformMembers_toFSharpMember(context, members) {
356
- return choose((_arg) => {
357
- switch (_arg.tag) {
358
- case 2: {
359
- const callSignatureInfo = _arg.fields[0];
474
+ return choose((_arg_3) => {
475
+ switch (_arg_3.tag) {
476
+ case 4: {
477
+ const callSignatureInfo = _arg_3.fields[0];
360
478
  const patternInput_1 = sanitizeNameAndPushScope("Invoke", context);
361
479
  const context_2 = patternInput_1[1];
362
- return new FSharpMember(0, [new FSharpMemberInfo(singleton(new FSharpAttribute(1, [])), patternInput_1[0], "Invoke", empty(), map((parameter_2) => transformParameter(context_2, parameter_2), callSignatureInfo.Parameters), transformType(context_2, callSignatureInfo.Type), false, false, void 0, new FSharpAccessibility(0, []), empty())]);
480
+ return new FSharpMember(0, [new FSharpMemberInfo(singleton(new FSharpAttribute(1, [])), patternInput_1[0], "Invoke", empty(), map((parameter_2) => transformParameter(context_2, parameter_2), callSignatureInfo.Parameters), transformType(context_2, callSignatureInfo.Type), false, false, void 0, new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]);
363
481
  }
364
482
  case 1: {
365
- const propertyInfo = _arg.fields[0];
483
+ const propertyInfo = _arg_3.fields[0];
366
484
  const patternInput_2 = sanitizeNameAndPushScope(propertyInfo.Name, context);
367
485
  const xmlDocInfo = transformComment(propertyInfo.Documentation);
368
486
  if (propertyInfo.IsPrivate && !propertyInfo.IsStatic) {
369
487
  return void 0;
370
488
  }
371
489
  else {
372
- return new FSharpMember(1, [new FSharpMemberInfo(toList(delay(() => xmlDocInfo.ObsoleteAttributes)), patternInput_2[0], propertyInfo.Name, empty(), empty(), transformType(patternInput_2[1], propertyInfo.Type), propertyInfo.IsOptional, propertyInfo.IsStatic, transformAccessor(propertyInfo.Accessor), propertyInfo.IsPrivate ? (new FSharpAccessibility(1, [])) : (new FSharpAccessibility(0, [])), xmlDocInfo.Others)]);
490
+ let typ;
491
+ const typ$0027 = transformType(patternInput_2[1], propertyInfo.Type);
492
+ typ = (propertyInfo.IsOptional ? ((typ$0027.tag === 2) ? typ$0027.fields[0] : typ$0027) : typ$0027);
493
+ return new FSharpMember(1, [new FSharpMemberInfo(toList(delay(() => xmlDocInfo.ObsoleteAttributes)), patternInput_2[0], propertyInfo.Name, empty(), empty(), typ, propertyInfo.IsOptional, propertyInfo.IsStatic, transformAccessor(propertyInfo.Accessor), propertyInfo.IsPrivate ? (new FSharpAccessibility(1, [])) : (new FSharpAccessibility(0, [])), xmlDocInfo.XmlDoc, new FSharpMemberInfoBody(1, []))]);
373
494
  }
374
495
  }
375
- case 3: {
376
- const indexSignature = _arg.fields[0];
377
- const patternInput_3 = sanitizeNameAndPushScope("Item", context);
378
- const context_4 = patternInput_3[1];
379
- return new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(14, [])), patternInput_3[0], "Item", empty(), map((parameter_3) => transformParameter(context_4, parameter_3), indexSignature.Parameters), transformType(context_4, indexSignature.Type), false, false, new FSharpAccessor(2, []), new FSharpAccessibility(0, []), empty())]);
496
+ case 2: {
497
+ const getAccessorInfo_1 = _arg_3.fields[0];
498
+ const patternInput_3 = sanitizeNameAndPushScope(getAccessorInfo_1.Name, context);
499
+ const xmlDocInfo_1 = transformComment(getAccessorInfo_1.Documentation);
500
+ return new FSharpMember(1, [new FSharpMemberInfo(toList(delay(() => xmlDocInfo_1.ObsoleteAttributes)), patternInput_3[0], getAccessorInfo_1.Name, empty(), empty(), transformType(patternInput_3[1], getAccessorInfo_1.Type), false, getAccessorInfo_1.IsStatic, new FSharpAccessor(0, []), new FSharpAccessibility(0, []), xmlDocInfo_1.XmlDoc, new FSharpMemberInfoBody(0, []))]);
380
501
  }
381
- case 4: {
382
- const methodSignature = _arg.fields[0];
383
- const patternInput_4 = sanitizeNameAndPushScope(methodSignature.Name, context);
384
- const context_5 = patternInput_4[1];
385
- return new FSharpMember(0, [new FSharpMemberInfo(empty(), patternInput_4[0], methodSignature.Name, empty(), map((parameter_4) => transformParameter(context_5, parameter_4), methodSignature.Parameters), transformType(context_5, methodSignature.Type), false, false, void 0, new FSharpAccessibility(0, []), empty())]);
502
+ case 3: {
503
+ const setAccessorInfo_1 = _arg_3.fields[0];
504
+ const patternInput_4 = sanitizeNameAndPushScope(setAccessorInfo_1.Name, context);
505
+ const xmlDocInfo_2 = transformComment(setAccessorInfo_1.Documentation);
506
+ return new FSharpMember(1, [new FSharpMemberInfo(toList(delay(() => xmlDocInfo_2.ObsoleteAttributes)), patternInput_4[0], setAccessorInfo_1.Name, empty(), empty(), transformType(patternInput_4[1], setAccessorInfo_1.ArgumentType), false, setAccessorInfo_1.IsStatic, new FSharpAccessor(1, []), new FSharpAccessibility(0, []), xmlDocInfo_2.XmlDoc, new FSharpMemberInfoBody(0, []))]);
386
507
  }
387
508
  case 5: {
388
- const constructSignature = _arg.fields[0];
389
- const patternInput_5 = sanitizeNameAndPushScope("Create", context);
509
+ const indexSignature = _arg_3.fields[0];
510
+ const patternInput_5 = sanitizeNameAndPushScope("Item", context);
390
511
  const context_6 = patternInput_5[1];
391
- return new FSharpMember(0, [new FSharpMemberInfo(singleton(new FSharpAttribute(12, [])), patternInput_5[0], "Create", empty(), map((parameter_5) => transformParameter(context_6, parameter_5), constructSignature.Parameters), transformType(context_6, constructSignature.Type), false, false, void 0, new FSharpAccessibility(0, []), empty())]);
512
+ return new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(16, [])), patternInput_5[0], "Item", empty(), map((parameter_3) => transformParameter(context_6, parameter_3), indexSignature.Parameters), transformType(context_6, indexSignature.Type), false, false, new FSharpAccessor(2, []), new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]);
513
+ }
514
+ case 6: {
515
+ const methodSignature = _arg_3.fields[0];
516
+ const patternInput_6 = sanitizeNameAndPushScope(methodSignature.Name, context);
517
+ const context_7 = patternInput_6[1];
518
+ const xmlDocInfo_3 = transformComment(methodSignature.Documentation);
519
+ return new FSharpMember(0, [new FSharpMemberInfo(toList(delay(() => xmlDocInfo_3.ObsoleteAttributes)), patternInput_6[0], methodSignature.Name, empty(), map((parameter_4) => transformParameter(context_7, parameter_4), methodSignature.Parameters), transformType(context_7, methodSignature.Type), false, false, void 0, new FSharpAccessibility(0, []), xmlDocInfo_3.XmlDoc, new FSharpMemberInfoBody(0, []))]);
520
+ }
521
+ case 7: {
522
+ const constructSignature = _arg_3.fields[0];
523
+ const patternInput_7 = sanitizeNameAndPushScope("Create", context);
524
+ const context_8 = patternInput_7[1];
525
+ return new FSharpMember(0, [new FSharpMemberInfo(singleton(new FSharpAttribute(13, [])), patternInput_7[0], "Create", empty(), map((parameter_5) => transformParameter(context_8, parameter_5), constructSignature.Parameters), transformType(context_8, constructSignature.Type), false, false, void 0, new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]);
392
526
  }
393
527
  default: {
394
- const methodInfo = _arg.fields[0];
528
+ const methodInfo = _arg_3.fields[0];
395
529
  const patternInput = sanitizeNameAndPushScope(methodInfo.Name, context);
396
530
  const name = patternInput[0];
397
531
  const context_1 = patternInput[1];
@@ -399,11 +533,59 @@ function TransformMembers_toFSharpMember(context, members) {
399
533
  return new FSharpMember(2, [new FSharpStaticMemberInfo(empty(), name, methodInfo.Name, empty(), map((parameter) => transformParameter(context_1, parameter), methodInfo.Parameters), transformType(context_1, methodInfo.Type), methodInfo.IsOptional, void 0, new FSharpAccessibility(0, []))]);
400
534
  }
401
535
  else {
402
- return new FSharpMember(0, [new FSharpMemberInfo(empty(), name, methodInfo.Name, empty(), map((parameter_1) => transformParameter(context_1, parameter_1), methodInfo.Parameters), transformType(context_1, methodInfo.Type), methodInfo.IsOptional, methodInfo.IsStatic, void 0, new FSharpAccessibility(0, []), empty())]);
536
+ return new FSharpMember(0, [new FSharpMemberInfo(empty(), name, methodInfo.Name, empty(), map((parameter_1) => transformParameter(context_1, parameter_1), methodInfo.Parameters), transformType(context_1, methodInfo.Type), methodInfo.IsOptional, methodInfo.IsStatic, void 0, new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]);
403
537
  }
404
538
  }
405
539
  }
406
- }, members);
540
+ }, choose((_arg) => {
541
+ switch (_arg.tag) {
542
+ case 3: {
543
+ const associatedGetAccessor = tryFind((_arg_2) => {
544
+ if (_arg_2.tag === 2) {
545
+ return _arg.fields[0].Name === _arg_2.fields[0].Name;
546
+ }
547
+ else {
548
+ return false;
549
+ }
550
+ }, members);
551
+ if (associatedGetAccessor == null) {
552
+ return _arg;
553
+ }
554
+ else {
555
+ return void 0;
556
+ }
557
+ }
558
+ case 4:
559
+ return _arg;
560
+ case 0:
561
+ return _arg;
562
+ case 1:
563
+ return _arg;
564
+ case 5:
565
+ return _arg;
566
+ case 6:
567
+ return _arg;
568
+ case 7:
569
+ return _arg;
570
+ default: {
571
+ const getAccessorInfo = _arg.fields[0];
572
+ const associatedSetAccessor = tryFind((_arg_1) => {
573
+ if (_arg_1.tag === 3) {
574
+ return getAccessorInfo.Name === _arg_1.fields[0].Name;
575
+ }
576
+ else {
577
+ return false;
578
+ }
579
+ }, members);
580
+ if (associatedSetAccessor == null) {
581
+ return _arg;
582
+ }
583
+ else {
584
+ return new GlueMember(1, [new GlueProperty(getAccessorInfo.Name, getAccessorInfo.Documentation, getAccessorInfo.Type, getAccessorInfo.IsStatic, false, new GlueAccessor(2, []), getAccessorInfo.IsPrivate)]);
585
+ }
586
+ }
587
+ }
588
+ }, members));
407
589
  }
408
590
 
409
591
  function TransformMembers_toFSharpParameters(context, members) {
@@ -414,22 +596,32 @@ function TransformMembers_toFSharpParameters(context, members) {
414
596
  const patternInput_1 = sanitizeNameAndPushScope(propertyInfo.Name, context);
415
597
  return new FSharpParameter(empty(), patternInput_1[0], propertyInfo.IsOptional, transformType(patternInput_1[1], propertyInfo.Type));
416
598
  }
599
+ case 2: {
600
+ const getAccessorInfo = _arg.fields[0];
601
+ const patternInput_2 = sanitizeNameAndPushScope(getAccessorInfo.Name, context);
602
+ return new FSharpParameter(empty(), patternInput_2[0], false, transformType(patternInput_2[1], getAccessorInfo.Type));
603
+ }
417
604
  case 3: {
418
- const patternInput_2 = sanitizeNameAndPushScope("Item", context);
419
- return new FSharpParameter(empty(), patternInput_2[0], false, transformType(patternInput_2[1], _arg.fields[0].Type));
605
+ const setAccessorInfo = _arg.fields[0];
606
+ const patternInput_3 = sanitizeNameAndPushScope(setAccessorInfo.Name, context);
607
+ return new FSharpParameter(empty(), patternInput_3[0], false, transformType(patternInput_3[1], setAccessorInfo.ArgumentType));
420
608
  }
421
- case 4: {
609
+ case 5: {
610
+ const patternInput_4 = sanitizeNameAndPushScope("Item", context);
611
+ return new FSharpParameter(empty(), patternInput_4[0], false, transformType(patternInput_4[1], _arg.fields[0].Type));
612
+ }
613
+ case 6: {
422
614
  const methodSignature = _arg.fields[0];
423
- const patternInput_3 = sanitizeNameAndPushScope(methodSignature.Name, context);
424
- return new FSharpParameter(empty(), patternInput_3[0], false, transformType(patternInput_3[1], methodSignature.Type));
615
+ const patternInput_5 = sanitizeNameAndPushScope(methodSignature.Name, context);
616
+ return new FSharpParameter(empty(), patternInput_5[0], false, transformType(patternInput_5[1], methodSignature.Type));
425
617
  }
426
- case 2: {
427
- const patternInput_4 = sanitizeNameAndPushScope("Invoke", context);
428
- return new FSharpParameter(empty(), patternInput_4[0], false, transformType(patternInput_4[1], _arg.fields[0].Type));
618
+ case 4: {
619
+ const patternInput_6 = sanitizeNameAndPushScope("Invoke", context);
620
+ return new FSharpParameter(empty(), patternInput_6[0], false, transformType(patternInput_6[1], _arg.fields[0].Type));
429
621
  }
430
- case 5: {
431
- const patternInput_5 = sanitizeNameAndPushScope("Create", context);
432
- return new FSharpParameter(empty(), patternInput_5[0], false, transformType(patternInput_5[1], _arg.fields[0].Type));
622
+ case 7: {
623
+ const patternInput_7 = sanitizeNameAndPushScope("Create", context);
624
+ return new FSharpParameter(empty(), patternInput_7[0], false, transformType(patternInput_7[1], _arg.fields[0].Type));
433
625
  }
434
626
  default: {
435
627
  const methodInfo = _arg.fields[0];
@@ -444,7 +636,26 @@ function transformInterface(context, info) {
444
636
  const patternInput = sanitizeNameAndPushScope(info.Name, context);
445
637
  const context_1 = patternInput[1];
446
638
  const Members = TransformMembers_toFSharpMember(context_1, info.Members);
447
- return new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), patternInput[0], info.Name, transformTypeParameters(context_1, info.TypeParameters), Members);
639
+ return new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), patternInput[0], info.Name, transformTypeParameters(context_1, info.TypeParameters), Members, map((glueType) => transformType(context_1, glueType), info.HeritageClauses));
640
+ }
641
+
642
+ export function Interface_makePartial(name, originalInterface) {
643
+ return new FSharpInterface(originalInterface.Attributes, name, originalInterface.OriginalName, originalInterface.TypeParameters, map((m) => {
644
+ switch (m.tag) {
645
+ case 1: {
646
+ const property = m.fields[0];
647
+ return new FSharpMember(1, [new FSharpMemberInfo(property.Attributes, property.Name, property.OriginalName, property.TypeParameters, property.Parameters, property.Type, true, property.IsStatic, property.Accessor, property.Accessibility, property.XmlDoc, property.Body)]);
648
+ }
649
+ case 2: {
650
+ const staticMember = m.fields[0];
651
+ return new FSharpMember(2, [new FSharpStaticMemberInfo(staticMember.Attributes, staticMember.Name, staticMember.OriginalName, staticMember.TypeParameters, staticMember.Parameters, staticMember.Type, true, staticMember.Accessor, staticMember.Accessibility)]);
652
+ }
653
+ default: {
654
+ const method = m.fields[0];
655
+ return new FSharpMember(0, [new FSharpMemberInfo(method.Attributes, method.Name, method.OriginalName, method.TypeParameters, method.Parameters, method.Type, true, method.IsStatic, method.Accessor, method.Accessibility, method.XmlDoc, method.Body)]);
656
+ }
657
+ }
658
+ }, originalInterface.Members), originalInterface.Inheritance);
448
659
  }
449
660
 
450
661
  function transformEnum(glueEnum) {
@@ -472,7 +683,7 @@ function transformEnum(glueEnum) {
472
683
  throw new Error(`Empty enum: ${glueEnum.Name}`);
473
684
  }
474
685
  else {
475
- return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(11, []), new FSharpAttribute(9, [0])]), sanitizeName(glueEnum.Name), List_distinct(map((glueMember_1) => {
686
+ return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(12, []), new FSharpAttribute(10, [0])]), sanitizeName(glueEnum.Name), List_distinct(map((glueMember_1) => {
476
687
  let caseValue;
477
688
  const matchValue_3 = glueMember_1.Value;
478
689
  if (matchValue_3.tag === 0) {
@@ -482,7 +693,7 @@ function transformEnum(glueEnum) {
482
693
  throw new Error("Should not happen");
483
694
  }
484
695
  const caseName = sanitizeName(glueMember_1.Name);
485
- return new FSharpUnionCase(toList(delay(() => ((caseName !== caseValue) ? singleton_1(new FSharpAttribute(10, [removeSurroundingQuotes(caseValue)])) : empty_1()))), caseName);
696
+ return new FSharpUnionCase(toList(delay(() => ((caseName !== caseValue) ? singleton_1(new FSharpAttribute(11, [removeSurroundingQuotes(caseValue)])) : empty_1()))), caseName);
486
697
  }, stringValues), {
487
698
  Equals: equals,
488
699
  GetHashCode: safeHash,
@@ -508,13 +719,13 @@ export function TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType) {
508
719
  let sanitizeResult;
509
720
  let matchResult, caseName;
510
721
  switch (m.tag) {
511
- case 2:
512
- case 5:
513
- case 3: {
722
+ case 4:
723
+ case 7:
724
+ case 5: {
514
725
  matchResult = 1;
515
726
  break;
516
727
  }
517
- case 4: {
728
+ case 6: {
518
729
  matchResult = 0;
519
730
  caseName = m.fields[0].Name;
520
731
  break;
@@ -524,6 +735,16 @@ export function TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType) {
524
735
  caseName = m.fields[0].Name;
525
736
  break;
526
737
  }
738
+ case 2: {
739
+ matchResult = 0;
740
+ caseName = m.fields[0].Name;
741
+ break;
742
+ }
743
+ case 3: {
744
+ matchResult = 0;
745
+ caseName = m.fields[0].Name;
746
+ break;
747
+ }
527
748
  default: {
528
749
  matchResult = 0;
529
750
  caseName = m.fields[0].Name;
@@ -531,7 +752,7 @@ export function TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType) {
531
752
  }
532
753
  switch (matchResult) {
533
754
  case 0:
534
- return (sanitizeResult = sanitizeNameWithResult(caseName), new FSharpUnionCase(toList(delay(() => (sanitizeResult.IsDifferent ? singleton_1(new FSharpAttribute(10, [removeSurroundingQuotes(caseName)])) : empty_1()))), sanitizeResult.Name));
755
+ return (sanitizeResult = sanitizeNameWithResult(caseName), new FSharpUnionCase(toList(delay(() => (sanitizeResult.IsDifferent ? singleton_1(new FSharpAttribute(11, [removeSurroundingQuotes(caseName)])) : empty_1()))), sanitizeResult.Name));
535
756
  default:
536
757
  return void 0;
537
758
  }
@@ -540,7 +761,7 @@ export function TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType) {
540
761
  return void 0;
541
762
  }
542
763
  else {
543
- return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(11, []), new FSharpAttribute(9, [0])]), sanitizeName(aliasName), cases, false)]);
764
+ return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(12, []), new FSharpAttribute(10, [0])]), sanitizeName(aliasName), cases, false)]);
544
765
  }
545
766
  }
546
767
 
@@ -555,8 +776,8 @@ export function TypeAliasDeclaration_transformKeyOf(aliasName, glueType) {
555
776
  }
556
777
  }
557
778
 
558
- export function TypeAliasDeclaration_transformLiteral(typeAliasName, literalInfo) {
559
- const makeTypeAlias = (primitiveType) => (new FSharpType(8, [new FSharpTypeAlias(typeAliasName, new FSharpType(7, [primitiveType]), empty())]));
779
+ export function TypeAliasDeclaration_transformLiteral(xmlDoc, typeAliasName, literalInfo) {
780
+ const makeTypeAlias = (primitiveType) => (new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(7, [primitiveType]), empty())]));
560
781
  switch (literalInfo.tag) {
561
782
  case 1:
562
783
  return makeTypeAlias(new FSharpPrimitive(1, []));
@@ -567,7 +788,7 @@ export function TypeAliasDeclaration_transformLiteral(typeAliasName, literalInfo
567
788
  case 4:
568
789
  return makeTypeAlias(new FSharpPrimitive(6, []));
569
790
  default:
570
- return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(11, []), new FSharpAttribute(9, [0])]), typeAliasName, singleton(new FSharpUnionCase(empty(), sanitizeName(literalInfo.fields[0]))), false)]);
791
+ return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(12, []), new FSharpAttribute(10, [0])]), typeAliasName, singleton(new FSharpUnionCase(empty(), sanitizeName(literalInfo.fields[0]))), false)]);
571
792
  }
572
793
  }
573
794
 
@@ -575,62 +796,216 @@ function transformTypeParameters(context, typeParameters) {
575
796
  return map((typeParameter) => FSharpTypeParameter_Create_Z6CFD3565(typeParameter.Name, unwrap(map_1((glueType) => transformType(context, glueType), typeParameter.Constraint)), unwrap(map_1((glueType_1) => transformType(context, glueType_1), typeParameter.Default))), typeParameters);
576
797
  }
577
798
 
799
+ function tryOptimizeUnionType(context, typeName, cases) {
800
+ const flattenCases = (cases_1) => collect_1((_arg) => {
801
+ switch (_arg.tag) {
802
+ case 8:
803
+ return singleton(_arg);
804
+ case 7:
805
+ return flattenCases(_arg.fields[0].fields[0]);
806
+ case 5: {
807
+ const matchValue = _arg.fields[0].Type;
808
+ if (matchValue.tag === 7) {
809
+ return flattenCases(matchValue.fields[0].fields[0]);
810
+ }
811
+ else {
812
+ return empty();
813
+ }
814
+ }
815
+ default:
816
+ return empty();
817
+ }
818
+ }, cases_1);
819
+ const flattenedCases = flattenCases(cases);
820
+ const isStringOnly = !isEmpty(flattenedCases) && forAll((_arg_1) => {
821
+ let matchResult;
822
+ if (_arg_1.tag === 8) {
823
+ if (_arg_1.fields[0].tag === 0) {
824
+ matchResult = 0;
825
+ }
826
+ else {
827
+ matchResult = 1;
828
+ }
829
+ }
830
+ else {
831
+ matchResult = 1;
832
+ }
833
+ switch (matchResult) {
834
+ case 0:
835
+ return true;
836
+ default:
837
+ return false;
838
+ }
839
+ }, flattenedCases);
840
+ const isNumericOnly = !isEmpty(flattenedCases) && forAll((_arg_2) => {
841
+ let matchResult_1;
842
+ if (_arg_2.tag === 8) {
843
+ if (_arg_2.fields[0].tag === 1) {
844
+ matchResult_1 = 0;
845
+ }
846
+ else {
847
+ matchResult_1 = 1;
848
+ }
849
+ }
850
+ else {
851
+ matchResult_1 = 1;
852
+ }
853
+ switch (matchResult_1) {
854
+ case 0:
855
+ return true;
856
+ default:
857
+ return false;
858
+ }
859
+ }, flattenedCases);
860
+ if (isStringOnly) {
861
+ return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(12, []), new FSharpAttribute(10, [0])]), typeName, List_distinct(map((value) => {
862
+ let matchResult_2, value_1;
863
+ if (value.tag === 8) {
864
+ if (value.fields[0].tag === 0) {
865
+ matchResult_2 = 0;
866
+ value_1 = value.fields[0].fields[0];
867
+ }
868
+ else {
869
+ matchResult_2 = 1;
870
+ }
871
+ }
872
+ else {
873
+ matchResult_2 = 1;
874
+ }
875
+ switch (matchResult_2) {
876
+ case 0: {
877
+ const sanitizeResult = sanitizeNameWithResult(value_1);
878
+ return new FSharpUnionCase(toList(delay(() => (sanitizeResult.IsDifferent ? singleton_1(new FSharpAttribute(11, [removeSurroundingQuotes(value_1)])) : empty_1()))), sanitizeResult.Name);
879
+ }
880
+ default:
881
+ throw new Error("Should not happen");
882
+ }
883
+ }, flattenedCases), {
884
+ Equals: equals,
885
+ GetHashCode: safeHash,
886
+ }), false)]);
887
+ }
888
+ else if (isNumericOnly) {
889
+ return new FSharpType(0, [new FSharpEnum(typeName, List_distinct(map((value_2) => {
890
+ let matchResult_3, value_3;
891
+ if (value_2.tag === 8) {
892
+ if (value_2.fields[0].tag === 1) {
893
+ matchResult_3 = 0;
894
+ value_3 = value_2.fields[0].fields[0];
895
+ }
896
+ else {
897
+ matchResult_3 = 1;
898
+ }
899
+ }
900
+ else {
901
+ matchResult_3 = 1;
902
+ }
903
+ switch (matchResult_3) {
904
+ case 0:
905
+ return new FSharpEnumCase(int32ToString(value_3), new FSharpLiteral(1, [value_3]));
906
+ default:
907
+ throw new Error("Should not happen");
908
+ }
909
+ }, flattenedCases), {
910
+ Equals: equals,
911
+ GetHashCode: safeHash,
912
+ }))]);
913
+ }
914
+ else if (forAll((_arg_3) => {
915
+ if (_arg_3.tag === 22) {
916
+ return true;
917
+ }
918
+ else {
919
+ return false;
920
+ }
921
+ }, cases)) {
922
+ const members = collect_1((_arg_4) => {
923
+ if (_arg_4.tag === 22) {
924
+ return TransformMembers_toFSharpMember(context, _arg_4.fields[0].Members);
925
+ }
926
+ else {
927
+ return empty();
928
+ }
929
+ }, cases);
930
+ return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), typeName, TransformContext__get_CurrentScopeName(context), empty(), members, empty())]);
931
+ }
932
+ else {
933
+ return void 0;
934
+ }
935
+ }
936
+
578
937
  function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
579
- let glueType_2;
580
938
  const patternInput = sanitizeNameAndPushScope(glueTypeAliasDeclaration.Name, context);
581
939
  const typeAliasName = patternInput[0];
582
940
  const context_1 = patternInput[1];
941
+ const xmlDoc = transformComment(glueTypeAliasDeclaration.Documentation);
583
942
  const matchValue = glueTypeAliasDeclaration.Type;
584
943
  switch (matchValue.tag) {
585
944
  case 9:
586
945
  return TypeAliasDeclaration_transformKeyOf(glueTypeAliasDeclaration.Name, matchValue.fields[0]);
587
946
  case 10: {
588
947
  const glueType_1 = matchValue.fields[0];
589
- return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, (glueType_1.tag === 9) ? ((glueType_2 = glueType_1.fields[0], (glueType_2.tag === 1) ? transformType(context_1, new GlueType(7, [new GlueTypeUnion(List_distinct(collect_1((m) => {
590
- let typ;
591
- switch (m.tag) {
592
- case 1: {
593
- typ = m.fields[0].Type;
594
- break;
595
- }
596
- case 2: {
597
- typ = m.fields[0].Type;
598
- break;
599
- }
600
- case 5: {
601
- typ = m.fields[0].Type;
602
- break;
948
+ let typ_2;
949
+ if (glueType_1.tag === 9) {
950
+ const glueType_2 = glueType_1.fields[0];
951
+ typ_2 = ((glueType_2.tag === 1) ? transformType(context_1, new GlueType(7, [new GlueTypeUnion(List_distinct(collect_1((m) => {
952
+ let typ_1;
953
+ switch (m.tag) {
954
+ case 1: {
955
+ typ_1 = m.fields[0].Type;
956
+ break;
957
+ }
958
+ case 2: {
959
+ typ_1 = m.fields[0].Type;
960
+ break;
961
+ }
962
+ case 3: {
963
+ typ_1 = m.fields[0].ArgumentType;
964
+ break;
965
+ }
966
+ case 4: {
967
+ typ_1 = m.fields[0].Type;
968
+ break;
969
+ }
970
+ case 7: {
971
+ typ_1 = m.fields[0].Type;
972
+ break;
973
+ }
974
+ case 6: {
975
+ typ_1 = m.fields[0].Type;
976
+ break;
977
+ }
978
+ case 5: {
979
+ typ_1 = m.fields[0].Type;
980
+ break;
981
+ }
982
+ default:
983
+ typ_1 = m.fields[0].Type;
603
984
  }
604
- case 4: {
605
- typ = m.fields[0].Type;
606
- break;
985
+ if (typ_1.tag === 7) {
986
+ return typ_1.fields[0].fields[0];
607
987
  }
608
- case 3: {
609
- typ = m.fields[0].Type;
610
- break;
988
+ else {
989
+ return singleton(typ_1);
611
990
  }
612
- default:
613
- typ = m.fields[0].Type;
614
- }
615
- if (typ.tag === 7) {
616
- return typ.fields[0].fields[0];
617
- }
618
- else {
619
- return singleton(typ);
620
- }
621
- }, glueType_2.fields[0].Members), {
622
- Equals: equals,
623
- GetHashCode: safeHash,
624
- }))])) : (new FSharpType(9, [])))) : (new FSharpType(9, [])), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
991
+ }, glueType_2.fields[0].Members), {
992
+ Equals: equals,
993
+ GetHashCode: safeHash,
994
+ }))])) : (new FSharpType(9, [])));
995
+ }
996
+ else {
997
+ typ_2 = (new FSharpType(9, []));
998
+ }
999
+ return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, typ_2, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
625
1000
  }
626
1001
  case 8:
627
- return TypeAliasDeclaration_transformLiteral(typeAliasName, matchValue.fields[0]);
1002
+ return TypeAliasDeclaration_transformLiteral(xmlDoc, typeAliasName, matchValue.fields[0]);
628
1003
  case 3:
629
- return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, new FSharpType(7, [transformPrimitive(matchValue.fields[0])]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
1004
+ return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(7, [transformPrimitive(matchValue.fields[0])]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
630
1005
  case 13: {
631
1006
  const typeReference = matchValue.fields[0];
632
1007
  const context_2 = TransformContext__PushScope_Z721C83C5(context_1, typeReference.Name);
633
- const handleDefaultCase = () => (new FSharpType(8, [new FSharpTypeAlias(typeAliasName, transformType(context_2, new GlueType(13, [typeReference])), transformTypeParameters(context_2, glueTypeAliasDeclaration.TypeParameters))]));
1008
+ const handleDefaultCase = () => (new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformType(context_2, new GlueType(13, [typeReference])), transformTypeParameters(context_2, glueTypeAliasDeclaration.TypeParameters))]));
634
1009
  const matchValue_2 = typeReference.TypeArguments;
635
1010
  let matchResult_1, head;
636
1011
  if (!isEmpty(matchValue_2)) {
@@ -648,11 +1023,11 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
648
1023
  switch (matchResult_1) {
649
1024
  case 0:
650
1025
  if (head.tag === 21) {
651
- const makeInterfaceTyp = (name) => (new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), name, glueTypeAliasDeclaration.Name, empty(), TransformMembers_toFSharpMember(context_2, head.fields[0])));
1026
+ const makeInterfaceTyp = (name) => (new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), name, glueTypeAliasDeclaration.Name, empty(), TransformMembers_toFSharpMember(context_2, head.fields[0]), empty()));
652
1027
  const exposedType = makeInterfaceTyp("ReturnType");
653
1028
  const typeArgument = makeInterfaceTyp(TransformContext__get_FullName(context_2) + ".ReturnType");
654
1029
  TransformContext__ExposeType_Z1D58A540(TransformContext__PushScope_Z721C83C5(context_2, typeReference.Name), new FSharpType(4, [exposedType]));
655
- return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, new FSharpType(10, [new FSharpTypeReference(typeReference.Name, typeReference.FullName, singleton(new FSharpType(4, [typeArgument])), new FSharpType(9, []))]), empty())]);
1030
+ return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(10, [new FSharpTypeReference(typeReference.Name, typeReference.FullName, singleton(new FSharpType(4, [typeArgument])), new FSharpType(9, []))]), empty())]);
656
1031
  }
657
1032
  else {
658
1033
  return handleDefaultCase();
@@ -662,44 +1037,28 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
662
1037
  }
663
1038
  }
664
1039
  case 15:
665
- return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, transformType(context_1, new GlueType(15, [matchValue.fields[0]])), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
666
- case 14: {
667
- const originalInterface = transformInterface(context_1, matchValue.fields[0]);
668
- return new FSharpType(4, [new FSharpInterface(originalInterface.Attributes, typeAliasName, originalInterface.OriginalName, originalInterface.TypeParameters, map((m_1) => {
669
- switch (m_1.tag) {
670
- case 1: {
671
- const property = m_1.fields[0];
672
- return new FSharpMember(1, [new FSharpMemberInfo(property.Attributes, property.Name, property.OriginalName, property.TypeParameters, property.Parameters, property.Type, true, property.IsStatic, property.Accessor, property.Accessibility, property.XmlDoc)]);
673
- }
674
- case 2: {
675
- const staticMember = m_1.fields[0];
676
- return new FSharpMember(2, [new FSharpStaticMemberInfo(staticMember.Attributes, staticMember.Name, staticMember.OriginalName, staticMember.TypeParameters, staticMember.Parameters, staticMember.Type, true, staticMember.Accessor, staticMember.Accessibility)]);
677
- }
678
- default: {
679
- const method = m_1.fields[0];
680
- return new FSharpMember(0, [new FSharpMemberInfo(method.Attributes, method.Name, method.OriginalName, method.TypeParameters, method.Parameters, method.Type, true, method.IsStatic, method.Accessor, method.Accessibility, method.XmlDoc)]);
681
- }
682
- }
683
- }, originalInterface.Members))]);
684
- }
1040
+ return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformType(context_1, new GlueType(15, [matchValue.fields[0]])), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
1041
+ case 14:
1042
+ return new FSharpType(4, [Interface_makePartial(typeAliasName, transformInterface(context_1, matchValue.fields[0]))]);
685
1043
  case 16: {
686
1044
  const functionType = matchValue.fields[0];
687
- return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), singleton(new FSharpMember(0, [new FSharpMemberInfo(singleton(new FSharpAttribute(1, [])), "Invoke", "Invoke", empty(), map((parameter) => transformParameter(context_1, parameter), functionType.Parameters), transformType(context_1, functionType.Type), false, false, void 0, new FSharpAccessibility(0, []), empty())])))]);
1045
+ return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), singleton(new FSharpMember(0, [new FSharpMemberInfo(singleton(new FSharpAttribute(1, [])), "Invoke", "Invoke", empty(), map((parameter) => transformParameter(context_1, parameter), functionType.Parameters), transformType(context_1, functionType.Type), false, false, void 0, new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))])), empty())]);
688
1046
  }
689
1047
  case 19:
690
- return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, transformTupleType(context_1, matchValue.fields[0]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
1048
+ return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformTupleType(context_1, matchValue.fields[0]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
691
1049
  case 21:
692
- return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), TransformMembers_toFSharpMember(context_1, matchValue.fields[0]))]);
1050
+ return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), TransformMembers_toFSharpMember(context_1, matchValue.fields[0]), empty())]);
693
1051
  case 22:
694
- return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), TransformMembers_toFSharpMember(context_1, matchValue.fields[0].Members))]);
1052
+ return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), TransformMembers_toFSharpMember(context_1, matchValue.fields[0].Members), empty())]);
695
1053
  case 24:
696
- return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, new FSharpType(17, []), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
1054
+ return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(17, []), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
1055
+ case 17:
1056
+ return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(12, [matchValue.fields[0]]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
697
1057
  case 12:
698
1058
  case 4:
699
1059
  case 1:
700
1060
  case 11:
701
1061
  case 5:
702
- case 17:
703
1062
  case 0:
704
1063
  case 6:
705
1064
  case 18:
@@ -709,122 +1068,12 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
709
1068
  case 23:
710
1069
  return new FSharpType(9, []);
711
1070
  default: {
712
- const flattenCases = (cases_1) => collect_1((_arg) => {
713
- switch (_arg.tag) {
714
- case 8:
715
- return singleton(_arg);
716
- case 7:
717
- return flattenCases(_arg.fields[0].fields[0]);
718
- case 5: {
719
- const matchValue_1 = _arg.fields[0].Type;
720
- if (matchValue_1.tag === 7) {
721
- return flattenCases(matchValue_1.fields[0].fields[0]);
722
- }
723
- else {
724
- return empty();
725
- }
726
- }
727
- default:
728
- return empty();
729
- }
730
- }, cases_1);
731
- const flattenedCases = flattenCases(matchValue.fields[0].fields[0]);
732
- const isStringOnly = !isEmpty(flattenedCases) && forAll((_arg_1) => {
733
- let matchResult_2;
734
- if (_arg_1.tag === 8) {
735
- if (_arg_1.fields[0].tag === 0) {
736
- matchResult_2 = 0;
737
- }
738
- else {
739
- matchResult_2 = 1;
740
- }
741
- }
742
- else {
743
- matchResult_2 = 1;
744
- }
745
- switch (matchResult_2) {
746
- case 0:
747
- return true;
748
- default:
749
- return false;
750
- }
751
- }, flattenedCases);
752
- const isNumericOnly = !isEmpty(flattenedCases) && forAll((_arg_2) => {
753
- let matchResult_3;
754
- if (_arg_2.tag === 8) {
755
- if (_arg_2.fields[0].tag === 1) {
756
- matchResult_3 = 0;
757
- }
758
- else {
759
- matchResult_3 = 1;
760
- }
761
- }
762
- else {
763
- matchResult_3 = 1;
764
- }
765
- switch (matchResult_3) {
766
- case 0:
767
- return true;
768
- default:
769
- return false;
770
- }
771
- }, flattenedCases);
772
- if (isStringOnly) {
773
- return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(11, []), new FSharpAttribute(9, [0])]), typeAliasName, List_distinct(map((value) => {
774
- let matchResult_4, value_1;
775
- if (value.tag === 8) {
776
- if (value.fields[0].tag === 0) {
777
- matchResult_4 = 0;
778
- value_1 = value.fields[0].fields[0];
779
- }
780
- else {
781
- matchResult_4 = 1;
782
- }
783
- }
784
- else {
785
- matchResult_4 = 1;
786
- }
787
- switch (matchResult_4) {
788
- case 0: {
789
- const sanitizeResult = sanitizeNameWithResult(value_1);
790
- return new FSharpUnionCase(toList(delay(() => (sanitizeResult.IsDifferent ? singleton_1(new FSharpAttribute(10, [removeSurroundingQuotes(value_1)])) : empty_1()))), sanitizeResult.Name);
791
- }
792
- default:
793
- throw new Error("Should not happen");
794
- }
795
- }, flattenedCases), {
796
- Equals: equals,
797
- GetHashCode: safeHash,
798
- }), false)]);
799
- }
800
- else if (isNumericOnly) {
801
- return new FSharpType(0, [new FSharpEnum(typeAliasName, List_distinct(map((value_2) => {
802
- let matchResult_5, value_3;
803
- if (value_2.tag === 8) {
804
- if (value_2.fields[0].tag === 1) {
805
- matchResult_5 = 0;
806
- value_3 = value_2.fields[0].fields[0];
807
- }
808
- else {
809
- matchResult_5 = 1;
810
- }
811
- }
812
- else {
813
- matchResult_5 = 1;
814
- }
815
- switch (matchResult_5) {
816
- case 0:
817
- return new FSharpEnumCase(int32ToString(value_3), new FSharpLiteral(1, [value_3]));
818
- default:
819
- throw new Error("Should not happen");
820
- }
821
- }, flattenedCases), {
822
- Equals: equals,
823
- GetHashCode: safeHash,
824
- }))]);
1071
+ const matchValue_1 = tryOptimizeUnionType(context_1, typeAliasName, matchValue.fields[0].fields[0]);
1072
+ if (matchValue_1 == null) {
1073
+ return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformType(context_1, matchValue), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
825
1074
  }
826
1075
  else {
827
- return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, transformType(context_1, matchValue), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
1076
+ return matchValue_1;
828
1077
  }
829
1078
  }
830
1079
  }
@@ -838,7 +1087,7 @@ function transformClassDeclaration(context, classDeclaration) {
838
1087
  let Members;
839
1088
  const patternInput = sanitizeNameAndPushScope(classDeclaration.Name, context);
840
1089
  const context_1 = patternInput[1];
841
- return new FSharpType(4, [(Members = TransformMembers_toFSharpMember(context_1, classDeclaration.Members), new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), patternInput[0], classDeclaration.Name, transformTypeParameters(context_1, classDeclaration.TypeParameters), Members))]);
1090
+ return new FSharpType(4, [(Members = TransformMembers_toFSharpMember(context_1, classDeclaration.Members), new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), patternInput[0], classDeclaration.Name, transformTypeParameters(context_1, classDeclaration.TypeParameters), Members, map((glueType) => transformType(context_1, glueType), classDeclaration.HeritageClauses)))]);
842
1091
  }
843
1092
 
844
1093
  function transformToFsharp(context, glueTypes) {
@@ -912,11 +1161,12 @@ export function transform(isTopLevel, glueAst) {
912
1161
  return true;
913
1162
  case 11:
914
1163
  return exists((glueType_2) => {
915
- if (glueType_2.tag === 12) {
916
- return true;
917
- }
918
- else {
919
- return false;
1164
+ switch (glueType_2.tag) {
1165
+ case 12:
1166
+ case 6:
1167
+ return true;
1168
+ default:
1169
+ return false;
920
1170
  }
921
1171
  }, glueType_1.fields[0].Types);
922
1172
  case 25: