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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +16 -0
  2. package/dist/Glutinum.Converter/Abbreviations.js +9 -32
  3. package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
  4. package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
  5. package/dist/Glutinum.Converter/FsharpAST.js +116 -65
  6. package/dist/Glutinum.Converter/Generate.js +38 -25
  7. package/dist/Glutinum.Converter/GlueAST.js +79 -41
  8. package/dist/Glutinum.Converter/Hosting.js +141 -167
  9. package/dist/Glutinum.Converter/Merge.js +369 -337
  10. package/dist/Glutinum.Converter/Packages.js +391 -92
  11. package/dist/Glutinum.Converter/Printer.js +398 -387
  12. package/dist/Glutinum.Converter/Read.js +387 -88
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
  14. package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
  15. package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
  16. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
  17. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
  18. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
  19. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +14 -20
  20. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
  21. package/dist/Glutinum.Converter/Reader/Node.js +8 -11
  22. package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
  23. package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1342
  24. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
  25. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
  26. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
  27. package/dist/Glutinum.Converter/Reader/Types.js +290 -15
  28. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
  29. package/dist/Glutinum.Converter/Reader/Utils.js +325 -25
  30. package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
  31. package/dist/Glutinum.Converter/Transform.js +3572 -8415
  32. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  33. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  34. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  35. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1149 -0
  36. package/dist/Glutinum.Converter/Transformer/Context.js +666 -0
  37. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  38. package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
  39. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  40. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +596 -0
  41. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  42. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -0
  43. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  44. package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
  45. package/dist/Glutinum.Converter/Utils/String.js +14 -3
  46. package/dist/Program.js +102 -239
  47. package/package.json +3 -2
@@ -4,15 +4,16 @@ import { StringBuilder__AppendLine, StringBuilder__Append_Z721C83C5, StringBuild
4
4
  import { class_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
5
5
  import { max } from "../fable_modules/fable-library-js.5.17.2/Double.js";
6
6
  import { trimStart, interpolate, substring, join, replace, concat, isNullOrWhiteSpace, replicate } from "../fable_modules/fable-library-js.5.17.2/String.js";
7
- import { isDigit2 } from "../fable_modules/fable-library-js.5.17.2/Char.js";
8
7
  import { splitLines, replace as replace_1, removeSingleQuote, removeDoubleQuote, capitalizeFirstLetter } from "./Utils/String.js";
9
- import { tail as tail_1, cons, head, mapIndexed, empty, forAll, ofArray, concat as concat_1, partition, singleton, append, choose, filter, iterateIndexed, isEmpty, iterate, map, length, exists } from "../fable_modules/fable-library-js.5.17.2/List.js";
10
- import { disposeSafe, getEnumerator, int32ToString, Exception } from "../fable_modules/fable-library-js.5.17.2/Util.js";
8
+ import { isDigit2 } from "../fable_modules/fable-library-js.5.17.2/Char.js";
9
+ import { cons, mapIndexed, empty, forAll, ofArray, concat as concat_1, partition, length, singleton, append, choose, filter, iterateIndexed, iterate, isEmpty, map, exists } from "../fable_modules/fable-library-js.5.17.2/List.js";
10
+ import { stringHash, disposeSafe, getEnumerator, int32ToString, Exception } from "../fable_modules/fable-library-js.5.17.2/Util.js";
11
11
  import { sanitizeTypeParameterName } from "./Utils/Naming.js";
12
12
  import { escape, create, isMatch, replace as replace_2 } from "../fable_modules/fable-library-js.5.17.2/RegExp.js";
13
13
  import { removeConsecutiveEmptyLines, trimEmptyLines } from "./Utils/List.js";
14
+ import { FSharpInterface, FSharpAttribute } from "./FsharpAST.js";
14
15
  import { singleton as singleton_1, append as append_1, delay, toList } from "../fable_modules/fable-library-js.5.17.2/Seq.js";
15
- import { FSharpOutFile, FSharpInterface, FSharpAttribute } from "./FsharpAST.js";
16
+ import { List_distinct } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
16
17
 
17
18
  export class Printer {
18
19
  constructor() {
@@ -44,16 +45,14 @@ export function Printer__get_Unindent(__) {
44
45
  }
45
46
 
46
47
  /**
47
- * Write the provided text prefixed with indentation
48
+ * Write the text prefixed with the indentation
48
49
  */
49
50
  export function Printer__Write_Z721C83C5(__, text) {
50
51
  StringBuilder__Append_Z721C83C5(__.buffer, replicate(__.indentationLevel, __.indentationText) + text);
51
52
  }
52
53
 
53
54
  /**
54
- * Write the provided text directly in the buffer
55
- *
56
- * Useful when you don't want to prefix the text with indentation
55
+ * Write the text without indentation
57
56
  */
58
57
  export function Printer__WriteInline_Z721C83C5(__, text) {
59
58
  StringBuilder__Append_Z721C83C5(__.buffer, text);
@@ -75,21 +74,9 @@ export function Printer__set_ImportSpecifier_Z721C83C5(__, v) {
75
74
  __["ImportSpecifier@"] = v;
76
75
  }
77
76
 
78
- export function Naming_$007CDigit$007C_$007C(digit) {
79
- if (isNullOrWhiteSpace(digit)) {
80
- return undefined;
81
- }
82
- else if (isDigit2(digit, 0)) {
83
- return digit;
84
- }
85
- else {
86
- return undefined;
87
- }
88
- }
89
-
90
77
  function sanitizeEnumCaseName(name) {
91
78
  const name_1 = capitalizeFirstLetter(removeDoubleQuote(removeSingleQuote(name)));
92
- if (Naming_$007CDigit$007C_$007C(name_1) != null) {
79
+ if (!isNullOrWhiteSpace(name_1) && isDigit2(name_1, 0)) {
93
80
  return concat("``", name_1, "``");
94
81
  }
95
82
  else {
@@ -125,6 +112,10 @@ function caseRulesToText(caseRules) {
125
112
  }
126
113
  }
127
114
 
115
+ function escapeStringLiteral(text) {
116
+ return replace(replace(replace(replace(replace(text, "\\", "\\\\"), "\"", "\\\""), "\r", "\\r"), "\n", "\\n"), "\t", "\\t");
117
+ }
118
+
128
119
  function attributeToText(fsharpAttribute) {
129
120
  switch (fsharpAttribute.tag) {
130
121
  case 1:
@@ -142,7 +133,7 @@ function attributeToText(fsharpAttribute) {
142
133
  case 8:
143
134
  return `[<TypeScriptTaggedUnion("${fsharpAttribute.fields[0]}", ${caseRulesToText(fsharpAttribute.fields[1])})>]`;
144
135
  case 13:
145
- return concat("[<CompiledName(\"", replace(replace(replace(replace(replace(fsharpAttribute.fields[0], "\\", "\\\\"), "\"", "\\\""), "\r", "\\r"), "\n", "\\n"), "\t", "\\t"), "\")>]");
136
+ return concat("[<CompiledName(\"", escapeStringLiteral(fsharpAttribute.fields[0]), "\")>]");
146
137
  case 14:
147
138
  return concat("[<CompiledValue(", (fsharpAttribute.fields[0].tag === 1) ? int32ToString(fsharpAttribute.fields[0].fields[0]) : ((fsharpAttribute.fields[0].tag === 2) ? fsharpAttribute.fields[0].fields[0].toString() : ((fsharpAttribute.fields[0].tag === 0) ? concat("\"", fsharpAttribute.fields[0].fields[0], "\"") : ((fsharpAttribute.fields[0].tag === 4) ? "null" : (fsharpAttribute.fields[0].fields[0] ? "true" : "false")))), ")>]");
148
139
  case 15:
@@ -159,8 +150,8 @@ function attributeToText(fsharpAttribute) {
159
150
  return "[<EmitIndexer>]";
160
151
  case 21:
161
152
  if (fsharpAttribute.fields[0] != null) {
162
- const name_3 = fsharpAttribute.fields[0];
163
- return concat("[<Global(\"", name_3, "\")>]");
153
+ const name_2 = fsharpAttribute.fields[0];
154
+ return concat("[<Global(\"", name_2, "\")>]");
164
155
  }
165
156
  else {
166
157
  return "[<Global>]";
@@ -180,16 +171,7 @@ function attributeToText(fsharpAttribute) {
180
171
  return "[<Obsolete>]";
181
172
  }
182
173
  else {
183
- const message_1 = fsharpAttribute.fields[0];
184
- if ((message_1.indexOf("``") >= 0) ? true : (message_1.indexOf("\"\"\"") >= 0)) {
185
- return concat("[<Obsolete(\"", replace(replace(replace(replace(replace(message_1, "\\", "\\\\"), "\"", "\\\""), "\r", "\\r"), "\n", "\\n"), "\t", "\\t"), "\")>]");
186
- }
187
- else if ((message_1.indexOf("\n") >= 0) ? true : (message_1.indexOf("\"") >= 0)) {
188
- return concat("[<Obsolete(\"\"\"", message_1, "\"\"\")>]");
189
- }
190
- else {
191
- return concat("[<Obsolete(\"", message_1, "\")>]");
192
- }
174
+ return concat("[<Obsolete(\"", escapeStringLiteral(fsharpAttribute.fields[0]), "\")>]");
193
175
  }
194
176
  case 9:
195
177
  return "[<AbstractClass>]";
@@ -202,21 +184,20 @@ function attributeToText(fsharpAttribute) {
202
184
  }
203
185
  }
204
186
 
205
- function printInlineAttribute(printer, fsharpAttribute) {
206
- Printer__WriteInline_Z721C83C5(printer, attributeToText(fsharpAttribute));
207
- Printer__WriteInline_Z721C83C5(printer, " ");
187
+ function compactAttributesText(fsharpAttributes) {
188
+ return replace_1(">][<", "; ", join("", map(attributeToText, fsharpAttributes)));
208
189
  }
209
190
 
210
191
  function printInlineAttributes(printer, fsharpAttributes) {
211
- if (length(fsharpAttributes) > 0) {
212
- Printer__WriteInline_Z721C83C5(printer, replace_1(">][<", "; ", join("", map(attributeToText, fsharpAttributes))));
192
+ if (!isEmpty(fsharpAttributes)) {
193
+ Printer__WriteInline_Z721C83C5(printer, compactAttributesText(fsharpAttributes));
213
194
  Printer__WriteInline_Z721C83C5(printer, " ");
214
195
  }
215
196
  }
216
197
 
217
198
  function printCompactAttributesAndNewLine(printer, fsharpAttributes) {
218
- if (length(fsharpAttributes) > 0) {
219
- Printer__Write_Z721C83C5(printer, replace_1(">][<", "; ", join("", map(attributeToText, fsharpAttributes))));
199
+ if (!isEmpty(fsharpAttributes)) {
200
+ Printer__Write_Z721C83C5(printer, compactAttributesText(fsharpAttributes));
220
201
  Printer__get_NewLine(printer);
221
202
  }
222
203
  }
@@ -229,18 +210,18 @@ function printAttributes(printer, fsharpAttributes) {
229
210
  }
230
211
 
231
212
  export function printTypeParametersDeclaration(printer, typeParameters) {
232
- const innterPrinter = Printer_$ctor();
213
+ const innerPrinter = Printer_$ctor();
233
214
  if (!isEmpty(typeParameters)) {
234
- Printer__WriteInline_Z721C83C5(innterPrinter, "<");
215
+ Printer__WriteInline_Z721C83C5(innerPrinter, "<");
235
216
  iterateIndexed((index, typeParameter) => {
236
217
  if (index !== 0) {
237
- Printer__WriteInline_Z721C83C5(innterPrinter, ", ");
218
+ Printer__WriteInline_Z721C83C5(innerPrinter, ", ");
238
219
  }
239
220
  if (typeParameter.tag === 1) {
240
- Printer__WriteInline_Z721C83C5(innterPrinter, concat("\'", sanitizeTypeParameterName(typeParameter.fields[0].Name)));
221
+ Printer__WriteInline_Z721C83C5(innerPrinter, concat("\'", sanitizeTypeParameterName(typeParameter.fields[0].Name)));
241
222
  }
242
223
  else {
243
- Printer__WriteInline_Z721C83C5(innterPrinter, `'T${index}`);
224
+ Printer__WriteInline_Z721C83C5(innerPrinter, `'T${index}`);
244
225
  }
245
226
  }, typeParameters);
246
227
  iterateIndexed((index_1, typeParameter_3) => {
@@ -250,14 +231,14 @@ export function printTypeParametersDeclaration(printer, typeParameters) {
250
231
  else {
251
232
  const constraint_ = matchValue;
252
233
  if (index_1 === 0) {
253
- Printer__WriteInline_Z721C83C5(innterPrinter, " when ");
234
+ Printer__WriteInline_Z721C83C5(innerPrinter, " when ");
254
235
  }
255
236
  else {
256
- Printer__WriteInline_Z721C83C5(innterPrinter, " and ");
237
+ Printer__WriteInline_Z721C83C5(innerPrinter, " and ");
257
238
  }
258
- Printer__WriteInline_Z721C83C5(innterPrinter, concat("\'", typeParameter_3.Name));
259
- Printer__WriteInline_Z721C83C5(innterPrinter, " :> ");
260
- Printer__WriteInline_Z721C83C5(innterPrinter, printType(constraint_));
239
+ Printer__WriteInline_Z721C83C5(innerPrinter, concat("\'", typeParameter_3.Name));
240
+ Printer__WriteInline_Z721C83C5(innerPrinter, " :> ");
241
+ Printer__WriteInline_Z721C83C5(innerPrinter, printType(constraint_));
261
242
  }
262
243
  }, filter((_arg_1) => (_arg_1.Constraint != null), choose((_arg) => {
263
244
  if (_arg.tag === 1) {
@@ -267,11 +248,11 @@ export function printTypeParametersDeclaration(printer, typeParameters) {
267
248
  return undefined;
268
249
  }
269
250
  }, typeParameters)));
270
- if (Printer__ToStringWithoutTrailNewLine(innterPrinter).endsWith(">")) {
271
- Printer__WriteInline_Z721C83C5(innterPrinter, " ");
251
+ if (Printer__ToStringWithoutTrailNewLine(innerPrinter).endsWith(">")) {
252
+ Printer__WriteInline_Z721C83C5(innerPrinter, " ");
272
253
  }
273
- Printer__WriteInline_Z721C83C5(innterPrinter, ">");
274
- Printer__WriteInline_Z721C83C5(printer, Printer__ToStringWithoutTrailNewLine(innterPrinter));
254
+ Printer__WriteInline_Z721C83C5(innerPrinter, ">");
255
+ Printer__WriteInline_Z721C83C5(printer, Printer__ToStringWithoutTrailNewLine(innerPrinter));
275
256
  }
276
257
  }
277
258
 
@@ -402,34 +383,23 @@ export function printType(fsharpType) {
402
383
  }
403
384
  }
404
385
 
405
- export function FSharpAccessibility_print(printer, accessibility) {
386
+ function FSharpAccessibility_text(accessibility) {
406
387
  switch (accessibility.tag) {
407
- case 1: {
408
- Printer__Write_Z721C83C5(printer, "private ");
409
- break;
410
- }
411
- case 2: {
412
- Printer__Write_Z721C83C5(printer, "protected ");
413
- break;
414
- }
388
+ case 1:
389
+ return "private ";
390
+ case 2:
391
+ return "protected ";
415
392
  default:
416
- Printer__Write_Z721C83C5(printer, "");
393
+ return "";
417
394
  }
418
395
  }
419
396
 
397
+ export function FSharpAccessibility_print(printer, accessibility) {
398
+ Printer__Write_Z721C83C5(printer, FSharpAccessibility_text(accessibility));
399
+ }
400
+
420
401
  export function FSharpAccessibility_printInline(printer, accessibility) {
421
- switch (accessibility.tag) {
422
- case 1: {
423
- Printer__WriteInline_Z721C83C5(printer, "private ");
424
- break;
425
- }
426
- case 2: {
427
- Printer__WriteInline_Z721C83C5(printer, "protected ");
428
- break;
429
- }
430
- default:
431
- Printer__WriteInline_Z721C83C5(printer, "");
432
- }
402
+ Printer__WriteInline_Z721C83C5(printer, FSharpAccessibility_text(accessibility));
433
403
  }
434
404
 
435
405
  function codeInline(line) {
@@ -541,24 +511,194 @@ function printParameterType(typ) {
541
511
  }
542
512
  }
543
513
 
514
+ function printParameterList(printer, separator, parameters) {
515
+ iterateIndexed((index, p) => {
516
+ if (index !== 0) {
517
+ Printer__WriteInline_Z721C83C5(printer, separator);
518
+ }
519
+ printInlineAttributes(printer, p.Attributes);
520
+ if (p.IsOptional) {
521
+ Printer__WriteInline_Z721C83C5(printer, "?");
522
+ }
523
+ Printer__WriteInline_Z721C83C5(printer, concat(p.Name, ": ", printParameterType(p.Type)));
524
+ if (hasParamArrayAttribute(p.Attributes)) {
525
+ Printer__WriteInline_Z721C83C5(printer, " []");
526
+ }
527
+ }, parameters);
528
+ }
529
+
544
530
  export function printParameters(printer, parameters) {
545
- if (length(parameters) === 0) {
531
+ if (isEmpty(parameters)) {
546
532
  Printer__WriteInline_Z721C83C5(printer, "unit");
547
533
  }
548
534
  else {
549
- iterateIndexed((index, p) => {
550
- if (index !== 0) {
551
- Printer__WriteInline_Z721C83C5(printer, " * ");
535
+ printParameterList(printer, " * ", parameters);
536
+ }
537
+ }
538
+
539
+ function accessorSuffix(accessor) {
540
+ switch (accessor.tag) {
541
+ case 1:
542
+ return " with set";
543
+ case 2:
544
+ return " with get, set";
545
+ default:
546
+ return " with get";
547
+ }
548
+ }
549
+
550
+ function printInterfaceMethod(printer, methodInfo) {
551
+ printXmlDoc(printer, methodInfo.XmlDoc);
552
+ printCompactAttributesAndNewLine(printer, methodInfo.Attributes);
553
+ if (methodInfo.IsStatic) {
554
+ Printer__Write_Z721C83C5(printer, "static ");
555
+ }
556
+ else {
557
+ Printer__Write_Z721C83C5(printer, "abstract ");
558
+ }
559
+ Printer__WriteInline_Z721C83C5(printer, concat("member ", methodInfo.Name));
560
+ printTypeParametersDeclaration(printer, methodInfo.TypeParameters);
561
+ if (methodInfo.IsStatic) {
562
+ Printer__WriteInline_Z721C83C5(printer, " ");
563
+ if (isEmpty(methodInfo.Parameters)) {
564
+ Printer__WriteInline_Z721C83C5(printer, "()");
565
+ }
566
+ else {
567
+ Printer__WriteInline_Z721C83C5(printer, "(");
568
+ printParameterList(printer, ", ", methodInfo.Parameters);
569
+ Printer__WriteInline_Z721C83C5(printer, ")");
570
+ }
571
+ }
572
+ else {
573
+ Printer__WriteInline_Z721C83C5(printer, ": ");
574
+ printParameters(printer, methodInfo.Parameters);
575
+ }
576
+ if (methodInfo.IsStatic) {
577
+ Printer__WriteInline_Z721C83C5(printer, " : ");
578
+ }
579
+ else {
580
+ Printer__WriteInline_Z721C83C5(printer, " -> ");
581
+ }
582
+ Printer__WriteInline_Z721C83C5(printer, printType(methodInfo.Type));
583
+ if (methodInfo.IsStatic) {
584
+ Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
585
+ }
586
+ Printer__get_NewLine(printer);
587
+ }
588
+
589
+ function printInterfaceProperty(printer, interfaceInfo, propertyInfo) {
590
+ printXmlDoc(printer, propertyInfo.XmlDoc);
591
+ printAttributes(printer, propertyInfo.Attributes);
592
+ if (propertyInfo.IsStatic) {
593
+ if (propertyInfo.Body.tag === 1) {
594
+ Printer__Write_Z721C83C5(printer, concat("[<Emit(\"\"\"", ((((((("import { " + interfaceInfo.OriginalName) + " } from \"") + Printer__get_ImportSpecifier(printer)) + "\";\n") + interfaceInfo.OriginalName) + ".") + propertyInfo.OriginalName) + "{{=$0}}", "\"\"\")>]"));
595
+ Printer__get_NewLine(printer);
596
+ }
597
+ Printer__Write_Z721C83C5(printer, "static member inline ");
598
+ FSharpAccessibility_printInline(printer, propertyInfo.Accessibility);
599
+ Printer__WriteInline_Z721C83C5(printer, propertyInfo.Name);
600
+ const printGetter = () => {
601
+ Printer__get_Indent(printer);
602
+ Printer__Write_Z721C83C5(printer, concat("with get () : ", printType(propertyInfo.Type), " ="));
603
+ Printer__get_NewLine(printer);
604
+ Printer__get_Indent(printer);
605
+ Printer__Write_Z721C83C5(printer, "nativeOnly");
606
+ Printer__get_Unindent(printer);
607
+ Printer__get_Unindent(printer);
608
+ };
609
+ const printerSetter = (useAndKeyword) => {
610
+ Printer__get_Indent(printer);
611
+ if (useAndKeyword) {
612
+ Printer__Write_Z721C83C5(printer, "and ");
552
613
  }
553
- printInlineAttributes(printer, p.Attributes);
554
- if (p.IsOptional) {
555
- Printer__WriteInline_Z721C83C5(printer, "?");
614
+ else {
615
+ Printer__Write_Z721C83C5(printer, "with ");
556
616
  }
557
- Printer__WriteInline_Z721C83C5(printer, concat(p.Name, ": ", printParameterType(p.Type)));
558
- if (hasParamArrayAttribute(p.Attributes)) {
559
- Printer__WriteInline_Z721C83C5(printer, " []");
617
+ Printer__WriteInline_Z721C83C5(printer, concat("set (value: ", printType(propertyInfo.Type), ") ="));
618
+ Printer__get_NewLine(printer);
619
+ Printer__get_Indent(printer);
620
+ Printer__Write_Z721C83C5(printer, "nativeOnly");
621
+ Printer__get_Unindent(printer);
622
+ Printer__get_Unindent(printer);
623
+ };
624
+ const matchValue_1 = propertyInfo.Accessor;
625
+ if (matchValue_1 != null) {
626
+ const accessor = matchValue_1;
627
+ Printer__get_NewLine(printer);
628
+ switch (accessor.tag) {
629
+ case 1: {
630
+ printerSetter(false);
631
+ break;
632
+ }
633
+ case 2: {
634
+ printGetter();
635
+ Printer__get_NewLine(printer);
636
+ printerSetter(true);
637
+ break;
638
+ }
639
+ default:
640
+ printGetter();
641
+ }
642
+ }
643
+ else {
644
+ Printer__WriteInline_Z721C83C5(printer, concat(": ", printType(propertyInfo.Type)));
645
+ Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
646
+ }
647
+ }
648
+ else {
649
+ Printer__Write_Z721C83C5(printer, concat("abstract member ", propertyInfo.Name));
650
+ iterateIndexed((index, p) => {
651
+ if (index === 0) {
652
+ Printer__WriteInline_Z721C83C5(printer, ": ");
560
653
  }
561
- }, parameters);
654
+ else {
655
+ Printer__WriteInline_Z721C83C5(printer, " -> ");
656
+ }
657
+ const option = p.IsOptional ? " option" : "";
658
+ Printer__WriteInline_Z721C83C5(printer, concat(p.Name, ": ", printParameterType(p.Type), option));
659
+ }, propertyInfo.Parameters);
660
+ if (length(propertyInfo.Parameters) > 0) {
661
+ Printer__WriteInline_Z721C83C5(printer, " -> ");
662
+ }
663
+ else {
664
+ Printer__WriteInline_Z721C83C5(printer, ": ");
665
+ }
666
+ Printer__WriteInline_Z721C83C5(printer, printType(propertyInfo.Type));
667
+ if (propertyInfo.IsOptional) {
668
+ Printer__WriteInline_Z721C83C5(printer, " option");
669
+ }
670
+ let option_4;
671
+ const option_2 = propertyInfo.Accessor;
672
+ option_4 = ((option_2 != null) ? accessorSuffix(option_2) : undefined);
673
+ if (option_4 != null) {
674
+ Printer__WriteInline_Z721C83C5(printer, option_4);
675
+ }
676
+ }
677
+ Printer__get_NewLine(printer);
678
+ }
679
+
680
+ function printInterfaceStaticMember(printer, interfaceInfo, staticMemberInfo) {
681
+ printXmlDoc(printer, staticMemberInfo.XmlDoc);
682
+ printCompactAttributesAndNewLine(printer, staticMemberInfo.Attributes);
683
+ const macroArguments = join(", ", mapIndexed((index, _arg) => (`$${index}`), staticMemberInfo.Parameters));
684
+ Printer__Write_Z721C83C5(printer, `[<Emit("""import { ${interfaceInfo.OriginalName} } from "${Printer__get_ImportSpecifier(printer)}";
685
+ ${interfaceInfo.OriginalName}.${staticMemberInfo.OriginalName}(${macroArguments})""")>]`);
686
+ Printer__get_NewLine(printer);
687
+ Printer__Write_Z721C83C5(printer, concat("static member inline ", staticMemberInfo.Name, " "));
688
+ printTypeParametersDeclaration(printer, staticMemberInfo.TypeParameters);
689
+ if (isEmpty(staticMemberInfo.Parameters)) {
690
+ Printer__WriteInline_Z721C83C5(printer, "() : ");
691
+ Printer__WriteInline_Z721C83C5(printer, printType(staticMemberInfo.Type));
692
+ Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
693
+ Printer__get_NewLine(printer);
694
+ }
695
+ else {
696
+ Printer__WriteInline_Z721C83C5(printer, "(");
697
+ printParameterList(printer, ", ", staticMemberInfo.Parameters);
698
+ Printer__WriteInline_Z721C83C5(printer, "): ");
699
+ Printer__WriteInline_Z721C83C5(printer, printType(staticMemberInfo.Type));
700
+ Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
701
+ Printer__get_NewLine(printer);
562
702
  }
563
703
  }
564
704
 
@@ -575,189 +715,17 @@ function printInterface(printer, interfaceInfo) {
575
715
  Printer__get_NewLine(printer);
576
716
  }, interfaceInfo.Inheritance);
577
717
  iterate((_arg) => {
578
- let _arg_1;
579
718
  switch (_arg.tag) {
580
719
  case 1: {
581
- const propertyInfo = _arg.fields[0];
582
- printXmlDoc(printer, propertyInfo.XmlDoc);
583
- printAttributes(printer, propertyInfo.Attributes);
584
- if (propertyInfo.IsStatic) {
585
- if (propertyInfo.Body.tag === 1) {
586
- Printer__Write_Z721C83C5(printer, concat("[<Emit(\"\"\"", ((((((("import { " + interfaceInfo.OriginalName) + " } from \"") + Printer__get_ImportSpecifier(printer)) + "\";\n") + interfaceInfo.OriginalName) + ".") + propertyInfo.OriginalName) + "{{=$0}}", "\"\"\")>]"));
587
- Printer__get_NewLine(printer);
588
- }
589
- Printer__Write_Z721C83C5(printer, "static member inline ");
590
- FSharpAccessibility_printInline(printer, propertyInfo.Accessibility);
591
- Printer__WriteInline_Z721C83C5(printer, propertyInfo.Name);
592
- const printGetter = () => {
593
- Printer__get_Indent(printer);
594
- Printer__Write_Z721C83C5(printer, concat("with get () : ", printType(propertyInfo.Type), " ="));
595
- Printer__get_NewLine(printer);
596
- Printer__get_Indent(printer);
597
- Printer__Write_Z721C83C5(printer, "nativeOnly");
598
- Printer__get_Unindent(printer);
599
- Printer__get_Unindent(printer);
600
- };
601
- const printerSetter = (useAndKeyword) => {
602
- Printer__get_Indent(printer);
603
- if (useAndKeyword) {
604
- Printer__Write_Z721C83C5(printer, "and ");
605
- }
606
- else {
607
- Printer__Write_Z721C83C5(printer, "with ");
608
- }
609
- Printer__WriteInline_Z721C83C5(printer, concat("set (value: ", printType(propertyInfo.Type), ") ="));
610
- Printer__get_NewLine(printer);
611
- Printer__get_Indent(printer);
612
- Printer__Write_Z721C83C5(printer, "nativeOnly");
613
- Printer__get_Unindent(printer);
614
- Printer__get_Unindent(printer);
615
- };
616
- const matchValue_1 = propertyInfo.Accessor;
617
- if (matchValue_1 != null) {
618
- const accessor = matchValue_1;
619
- Printer__get_NewLine(printer);
620
- switch (accessor.tag) {
621
- case 1: {
622
- printerSetter(false);
623
- break;
624
- }
625
- case 2: {
626
- printGetter();
627
- Printer__get_NewLine(printer);
628
- printerSetter(true);
629
- break;
630
- }
631
- default:
632
- printGetter();
633
- }
634
- }
635
- else {
636
- Printer__WriteInline_Z721C83C5(printer, concat(": ", printType(propertyInfo.Type)));
637
- Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
638
- }
639
- }
640
- else {
641
- Printer__Write_Z721C83C5(printer, concat("abstract member ", propertyInfo.Name));
642
- iterateIndexed((index_1, p_1) => {
643
- if (index_1 === 0) {
644
- Printer__WriteInline_Z721C83C5(printer, ": ");
645
- }
646
- else {
647
- Printer__WriteInline_Z721C83C5(printer, " -> ");
648
- }
649
- const option = p_1.IsOptional ? " option" : "";
650
- Printer__WriteInline_Z721C83C5(printer, concat(p_1.Name, ": ", printParameterType(p_1.Type), option));
651
- }, propertyInfo.Parameters);
652
- if (length(propertyInfo.Parameters) > 0) {
653
- Printer__WriteInline_Z721C83C5(printer, " -> ");
654
- }
655
- else {
656
- Printer__WriteInline_Z721C83C5(printer, ": ");
657
- }
658
- Printer__WriteInline_Z721C83C5(printer, printType(propertyInfo.Type));
659
- if (propertyInfo.IsOptional) {
660
- Printer__WriteInline_Z721C83C5(printer, " option");
661
- }
662
- let option_4;
663
- const option_2 = propertyInfo.Accessor;
664
- option_4 = ((option_2 != null) ? ((_arg_1 = option_2, (_arg_1.tag === 1) ? " with set" : ((_arg_1.tag === 2) ? " with get, set" : " with get"))) : undefined);
665
- if (option_4 != null) {
666
- Printer__WriteInline_Z721C83C5(printer, option_4);
667
- }
668
- }
669
- Printer__get_NewLine(printer);
720
+ printInterfaceProperty(printer, interfaceInfo, _arg.fields[0]);
670
721
  break;
671
722
  }
672
723
  case 2: {
673
- const staticMemberInfo = _arg.fields[0];
674
- printXmlDoc(printer, staticMemberInfo.XmlDoc);
675
- printCompactAttributesAndNewLine(printer, staticMemberInfo.Attributes);
676
- const macroArguments = join(", ", mapIndexed((index_2, _arg_2) => (`$${index_2}`), staticMemberInfo.Parameters));
677
- Printer__Write_Z721C83C5(printer, `[<Emit("""import { ${interfaceInfo.OriginalName} } from "${Printer__get_ImportSpecifier(printer)}";
678
- ${interfaceInfo.OriginalName}.${staticMemberInfo.OriginalName}(${macroArguments})""")>]`);
679
- Printer__get_NewLine(printer);
680
- Printer__Write_Z721C83C5(printer, concat("static member inline ", staticMemberInfo.Name, " "));
681
- printTypeParametersDeclaration(printer, staticMemberInfo.TypeParameters);
682
- if (isEmpty(staticMemberInfo.Parameters)) {
683
- Printer__WriteInline_Z721C83C5(printer, "() : ");
684
- Printer__WriteInline_Z721C83C5(printer, printType(staticMemberInfo.Type));
685
- Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
686
- Printer__get_NewLine(printer);
687
- }
688
- else {
689
- Printer__WriteInline_Z721C83C5(printer, "(");
690
- iterateIndexed((index_3, p_2) => {
691
- if (index_3 !== 0) {
692
- Printer__WriteInline_Z721C83C5(printer, ", ");
693
- }
694
- printInlineAttributes(printer, p_2.Attributes);
695
- if (p_2.IsOptional) {
696
- Printer__WriteInline_Z721C83C5(printer, "?");
697
- }
698
- Printer__WriteInline_Z721C83C5(printer, concat(p_2.Name, ": ", printParameterType(p_2.Type)));
699
- if (hasParamArrayAttribute(p_2.Attributes)) {
700
- Printer__WriteInline_Z721C83C5(printer, " []");
701
- }
702
- }, staticMemberInfo.Parameters);
703
- Printer__WriteInline_Z721C83C5(printer, "): ");
704
- Printer__WriteInline_Z721C83C5(printer, printType(staticMemberInfo.Type));
705
- Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
706
- Printer__get_NewLine(printer);
707
- }
724
+ printInterfaceStaticMember(printer, interfaceInfo, _arg.fields[0]);
708
725
  break;
709
726
  }
710
- default: {
711
- const methodInfo = _arg.fields[0];
712
- printXmlDoc(printer, methodInfo.XmlDoc);
713
- printCompactAttributesAndNewLine(printer, methodInfo.Attributes);
714
- if (methodInfo.IsStatic) {
715
- Printer__Write_Z721C83C5(printer, "static ");
716
- }
717
- else {
718
- Printer__Write_Z721C83C5(printer, "abstract ");
719
- }
720
- Printer__WriteInline_Z721C83C5(printer, concat("member ", methodInfo.Name));
721
- printTypeParametersDeclaration(printer, methodInfo.TypeParameters);
722
- if (methodInfo.IsStatic) {
723
- Printer__WriteInline_Z721C83C5(printer, " ");
724
- if (length(methodInfo.Parameters) === 0) {
725
- Printer__WriteInline_Z721C83C5(printer, "()");
726
- }
727
- else {
728
- Printer__WriteInline_Z721C83C5(printer, "(");
729
- iterateIndexed((index, p) => {
730
- if (index !== 0) {
731
- Printer__WriteInline_Z721C83C5(printer, ", ");
732
- }
733
- printInlineAttributes(printer, p.Attributes);
734
- if (p.IsOptional) {
735
- Printer__WriteInline_Z721C83C5(printer, "?");
736
- }
737
- Printer__WriteInline_Z721C83C5(printer, concat(p.Name, ": ", printParameterType(p.Type)));
738
- if (hasParamArrayAttribute(p.Attributes)) {
739
- Printer__WriteInline_Z721C83C5(printer, " []");
740
- }
741
- }, methodInfo.Parameters);
742
- Printer__WriteInline_Z721C83C5(printer, ")");
743
- }
744
- }
745
- else {
746
- Printer__WriteInline_Z721C83C5(printer, ": ");
747
- printParameters(printer, methodInfo.Parameters);
748
- }
749
- if (methodInfo.IsStatic) {
750
- Printer__WriteInline_Z721C83C5(printer, " : ");
751
- }
752
- else {
753
- Printer__WriteInline_Z721C83C5(printer, " -> ");
754
- }
755
- Printer__WriteInline_Z721C83C5(printer, printType(methodInfo.Type));
756
- if (methodInfo.IsStatic) {
757
- Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
758
- }
759
- Printer__get_NewLine(printer);
760
- }
727
+ default:
728
+ printInterfaceMethod(printer, _arg.fields[0]);
761
729
  }
762
730
  }, interfaceInfo.Members);
763
731
  if (isEmpty(interfaceInfo.Members) && isEmpty(interfaceInfo.Inheritance)) {
@@ -841,14 +809,13 @@ function printClass(printer, classInfo) {
841
809
  }
842
810
  if (!isEmpty(classInfo.ExplicitFields)) {
843
811
  iterate((explicitField) => {
844
- let _arg;
845
812
  printXmlDoc(printer, explicitField.XmlDoc);
846
813
  Printer__Write_Z721C83C5(printer, concat("member val ", explicitField.Name, " : "));
847
814
  Printer__WriteInline_Z721C83C5(printer, printType(explicitField.Type));
848
815
  Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
849
816
  let option_3;
850
817
  const option_1 = explicitField.Accessor;
851
- option_3 = ((option_1 != null) ? ((_arg = option_1, (_arg.tag === 1) ? " with set" : ((_arg.tag === 2) ? " with get, set" : " with get"))) : undefined);
818
+ option_3 = ((option_1 != null) ? accessorSuffix(option_1) : undefined);
852
819
  if (option_3 != null) {
853
820
  Printer__WriteInline_Z721C83C5(printer, option_3);
854
821
  }
@@ -859,8 +826,7 @@ function printClass(printer, classInfo) {
859
826
  }
860
827
 
861
828
  function printEnum(printer, enumInfo) {
862
- Printer__Write_Z721C83C5(printer, "[<RequireQualifiedAccess>]");
863
- Printer__get_NewLine(printer);
829
+ printAttributes(printer, singleton(FSharpAttribute.RequireQualifiedAccess));
864
830
  Printer__Write_Z721C83C5(printer, concat("type ", enumInfo.Name, " ="));
865
831
  Printer__get_NewLine(printer);
866
832
  Printer__get_Indent(printer);
@@ -943,14 +909,148 @@ function printDelegate(printer, delegateInfo) {
943
909
  Printer__get_Unindent(printer);
944
910
  }
945
911
 
946
- function print(printer_mut, fsharpTypes_mut) {
947
- print:
948
- while (true) {
949
- const printer = printer_mut, fsharpTypes = fsharpTypes_mut;
950
- if (isEmpty(fsharpTypes)) {
912
+ function printUnion(printer, unionInfo) {
913
+ printAttributes(printer, unionInfo.Attributes);
914
+ Printer__Write_Z721C83C5(printer, concat("type ", printTypeNameWithTypeParameters(unionInfo.Name, unionInfo.TypeParameters), " ="));
915
+ Printer__get_NewLine(printer);
916
+ Printer__get_Indent(printer);
917
+ iterate((enumCaseInfo) => {
918
+ Printer__Write_Z721C83C5(printer, "| ");
919
+ switch (enumCaseInfo.tag) {
920
+ case 1: {
921
+ Printer__WriteInline_Z721C83C5(printer, printType(enumCaseInfo.fields[0]));
922
+ break;
923
+ }
924
+ case 2: {
925
+ Printer__WriteInline_Z721C83C5(printer, concat(enumCaseInfo.fields[0], " of ", printType(enumCaseInfo.fields[1])));
926
+ break;
927
+ }
928
+ case 3: {
929
+ const fields = enumCaseInfo.fields[1];
930
+ const caseInfo = enumCaseInfo.fields[0];
931
+ printInlineAttributes(printer, caseInfo.Attributes);
932
+ Printer__WriteInline_Z721C83C5(printer, caseInfo.Name);
933
+ if (!isEmpty(fields)) {
934
+ Printer__WriteInline_Z721C83C5(printer, concat(" of ", join(" * ", map((tupledArg) => concat(tupledArg[0], ": ", printType(tupledArg[1])), fields))));
935
+ }
936
+ break;
937
+ }
938
+ default: {
939
+ const enumCaseInfo_1 = enumCaseInfo.fields[0];
940
+ printInlineAttributes(printer, enumCaseInfo_1.Attributes);
941
+ Printer__WriteInline_Z721C83C5(printer, enumCaseInfo_1.Name);
942
+ }
951
943
  }
952
- else {
953
- const fsharpType = head(fsharpTypes);
944
+ Printer__get_NewLine(printer);
945
+ }, unionInfo.Cases);
946
+ iterate((constant) => {
947
+ Printer__Write_Z721C83C5(printer, `static member inline ${constant.Name}: ${unionInfo.Name} = ${unionInfo.Name}.${constant.Case} ${constant.Value}`);
948
+ Printer__get_NewLine(printer);
949
+ }, unionInfo.Constants);
950
+ if (exists((_arg) => {
951
+ switch (_arg.tag) {
952
+ case 6:
953
+ case 7:
954
+ return true;
955
+ default:
956
+ return false;
957
+ }
958
+ }, unionInfo.Attributes)) {
959
+ const returnType = printTypeNameWithTypeParameters(unionInfo.Name, unionInfo.TypeParameters);
960
+ iterate((caseType) => {
961
+ const enumerator = getEnumerator(["op_Implicit", "op_ErasedCast"]);
962
+ try {
963
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
964
+ const name_2 = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
965
+ Printer__get_NewLine(printer);
966
+ Printer__Write_Z721C83C5(printer, "[<Emit(\"$0\")>]");
967
+ Printer__get_NewLine(printer);
968
+ Printer__Write_Z721C83C5(printer, `static member ${name_2}(value: ${caseType}) : ${returnType} = nativeOnly`);
969
+ Printer__get_NewLine(printer);
970
+ }
971
+ }
972
+ finally {
973
+ disposeSafe(enumerator);
974
+ }
975
+ }, List_distinct(choose((_arg_1) => {
976
+ if (_arg_1.tag === 2) {
977
+ return printType(_arg_1.fields[1]);
978
+ }
979
+ else {
980
+ return undefined;
981
+ }
982
+ }, unionInfo.Cases), {
983
+ Equals: (x, y) => (x === y),
984
+ GetHashCode: (x) => (stringHash(x) | 0),
985
+ }));
986
+ }
987
+ Printer__get_Unindent(printer);
988
+ }
989
+
990
+ function printSingleErasedCaseUnion(printer, erasedCaseUnionInfo) {
991
+ printXmlDoc(printer, erasedCaseUnionInfo.XmlDoc);
992
+ printAttributes(printer, cons(FSharpAttribute.Erase, erasedCaseUnionInfo.Attributes));
993
+ Printer__Write_Z721C83C5(printer, concat("type ", erasedCaseUnionInfo.Name));
994
+ printTypeParametersDeclaration(printer, singleton(erasedCaseUnionInfo.TypeParameter));
995
+ Printer__WriteInline_Z721C83C5(printer, " =");
996
+ Printer__get_NewLine(printer);
997
+ Printer__get_Indent(printer);
998
+ Printer__Write_Z721C83C5(printer, concat("| ", erasedCaseUnionInfo.Name, " of "));
999
+ const matchValue = erasedCaseUnionInfo.TypeParameter;
1000
+ if (matchValue.tag === 1) {
1001
+ Printer__WriteInline_Z721C83C5(printer, concat("\'", matchValue.fields[0].Name));
1002
+ }
1003
+ else {
1004
+ Printer__WriteInline_Z721C83C5(printer, printType(matchValue.fields[0]));
1005
+ }
1006
+ Printer__get_NewLine(printer);
1007
+ Printer__get_NewLine(printer);
1008
+ Printer__Write_Z721C83C5(printer, "member inline this.Value =");
1009
+ Printer__get_NewLine(printer);
1010
+ Printer__get_Indent(printer);
1011
+ Printer__Write_Z721C83C5(printer, concat("let (", erasedCaseUnionInfo.Name, " output) = this"));
1012
+ Printer__get_NewLine(printer);
1013
+ Printer__Write_Z721C83C5(printer, "output");
1014
+ Printer__get_NewLine(printer);
1015
+ Printer__get_Unindent(printer);
1016
+ Printer__get_Unindent(printer);
1017
+ }
1018
+
1019
+ function printTypeExtension(printer, extensionInfo) {
1020
+ printAttributes(printer, singleton(FSharpAttribute.AutoOpen));
1021
+ Printer__Write_Z721C83C5(printer, concat("module ", extensionInfo.ModuleName, " ="));
1022
+ Printer__get_NewLine(printer);
1023
+ Printer__get_Indent(printer);
1024
+ Printer__get_NewLine(printer);
1025
+ Printer__Write_Z721C83C5(printer, concat("type ", printTypeNameWithTypeParameters(extensionInfo.TargetName, extensionInfo.TypeParameters), " with"));
1026
+ Printer__get_NewLine(printer);
1027
+ Printer__get_Indent(printer);
1028
+ const enumerator = getEnumerator(extensionInfo.Members);
1029
+ try {
1030
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
1031
+ const extensionMember = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
1032
+ const parameters = join(", ", map((parameter) => concat(parameter.Name, ": ", printParameterType(parameter.Type)), extensionMember.Parameters));
1033
+ const arguments$ = join(", ", map((_arg) => _arg.Name, extensionMember.Parameters));
1034
+ Printer__Write_Z721C83C5(printer, `member inline this.${extensionMember.Name}(${parameters}) : ${printType(extensionMember.ReturnType)} =`);
1035
+ Printer__get_NewLine(printer);
1036
+ Printer__get_Indent(printer);
1037
+ Printer__Write_Z721C83C5(printer, `this.${extensionMember.Name}.Invoke(${arguments$})`);
1038
+ Printer__get_NewLine(printer);
1039
+ Printer__get_Unindent(printer);
1040
+ }
1041
+ }
1042
+ finally {
1043
+ disposeSafe(enumerator);
1044
+ }
1045
+ Printer__get_Unindent(printer);
1046
+ Printer__get_Unindent(printer);
1047
+ }
1048
+
1049
+ function print(printer, fsharpTypes) {
1050
+ const enumerator = getEnumerator(fsharpTypes);
1051
+ try {
1052
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
1053
+ const fsharpType = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
954
1054
  Printer__get_NewLine(printer);
955
1055
  switch (fsharpType.tag) {
956
1056
  case 0: {
@@ -994,33 +1094,7 @@ function print(printer_mut, fsharpTypes_mut) {
994
1094
  break;
995
1095
  }
996
1096
  case 2: {
997
- const erasedCaseUnionInfo = fsharpType.fields[0];
998
- printXmlDoc(printer, erasedCaseUnionInfo.XmlDoc);
999
- printAttributes(printer, cons(FSharpAttribute.Erase, erasedCaseUnionInfo.Attributes));
1000
- Printer__Write_Z721C83C5(printer, concat("type ", erasedCaseUnionInfo.Name));
1001
- printTypeParametersDeclaration(printer, singleton(erasedCaseUnionInfo.TypeParameter));
1002
- Printer__WriteInline_Z721C83C5(printer, " =");
1003
- Printer__get_NewLine(printer);
1004
- Printer__get_Indent(printer);
1005
- Printer__Write_Z721C83C5(printer, concat("| ", erasedCaseUnionInfo.Name, " of "));
1006
- const matchValue = erasedCaseUnionInfo.TypeParameter;
1007
- if (matchValue.tag === 1) {
1008
- Printer__WriteInline_Z721C83C5(printer, concat("\'", matchValue.fields[0].Name));
1009
- }
1010
- else {
1011
- Printer__WriteInline_Z721C83C5(printer, printType(matchValue.fields[0]));
1012
- }
1013
- Printer__get_NewLine(printer);
1014
- Printer__get_NewLine(printer);
1015
- Printer__Write_Z721C83C5(printer, "member inline this.Value =");
1016
- Printer__get_NewLine(printer);
1017
- Printer__get_Indent(printer);
1018
- Printer__Write_Z721C83C5(printer, concat("let (", erasedCaseUnionInfo.Name, " output) = this"));
1019
- Printer__get_NewLine(printer);
1020
- Printer__Write_Z721C83C5(printer, "output");
1021
- Printer__get_NewLine(printer);
1022
- Printer__get_Unindent(printer);
1023
- Printer__get_Unindent(printer);
1097
+ printSingleErasedCaseUnion(printer, fsharpType.fields[0]);
1024
1098
  break;
1025
1099
  }
1026
1100
  case 20: {
@@ -1028,34 +1102,7 @@ function print(printer_mut, fsharpTypes_mut) {
1028
1102
  break;
1029
1103
  }
1030
1104
  case 21: {
1031
- const extensionInfo = fsharpType.fields[0];
1032
- printAttributes(printer, singleton(FSharpAttribute.AutoOpen));
1033
- Printer__Write_Z721C83C5(printer, concat("module ", extensionInfo.ModuleName, " ="));
1034
- Printer__get_NewLine(printer);
1035
- Printer__get_Indent(printer);
1036
- Printer__get_NewLine(printer);
1037
- Printer__Write_Z721C83C5(printer, concat("type ", printTypeNameWithTypeParameters(extensionInfo.TargetName, extensionInfo.TypeParameters), " with"));
1038
- Printer__get_NewLine(printer);
1039
- Printer__get_Indent(printer);
1040
- const enumerator = getEnumerator(extensionInfo.Members);
1041
- try {
1042
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
1043
- const extensionMember = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
1044
- const parameters = join(", ", map((parameter) => concat(parameter.Name, ": ", printParameterType(parameter.Type)), extensionMember.Parameters));
1045
- const arguments$ = join(", ", map((_arg) => _arg.Name, extensionMember.Parameters));
1046
- Printer__Write_Z721C83C5(printer, `member inline this.${extensionMember.Name}(${parameters}) : ${printType(extensionMember.ReturnType)} =`);
1047
- Printer__get_NewLine(printer);
1048
- Printer__get_Indent(printer);
1049
- Printer__Write_Z721C83C5(printer, `this.${extensionMember.Name}.Invoke(${arguments$})`);
1050
- Printer__get_NewLine(printer);
1051
- Printer__get_Unindent(printer);
1052
- }
1053
- }
1054
- finally {
1055
- disposeSafe(enumerator);
1056
- }
1057
- Printer__get_Unindent(printer);
1058
- Printer__get_Unindent(printer);
1105
+ printTypeExtension(printer, fsharpType.fields[0]);
1059
1106
  break;
1060
1107
  }
1061
1108
  case 7:
@@ -1072,54 +1119,13 @@ function print(printer_mut, fsharpTypes_mut) {
1072
1119
  case 15: {
1073
1120
  break;
1074
1121
  }
1075
- default: {
1076
- const unionInfo = fsharpType.fields[0];
1077
- printAttributes(printer, unionInfo.Attributes);
1078
- Printer__Write_Z721C83C5(printer, concat("type ", printTypeNameWithTypeParameters(unionInfo.Name, unionInfo.TypeParameters), " ="));
1079
- Printer__get_NewLine(printer);
1080
- Printer__get_Indent(printer);
1081
- iterate((enumCaseInfo) => {
1082
- Printer__Write_Z721C83C5(printer, "| ");
1083
- switch (enumCaseInfo.tag) {
1084
- case 1: {
1085
- Printer__WriteInline_Z721C83C5(printer, printType(enumCaseInfo.fields[0]));
1086
- Printer__get_NewLine(printer);
1087
- break;
1088
- }
1089
- case 2: {
1090
- Printer__WriteInline_Z721C83C5(printer, concat(enumCaseInfo.fields[0], " of ", printType(enumCaseInfo.fields[1])));
1091
- break;
1092
- }
1093
- case 3: {
1094
- const fields = enumCaseInfo.fields[1];
1095
- const caseInfo = enumCaseInfo.fields[0];
1096
- printInlineAttributes(printer, caseInfo.Attributes);
1097
- Printer__WriteInline_Z721C83C5(printer, caseInfo.Name);
1098
- if (!isEmpty(fields)) {
1099
- Printer__WriteInline_Z721C83C5(printer, concat(" of ", join(" * ", map((tupledArg) => concat(tupledArg[0], ": ", printType(tupledArg[1])), fields))));
1100
- }
1101
- break;
1102
- }
1103
- default: {
1104
- const enumCaseInfo_1 = enumCaseInfo.fields[0];
1105
- printInlineAttributes(printer, enumCaseInfo_1.Attributes);
1106
- Printer__WriteInline_Z721C83C5(printer, enumCaseInfo_1.Name);
1107
- }
1108
- }
1109
- Printer__get_NewLine(printer);
1110
- }, unionInfo.Cases);
1111
- iterate((constant) => {
1112
- Printer__Write_Z721C83C5(printer, `static member inline ${constant.Name}: ${unionInfo.Name} = ${unionInfo.Name}.${constant.Case} ${constant.Value}`);
1113
- Printer__get_NewLine(printer);
1114
- }, unionInfo.Constants);
1115
- Printer__get_Unindent(printer);
1116
- }
1122
+ default:
1123
+ printUnion(printer, fsharpType.fields[0]);
1117
1124
  }
1118
- printer_mut = printer;
1119
- fsharpTypes_mut = tail_1(fsharpTypes);
1120
- continue print;
1121
1125
  }
1122
- break;
1126
+ }
1127
+ finally {
1128
+ disposeSafe(enumerator);
1123
1129
  }
1124
1130
  }
1125
1131
 
@@ -1134,19 +1140,24 @@ export function printFileWith(namespace_, isPackage, externalBindings, printer,
1134
1140
  const bodyPrinter = Printer_$ctor();
1135
1141
  print(bodyPrinter, transformResult.FSharpAST);
1136
1142
  body = toString(bodyPrinter);
1137
- const outFile = new FSharpOutFile(namespace_, ofArray(["Fable.Core", "Fable.Core.JsInterop", "System"]));
1138
1143
  if (isPackage) {
1139
- Printer__Write_Z721C83C5(printer, concat("namespace rec ", outFile.Name));
1144
+ Printer__Write_Z721C83C5(printer, concat("namespace rec ", namespace_));
1140
1145
  }
1141
1146
  else {
1142
- Printer__Write_Z721C83C5(printer, concat("module rec ", outFile.Name));
1147
+ Printer__Write_Z721C83C5(printer, concat("module rec ", namespace_));
1143
1148
  }
1144
1149
  Printer__get_NewLine(printer);
1145
1150
  Printer__get_NewLine(printer);
1146
- iterate((o) => {
1147
- Printer__Write_Z721C83C5(printer, concat("open ", o));
1148
- Printer__get_NewLine(printer);
1149
- }, outFile.Opens);
1151
+ const enumerator = getEnumerator(["Fable.Core", "Fable.Core.JsInterop", "System"]);
1152
+ try {
1153
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
1154
+ Printer__Write_Z721C83C5(printer, concat("open ", enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]()));
1155
+ Printer__get_NewLine(printer);
1156
+ }
1157
+ }
1158
+ finally {
1159
+ disposeSafe(enumerator);
1160
+ }
1150
1161
  if (transformResult.IncludeReadonlyArrayAlias && !namespace_.startsWith("Glutinum.Types")) {
1151
1162
  Printer__get_NewLine(printer);
1152
1163
  Printer__Write_Z721C83C5(printer, "// You need to add Glutinum.Types NuGet package to your project");
@@ -1154,10 +1165,10 @@ export function printFileWith(namespace_, isPackage, externalBindings, printer,
1154
1165
  Printer__Write_Z721C83C5(printer, "open Glutinum.Types.TypeScript");
1155
1166
  Printer__get_NewLine(printer);
1156
1167
  }
1157
- const enumerator = getEnumerator(externalBindings);
1168
+ const enumerator_1 = getEnumerator(externalBindings);
1158
1169
  try {
1159
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
1160
- const externalBinding = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
1170
+ while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
1171
+ const externalBinding = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
1161
1172
  if (body.indexOf(concat("Glutinum.", externalBinding, ".")) >= 0) {
1162
1173
  Printer__get_NewLine(printer);
1163
1174
  Printer__Write_Z721C83C5(printer, concat("// You need to add Glutinum.", externalBinding, " NuGet package to your project"));
@@ -1166,7 +1177,7 @@ export function printFileWith(namespace_, isPackage, externalBindings, printer,
1166
1177
  }
1167
1178
  }
1168
1179
  finally {
1169
- disposeSafe(enumerator);
1180
+ disposeSafe(enumerator_1);
1170
1181
  }
1171
1182
  if (transformResult.IncludeRegExpAlias) {
1172
1183
  Printer__get_NewLine(printer);