@glutinum/cli 0.14.1 → 1.0.0-beta.10

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 (64) 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 +154 -69
  6. package/dist/Glutinum.Converter/Generate.js +44 -23
  7. package/dist/Glutinum.Converter/GlueAST.js +122 -74
  8. package/dist/Glutinum.Converter/Hosting.js +892 -0
  9. package/dist/Glutinum.Converter/Merge.js +469 -301
  10. package/dist/Glutinum.Converter/Packages.js +403 -77
  11. package/dist/Glutinum.Converter/Printer.js +455 -388
  12. package/dist/Glutinum.Converter/Read.js +366 -104
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +9 -9
  14. package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
  15. package/dist/Glutinum.Converter/Reader/Declaration.js +24 -30
  16. package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
  17. package/dist/Glutinum.Converter/Reader/Documentation.js +56 -67
  18. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +105 -38
  19. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +52 -55
  20. package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
  21. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +28 -16
  22. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +46 -45
  23. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +48 -5
  24. package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
  25. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
  26. package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
  27. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +55 -7
  28. package/dist/Glutinum.Converter/Reader/Node.js +23 -26
  29. package/dist/Glutinum.Converter/Reader/Parameters.js +39 -30
  30. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
  31. package/dist/Glutinum.Converter/Reader/TypeNode.js +410 -1545
  32. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +78 -51
  33. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +116 -71
  34. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +25 -7
  35. package/dist/Glutinum.Converter/Reader/Types.js +296 -16
  36. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +21 -34
  37. package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
  38. package/dist/Glutinum.Converter/Reader/Utils.js +584 -148
  39. package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
  40. package/dist/Glutinum.Converter/Transform.js +2971 -6875
  41. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  42. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  43. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  44. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1087 -0
  45. package/dist/Glutinum.Converter/Transformer/Context.js +678 -0
  46. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  47. package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
  48. package/dist/Glutinum.Converter/Transformer/Heritage.js +493 -0
  49. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  50. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
  51. package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
  52. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  53. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +356 -0
  54. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  55. package/dist/Glutinum.Converter/TypeScript.Extensions.js +193 -211
  56. package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
  57. package/dist/Glutinum.Converter/Utils/String.js +15 -4
  58. package/dist/Program.js +107 -232
  59. package/package.json +4 -3
  60. package/dist/Glutinum.Converter/TypeScript.js +0 -12
  61. package/src/Glutinum.Converter/js/bootstrap.js +0 -123
  62. package/src/Glutinum.Converter/js/host.js +0 -144
  63. package/src/Glutinum.Converter/js/npm.js +0 -137
  64. package/src/Glutinum.Converter/js/resolve.js +0 -402
@@ -1,25 +1,29 @@
1
1
 
2
- import bootstrap from "../../src/Glutinum.Converter/js/bootstrap.js";
3
- import * as fs from "fs";
4
- import { disposeSafe, getEnumerator, Exception } from "../fable_modules/fable-library-js.5.17.2/Util.js";
2
+ import { createNodeHost, Bootstrap_createProgramForCLI } from "./Hosting.js";
3
+ import { readFileSync, existsSync } from "fs";
4
+ import { comparePrimitives, disposeSafe, getEnumerator, Exception } from "../fable_modules/fable-library-js.5.17.2/Util.js";
5
5
  import { concat } from "../fable_modules/fable-library-js.5.17.2/String.js";
6
- import { toString } from "../fable_modules/fable-library-js.5.17.2/Types.js";
7
- import { printFile, Printer_$ctor } from "./Printer.js";
6
+ import { printFileWith, Printer_$ctor } from "./Printer.js";
8
7
  import { readSourceFile } from "./Read.js";
9
8
  import { error as error_1, warn } from "./Log.js";
10
- import { applyWith } from "./Transform.js";
9
+ import { TransformOptions, applyWithOptions } from "./Transform.js";
10
+ import { ImportSource } from "./Transformer/Context.js";
11
11
  import { defaultArg } from "../fable_modules/fable-library-js.5.17.2/Option.js";
12
- import { generateWith, defaultOptions } from "./Packages.js";
13
- import { createNodeHost } from "../../src/Glutinum.Converter/js/host.js";
14
- import * as path from "path";
12
+ import { empty } from "../fable_modules/fable-library-js.5.17.2/Map.js";
13
+ import { empty as empty_1 } from "../fable_modules/fable-library-js.5.17.2/List.js";
14
+ import { toString } from "../fable_modules/fable-library-js.5.17.2/Types.js";
15
+ import { defaultMaxOverloads } from "./Transformer/UnionOverloads.js";
16
+ import { defaultOptions, generateWith } from "./Packages.js";
15
17
 
16
- export const createProgramForCLI = bootstrap;
18
+ export function createProgramForCLI(fileName, source) {
19
+ return Bootstrap_createProgramForCLI(fileName, source);
20
+ }
17
21
 
18
- export function generateBindingFile(filePath) {
19
- if (!fs.existsSync(filePath)) {
22
+ function generateFile(moduleName, isGlobal, maxOverloads, filePath) {
23
+ if (!existsSync(filePath)) {
20
24
  throw new Exception(concat("File does not exist: ", filePath));
21
25
  }
22
- const program = createProgramForCLI(filePath, toString(fs.readFileSync(filePath)));
26
+ const program = createProgramForCLI(filePath, readFileSync(filePath, "utf8"));
23
27
  const checker = program.getTypeChecker();
24
28
  const sourceFile = program.getSourceFile(filePath);
25
29
  const printer = Printer_$ctor();
@@ -33,7 +37,9 @@ export function generateBindingFile(filePath) {
33
37
  finally {
34
38
  disposeSafe(enumerator);
35
39
  }
36
- const transformResult = applyWith(defaultArg(readerResult.ImportSpecifier, "REPLACE_ME_WITH_MODULE_NAME"), readerResult.TypeMemory, readerResult.GlueAST);
40
+ const transformResult = applyWithOptions(new TransformOptions(isGlobal ? ImportSource.Global : (new ImportSource(/* Module */ 0, [defaultArg(readerResult.ImportSpecifier, "REPLACE_ME_WITH_MODULE_NAME"), empty({
41
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
42
+ })])), maxOverloads), readerResult.TypeMemory, readerResult.GlueAST);
37
43
  let enumerator_1 = getEnumerator(transformResult.Warnings);
38
44
  try {
39
45
  while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
@@ -52,16 +58,23 @@ export function generateBindingFile(filePath) {
52
58
  finally {
53
59
  disposeSafe(enumerator_2);
54
60
  }
55
- printFile(printer, transformResult);
61
+ printFileWith(moduleName, false, empty_1(), printer, transformResult);
56
62
  return toString(printer);
57
63
  }
58
64
 
65
+ export function generateBindingFileWith(moduleName, filePath) {
66
+ return generateFile(moduleName, false, defaultMaxOverloads, filePath);
67
+ }
68
+
59
69
  /**
60
- * Generate a single binding file for the packages, and the packages they depend on.
61
- * An empty list generates every package installed in the nearest <c>node_modules</c>.
70
+ * `isGlobal`: the file declares the globals of a script, nothing is imported
62
71
  */
63
- export function generatePackagesWith(host, inputs) {
64
- return generatePackagesWithOptions(defaultOptions, host, inputs);
72
+ export function generateBindingFileWithOptions(moduleName, isGlobal, maxOverloads, filePath) {
73
+ return generateFile(moduleName, isGlobal, maxOverloads, filePath);
74
+ }
75
+
76
+ export function generateBindingFile(filePath) {
77
+ return generateBindingFileWith("Glutinum", filePath);
65
78
  }
66
79
 
67
80
  export function generatePackagesWithOptions(options, host, inputs) {
@@ -88,13 +101,21 @@ export function generatePackagesWithOptions(options, host, inputs) {
88
101
  }
89
102
 
90
103
  /**
91
- * The packages installed on the disk, from the current directory
104
+ * Generate a single binding file for the packages, and the packages they depend on.
105
+ * An empty list generates every package installed in the nearest <c>node_modules</c>.
92
106
  */
93
- export function generatePackages(inputs) {
94
- return generatePackagesFromDisk(defaultOptions, inputs);
107
+ export function generatePackagesWith(host, inputs) {
108
+ return generatePackagesWithOptions(defaultOptions, host, inputs);
95
109
  }
96
110
 
97
111
  export function generatePackagesFromDisk(options, inputs) {
98
- return generatePackagesWithOptions(options, createNodeHost(fs, path, process.cwd()), inputs);
112
+ return generatePackagesWithOptions(options, createNodeHost(process.cwd()), inputs);
113
+ }
114
+
115
+ /**
116
+ * The packages installed on the disk, from the current directory
117
+ */
118
+ export function generatePackages(inputs) {
119
+ return generatePackagesFromDisk(defaultOptions, inputs);
99
120
  }
100
121
 
@@ -1,11 +1,12 @@
1
1
 
2
2
  import { toString, Union, Record } from "../fable_modules/fable-library-js.5.17.2/Types.js";
3
- import { float64_type, int32_type, bool_type, union_type, list_type, record_type, option_type, string_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
4
- import { append, singleton, map, collect, empty } from "../fable_modules/fable-library-js.5.17.2/List.js";
5
- import { stringHash, int32ToString } from "../fable_modules/fable-library-js.5.17.2/Util.js";
3
+ import { class_type, float64_type, int32_type, bool_type, union_type, list_type, record_type, option_type, string_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
4
+ import { tryItem, mapIndexed, append, singleton, map, collect, empty } from "../fable_modules/fable-library-js.5.17.2/List.js";
5
+ import { comparePrimitives, stringHash, int32ToString } from "../fable_modules/fable-library-js.5.17.2/Util.js";
6
6
  import { join, concat } from "../fable_modules/fable-library-js.5.17.2/String.js";
7
- import { tryFind } from "../fable_modules/fable-library-js.5.17.2/Map.js";
7
+ import { map as map_1, ofList, tryFind } from "../fable_modules/fable-library-js.5.17.2/Map.js";
8
8
  import { List_distinctBy } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
9
+ import { orElse, defaultArg } from "../fable_modules/fable-library-js.5.17.2/Option.js";
9
10
 
10
11
  export class GlueCommentParam extends Record {
11
12
  constructor(Name, Content) {
@@ -182,18 +183,19 @@ export function GlueIndexSignature_$reflection() {
182
183
  }
183
184
 
184
185
  export class GlueMethodSignature extends Record {
185
- constructor(Name, Documentation, TypeParameters, Parameters, Type) {
186
+ constructor(Name, Documentation, TypeParameters, Parameters, Type, IsOptional) {
186
187
  super();
187
188
  this.Name = Name;
188
189
  this.Documentation = Documentation;
189
190
  this.TypeParameters = TypeParameters;
190
191
  this.Parameters = Parameters;
191
192
  this.Type = Type;
193
+ this.IsOptional = IsOptional;
192
194
  }
193
195
  }
194
196
 
195
197
  export function GlueMethodSignature_$reflection() {
196
- return record_type("Glutinum.Converter.GlueAST.GlueMethodSignature", [], GlueMethodSignature, () => [["Name", string_type], ["Documentation", list_type(GlueComment_$reflection())], ["TypeParameters", list_type(GlueTypeParameter_$reflection())], ["Parameters", list_type(GlueParameter_$reflection())], ["Type", GlueType_$reflection()]]);
198
+ return record_type("Glutinum.Converter.GlueAST.GlueMethodSignature", [], GlueMethodSignature, () => [["Name", string_type], ["Documentation", list_type(GlueComment_$reflection())], ["TypeParameters", list_type(GlueTypeParameter_$reflection())], ["Parameters", list_type(GlueParameter_$reflection())], ["Type", GlueType_$reflection()], ["IsOptional", bool_type]]);
197
199
  }
198
200
 
199
201
  export class GlueConstructSignature extends Record {
@@ -240,14 +242,15 @@ export function GlueInterface_$reflection() {
240
242
  }
241
243
 
242
244
  export class GlueTypeLiteral extends Record {
243
- constructor(Members) {
245
+ constructor(Members, Id) {
244
246
  super();
245
247
  this.Members = Members;
248
+ this.Id = Id;
246
249
  }
247
250
  }
248
251
 
249
252
  export function GlueTypeLiteral_$reflection() {
250
- return record_type("Glutinum.Converter.GlueAST.GlueTypeLiteral", [], GlueTypeLiteral, () => [["Members", list_type(GlueMember_$reflection())]]);
253
+ return record_type("Glutinum.Converter.GlueAST.GlueTypeLiteral", [], GlueTypeLiteral, () => [["Members", list_type(GlueMember_$reflection())], ["Id", option_type(string_type)]]);
251
254
  }
252
255
 
253
256
  export class GlueVariable extends Record {
@@ -363,20 +366,21 @@ export function GlueFunctionDeclaration_$reflection() {
363
366
  }
364
367
 
365
368
  export class GlueModuleDeclaration extends Record {
366
- constructor(Documentation, Name, IsTopLevel, IsNamespace, IsGlobal, IsRecursive, Types) {
369
+ constructor(Documentation, Name, IsTopLevel, IsNamespace, IsGlobal, IsExported, IsRecursive, Types) {
367
370
  super();
368
371
  this.Documentation = Documentation;
369
372
  this.Name = Name;
370
373
  this.IsTopLevel = IsTopLevel;
371
374
  this.IsNamespace = IsNamespace;
372
375
  this.IsGlobal = IsGlobal;
376
+ this.IsExported = IsExported;
373
377
  this.IsRecursive = IsRecursive;
374
378
  this.Types = Types;
375
379
  }
376
380
  }
377
381
 
378
382
  export function GlueModuleDeclaration_$reflection() {
379
- return record_type("Glutinum.Converter.GlueAST.GlueModuleDeclaration", [], GlueModuleDeclaration, () => [["Documentation", list_type(GlueComment_$reflection())], ["Name", string_type], ["IsTopLevel", bool_type], ["IsNamespace", bool_type], ["IsGlobal", bool_type], ["IsRecursive", bool_type], ["Types", list_type(GlueType_$reflection())]]);
383
+ return record_type("Glutinum.Converter.GlueAST.GlueModuleDeclaration", [], GlueModuleDeclaration, () => [["Documentation", list_type(GlueComment_$reflection())], ["Name", string_type], ["IsTopLevel", bool_type], ["IsNamespace", bool_type], ["IsGlobal", bool_type], ["IsExported", bool_type], ["IsRecursive", bool_type], ["Types", list_type(GlueType_$reflection())]]);
380
384
  }
381
385
 
382
386
  export class GlueConstructor extends Record {
@@ -439,21 +443,6 @@ export function GlueTypeUnion_$reflection() {
439
443
  return union_type("Glutinum.Converter.GlueAST.GlueTypeUnion", [], GlueTypeUnion, () => [[["Item", list_type(GlueType_$reflection())]]]);
440
444
  }
441
445
 
442
- export class ExcludedMember extends Union {
443
- constructor(Item) {
444
- super();
445
- this.tag = 0;
446
- this.fields = [Item];
447
- }
448
- cases() {
449
- return ["Literal"];
450
- }
451
- }
452
-
453
- export function ExcludedMember_$reflection() {
454
- return union_type("Glutinum.Converter.GlueAST.ExcludedMember", [], ExcludedMember, () => [[["Item", GlueLiteral_$reflection()]]]);
455
- }
456
-
457
446
  export class GlueFunctionType extends Record {
458
447
  constructor(Documentation, Type, TypeParameters, OwnTypeParameterNames, Parameters) {
459
448
  super();
@@ -515,12 +504,12 @@ export class GlueUtilityType extends Union {
515
504
  this.fields = fields;
516
505
  }
517
506
  cases() {
518
- return ["Partial", "Record", "ReturnType", "ThisParameterType", "Omit", "Readonly"];
507
+ return ["Partial", "Record", "ReturnType", "ThisParameterType", "Omit", "Pick", "Readonly"];
519
508
  }
520
509
  }
521
510
 
522
511
  export function GlueUtilityType_$reflection() {
523
- return union_type("Glutinum.Converter.GlueAST.GlueUtilityType", [], GlueUtilityType, () => [[["Item", GlueInterface_$reflection()]], [["Item", GlueRecord_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", list_type(GlueMember_$reflection())]], [["Item", GlueReadonly_$reflection()]]]);
512
+ return union_type("Glutinum.Converter.GlueAST.GlueUtilityType", [], GlueUtilityType, () => [[["Item", GlueInterface_$reflection()]], [["Item", GlueRecord_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", list_type(GlueMember_$reflection())]], [["Item", list_type(GlueMember_$reflection())]], [["Item", GlueReadonly_$reflection()]]]);
524
513
  }
525
514
 
526
515
  export class GlueMappedType extends Record {
@@ -566,43 +555,46 @@ export class GlueType extends Union {
566
555
  this.fields = fields;
567
556
  }
568
557
  cases() {
569
- return ["Discard", "Interface", "Variable", "Primitive", "Enum", "TypeAliasDeclaration", "FunctionDeclaration", "Union", "Literal", "KeyOf", "IndexedAccessType", "ModuleDeclaration", "ClassDeclaration", "TypeReference", "Array", "FunctionType", "TypeParameter", "ThisType", "TupleType", "NamedTupleType", "IntersectionType", "TypeLiteral", "OptionalType", "Unknown", "ExportDefault", "TemplateLiteral", "UtilityType", "MappedType", "ConstructorType", "ReadOnly", "FileModule", "ReExport", "ConditionalType"];
558
+ return ["Discard", "Interface", "Variable", "Primitive", "Enum", "TypeAliasDeclaration", "FunctionDeclaration", "Union", "Literal", "KeyOf", "IndexedAccessType", "ModuleDeclaration", "ClassDeclaration", "TypeReference", "Array", "FunctionType", "TypeParameter", "ThisType", "TupleType", "NamedTupleType", "IntersectionType", "IntersectionOfReferences", "TypeLiteral", "OptionalType", "Unknown", "ExportDefault", "TemplateLiteral", "UtilityType", "MappedType", "ConstructorType", "ReadOnly", "FileModule", "ReExport", "ConditionalType"];
570
559
  }
571
560
  static Discard = new GlueType(0, []);
572
- static Unknown = new GlueType(23, []);
573
- static TemplateLiteral = new GlueType(25, []);
561
+ static Unknown = new GlueType(24, []);
562
+ static TemplateLiteral = new GlueType(26, []);
574
563
  }
575
564
 
576
565
  export function GlueType_$reflection() {
577
- return union_type("Glutinum.Converter.GlueAST.GlueType", [], GlueType, () => [[], [["Item", GlueInterface_$reflection()]], [["Item", GlueVariable_$reflection()]], [["Item", GluePrimitive_$reflection()]], [["Item", GlueEnum_$reflection()]], [["Item", GlueTypeAliasDeclaration_$reflection()]], [["Item", GlueFunctionDeclaration_$reflection()]], [["Item", GlueTypeUnion_$reflection()]], [["Item", GlueLiteral_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueIndexedAccessType_$reflection()]], [["Item", GlueModuleDeclaration_$reflection()]], [["Item", GlueClassDeclaration_$reflection()]], [["Item", GlueTypeReference_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueFunctionType_$reflection()]], [["Item", string_type]], [["Item", GlueThisType_$reflection()]], [["Item", list_type(GlueType_$reflection())]], [["Item", NamedTupleType_$reflection()]], [["Item", list_type(GlueMember_$reflection())]], [["Item", GlueTypeLiteral_$reflection()]], [["Item", GlueType_$reflection()]], [], [["Item", GlueType_$reflection()]], [], [["Item", GlueUtilityType_$reflection()]], [["Item", GlueMappedType_$reflection()]], [["Item", GlueConstructSignature_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueFileModule_$reflection()]], [["Item", GlueReExport_$reflection()]], [["Item", GlueConditionalType_$reflection()]]]);
566
+ return union_type("Glutinum.Converter.GlueAST.GlueType", [], GlueType, () => [[], [["Item", GlueInterface_$reflection()]], [["Item", GlueVariable_$reflection()]], [["Item", GluePrimitive_$reflection()]], [["Item", GlueEnum_$reflection()]], [["Item", GlueTypeAliasDeclaration_$reflection()]], [["Item", GlueFunctionDeclaration_$reflection()]], [["Item", GlueTypeUnion_$reflection()]], [["Item", GlueLiteral_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueIndexedAccessType_$reflection()]], [["Item", GlueModuleDeclaration_$reflection()]], [["Item", GlueClassDeclaration_$reflection()]], [["Item", GlueTypeReference_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueFunctionType_$reflection()]], [["Item", string_type]], [["Item", GlueThisType_$reflection()]], [["Item", list_type(GlueType_$reflection())]], [["Item", NamedTupleType_$reflection()]], [["Item", list_type(GlueMember_$reflection())]], [["references", list_type(GlueType_$reflection())], ["members", list_type(GlueMember_$reflection())]], [["Item", GlueTypeLiteral_$reflection()]], [["Item", GlueType_$reflection()]], [], [["Item", GlueType_$reflection()]], [], [["Item", GlueUtilityType_$reflection()]], [["Item", GlueMappedType_$reflection()]], [["Item", GlueConstructSignature_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueFileModule_$reflection()]], [["Item", GlueReExport_$reflection()]], [["Item", GlueConditionalType_$reflection()]]]);
578
567
  }
579
568
 
580
569
  export class GlueFileModule extends Record {
581
- constructor(Name, ImportSpecifier, IsGlobal, Types) {
570
+ constructor(Name, ImportSpecifier, SymbolSpecifiers, IsGlobal, HasRuntime, Types) {
582
571
  super();
583
572
  this.Name = Name;
584
573
  this.ImportSpecifier = ImportSpecifier;
574
+ this.SymbolSpecifiers = SymbolSpecifiers;
585
575
  this.IsGlobal = IsGlobal;
576
+ this.HasRuntime = HasRuntime;
586
577
  this.Types = Types;
587
578
  }
588
579
  }
589
580
 
590
581
  export function GlueFileModule_$reflection() {
591
- return record_type("Glutinum.Converter.GlueAST.GlueFileModule", [], GlueFileModule, () => [["Name", string_type], ["ImportSpecifier", string_type], ["IsGlobal", bool_type], ["Types", list_type(GlueType_$reflection())]]);
582
+ return record_type("Glutinum.Converter.GlueAST.GlueFileModule", [], GlueFileModule, () => [["Name", string_type], ["ImportSpecifier", string_type], ["SymbolSpecifiers", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, string_type])], ["IsGlobal", bool_type], ["HasRuntime", bool_type], ["Types", list_type(GlueType_$reflection())]]);
592
583
  }
593
584
 
594
585
  export class GlueConditionalType extends Record {
595
- constructor(CheckType, ExtendsType, TrueType, FalseType) {
586
+ constructor(CheckType, ExtendsType, TrueType, FalseType, Inferred) {
596
587
  super();
597
588
  this.CheckType = CheckType;
598
589
  this.ExtendsType = ExtendsType;
599
590
  this.TrueType = TrueType;
600
591
  this.FalseType = FalseType;
592
+ this.Inferred = Inferred;
601
593
  }
602
594
  }
603
595
 
604
596
  export function GlueConditionalType_$reflection() {
605
- return record_type("Glutinum.Converter.GlueAST.GlueConditionalType", [], GlueConditionalType, () => [["CheckType", GlueType_$reflection()], ["ExtendsType", GlueType_$reflection()], ["TrueType", GlueType_$reflection()], ["FalseType", GlueType_$reflection()]]);
597
+ return record_type("Glutinum.Converter.GlueAST.GlueConditionalType", [], GlueConditionalType, () => [["CheckType", GlueType_$reflection()], ["ExtendsType", GlueType_$reflection()], ["TrueType", GlueType_$reflection()], ["FalseType", GlueType_$reflection()], ["Inferred", list_type(GlueTypeParameter_$reflection())]]);
606
598
  }
607
599
 
608
600
  export class GlueReExport extends Record {
@@ -691,24 +683,63 @@ export function GlueLiteral__ToText(this$) {
691
683
  }
692
684
 
693
685
  export function GlueUtilityType__get_TypeParameters(this$) {
686
+ let matchResult, info, returnType, thisType, members, members_1, interfaces;
694
687
  switch (this$.tag) {
688
+ case 1: {
689
+ matchResult = 1;
690
+ break;
691
+ }
692
+ case 2: {
693
+ matchResult = 2;
694
+ returnType = this$.fields[0];
695
+ break;
696
+ }
697
+ case 3: {
698
+ matchResult = 3;
699
+ thisType = this$.fields[0];
700
+ break;
701
+ }
702
+ case 4: {
703
+ matchResult = 4;
704
+ members = this$.fields[0];
705
+ break;
706
+ }
707
+ case 5: {
708
+ matchResult = 4;
709
+ members = this$.fields[0];
710
+ break;
711
+ }
712
+ case 6: {
713
+ if (this$.fields[0].tag === 1) {
714
+ matchResult = 6;
715
+ interfaces = this$.fields[0].fields[0];
716
+ }
717
+ else {
718
+ matchResult = 5;
719
+ members_1 = this$.fields[0].fields[0];
720
+ }
721
+ break;
722
+ }
723
+ default: {
724
+ matchResult = 0;
725
+ info = this$.fields[0];
726
+ }
727
+ }
728
+ switch (matchResult) {
729
+ case 0:
730
+ return info.TypeParameters;
695
731
  case 1:
696
732
  return empty();
697
733
  case 2:
698
- return GlueType__get_TypeParameters(this$.fields[0]);
734
+ return GlueType__get_TypeParameters(returnType);
699
735
  case 3:
700
- return GlueType__get_TypeParameters(this$.fields[0]);
736
+ return GlueType__get_TypeParameters(thisType);
701
737
  case 4:
702
- return collect(GlueMember__get_TypeParameters, this$.fields[0]);
738
+ return collect(GlueMember__get_TypeParameters, members);
703
739
  case 5:
704
- if (this$.fields[0].tag === 1) {
705
- return collect((interfaceInfo) => interfaceInfo.TypeParameters, this$.fields[0].fields[0]);
706
- }
707
- else {
708
- return collect(GlueMember__get_TypeParameters, this$.fields[0].fields[0]);
709
- }
740
+ return collect(GlueMember__get_TypeParameters, members_1);
710
741
  default:
711
- return this$.fields[0].TypeParameters;
742
+ return collect((interfaceInfo) => interfaceInfo.TypeParameters, interfaces);
712
743
  }
713
744
  }
714
745
 
@@ -747,7 +778,7 @@ export function GlueType__get_Name(this$) {
747
778
  return "string";
748
779
  }
749
780
  }
750
- case 25:
781
+ case 26:
751
782
  return "string";
752
783
  case 4:
753
784
  return this$.fields[0].Name;
@@ -769,7 +800,7 @@ export function GlueType__get_Name(this$) {
769
800
  return this$.fields[0].Name;
770
801
  case 14:
771
802
  return concat("ResizeArray<", GlueType__get_Name(this$.fields[0]), ">");
772
- case 29: {
803
+ case 30: {
773
804
  const info_11 = this$.fields[0];
774
805
  if (info_11.tag === 14) {
775
806
  return concat("ReadonlyArray<", GlueType__get_Name(info_11.fields[0]), ">");
@@ -783,22 +814,23 @@ export function GlueType__get_Name(this$) {
783
814
  case 7:
784
815
  return join(" | ", map(GlueType__get_Name, this$.fields[0].fields[0]));
785
816
  case 19:
786
- case 21:
817
+ case 22:
787
818
  case 20:
819
+ case 21:
788
820
  case 10:
789
821
  case 15:
790
822
  case 18:
791
- case 22:
823
+ case 23:
792
824
  case 0:
825
+ case 25:
826
+ case 29:
827
+ case 31:
828
+ case 33:
793
829
  case 24:
794
- case 28:
795
- case 30:
796
- case 32:
797
- case 23:
798
830
  return "obj";
799
- case 31:
831
+ case 32:
800
832
  return this$.fields[0].Name;
801
- case 26: {
833
+ case 27: {
802
834
  const utilityType = this$.fields[0];
803
835
  switch (utilityType.tag) {
804
836
  case 2:
@@ -809,7 +841,7 @@ export function GlueType__get_Name(this$) {
809
841
  return "obj";
810
842
  }
811
843
  }
812
- case 27:
844
+ case 28:
813
845
  return "obj";
814
846
  default:
815
847
  return this$.fields[0].Name;
@@ -842,19 +874,21 @@ export function GlueType__get_TypeParameters(this$) {
842
874
  return collect(GlueType__get_TypeParameters, this$.fields[0]);
843
875
  case 19:
844
876
  return GlueType__get_TypeParameters(this$.fields[0].Type);
845
- case 22:
877
+ case 23:
846
878
  return GlueType__get_TypeParameters(this$.fields[0]);
847
- case 27:
879
+ case 28:
848
880
  return singleton(this$.fields[0].TypeParameter);
849
- case 29:
881
+ case 30:
850
882
  return GlueType__get_TypeParameters(this$.fields[0]);
851
883
  case 20:
852
884
  return collect(GlueMember__get_TypeParameters, this$.fields[0]);
853
- case 26:
885
+ case 21:
886
+ return collect(GlueType__get_TypeParameters, this$.fields[0]);
887
+ case 27:
854
888
  return GlueUtilityType__get_TypeParameters(this$.fields[0]);
855
- case 23:
856
889
  case 24:
857
890
  case 25:
891
+ case 26:
858
892
  case 0:
859
893
  case 3:
860
894
  case 4:
@@ -862,11 +896,11 @@ export function GlueType__get_TypeParameters(this$) {
862
896
  case 10:
863
897
  case 11:
864
898
  case 16:
865
- case 21:
866
- case 30:
899
+ case 22:
867
900
  case 31:
868
901
  case 32:
869
- case 28:
902
+ case 33:
903
+ case 29:
870
904
  return empty();
871
905
  default:
872
906
  return this$.fields[0].TypeParameters;
@@ -892,12 +926,12 @@ export function GlueSubstitution_mentionedTypeParameters(glueType_mut) {
892
926
  glueType_2 = glueType.fields[0];
893
927
  break;
894
928
  }
895
- case 29: {
929
+ case 30: {
896
930
  matchResult = 2;
897
931
  glueType_2 = glueType.fields[0];
898
932
  break;
899
933
  }
900
- case 22: {
934
+ case 23: {
901
935
  matchResult = 2;
902
936
  glueType_2 = glueType.fields[0];
903
937
  break;
@@ -983,10 +1017,10 @@ export function GlueSubstitution_substitute(substitutions, glueType) {
983
1017
  return new GlueType(/* Union */ 7, [new GlueTypeUnion(map(substitute, glueType.fields[0].fields[0]))]);
984
1018
  case 14:
985
1019
  return new GlueType(/* Array */ 14, [substitute(glueType.fields[0])]);
986
- case 29:
987
- return new GlueType(/* ReadOnly */ 29, [substitute(glueType.fields[0])]);
988
- case 22:
989
- return new GlueType(/* OptionalType */ 22, [substitute(glueType.fields[0])]);
1020
+ case 30:
1021
+ return new GlueType(/* ReadOnly */ 30, [substitute(glueType.fields[0])]);
1022
+ case 23:
1023
+ return new GlueType(/* OptionalType */ 23, [substitute(glueType.fields[0])]);
990
1024
  case 18:
991
1025
  return new GlueType(/* TupleType */ 18, [map(substitute, glueType.fields[0])]);
992
1026
  case 19: {
@@ -1008,9 +1042,9 @@ export function GlueSubstitution_substitute(substitutions, glueType) {
1008
1042
  GetHashCode: (x) => (stringHash(x) | 0),
1009
1043
  }), functionType.OwnTypeParameterNames, Parameters))]);
1010
1044
  }
1011
- case 32: {
1045
+ case 33: {
1012
1046
  const conditionalType = glueType.fields[0];
1013
- return new GlueType(/* ConditionalType */ 32, [new GlueConditionalType(substitute(conditionalType.CheckType), substitute(conditionalType.ExtendsType), substitute(conditionalType.TrueType), substitute(conditionalType.FalseType))]);
1047
+ return new GlueType(/* ConditionalType */ 33, [new GlueConditionalType(substitute(conditionalType.CheckType), substitute(conditionalType.ExtendsType), substitute(conditionalType.TrueType), substitute(conditionalType.FalseType), conditionalType.Inferred)]);
1014
1048
  }
1015
1049
  case 9:
1016
1050
  return new GlueType(/* KeyOf */ 9, [substitute(glueType.fields[0])]);
@@ -1021,7 +1055,11 @@ export function GlueSubstitution_substitute(substitutions, glueType) {
1021
1055
  case 20:
1022
1056
  return new GlueType(/* IntersectionType */ 20, [map((glueMember) => GlueSubstitution_substituteMember(substitutions, glueMember), glueType.fields[0])]);
1023
1057
  case 21:
1024
- return new GlueType(/* TypeLiteral */ 21, [new GlueTypeLiteral(map((glueMember_1) => GlueSubstitution_substituteMember(substitutions, glueMember_1), glueType.fields[0].Members))]);
1058
+ return new GlueType(/* IntersectionOfReferences */ 21, [map(substitute, glueType.fields[0]), glueType.fields[1]]);
1059
+ case 22: {
1060
+ const typeLiteral = glueType.fields[0];
1061
+ return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(map((glueMember_1) => GlueSubstitution_substituteMember(substitutions, glueMember_1), typeLiteral.Members), typeLiteral.Id)]);
1062
+ }
1025
1063
  default:
1026
1064
  return glueType;
1027
1065
  }
@@ -1041,7 +1079,7 @@ export function GlueSubstitution_substituteMember(substitutions, glueMember) {
1041
1079
  }
1042
1080
  case 6: {
1043
1081
  const info_2 = glueMember.fields[0];
1044
- return new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature(info_2.Name, info_2.Documentation, info_2.TypeParameters, parameters(info_2.Parameters), substitute(info_2.Type))]);
1082
+ return new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature(info_2.Name, info_2.Documentation, info_2.TypeParameters, parameters(info_2.Parameters), substitute(info_2.Type), info_2.IsOptional)]);
1045
1083
  }
1046
1084
  case 2: {
1047
1085
  const info_3 = glueMember.fields[0];
@@ -1070,3 +1108,13 @@ export function GlueSubstitution_substituteMember(substitutions, glueMember) {
1070
1108
  }
1071
1109
  }
1072
1110
 
1111
+ /**
1112
+ * The type arguments of a reference by the name of the type parameters they stand for
1113
+ */
1114
+ export function GlueSubstitution_ofTypeArguments(typeParameters, typeArguments) {
1115
+ const substitutions = ofList(mapIndexed((index, typeParameter) => [typeParameter.Name, defaultArg(orElse(tryItem(index, typeArguments), typeParameter.Default), new GlueType(/* Primitive */ 3, [GluePrimitive.Any]))], typeParameters), {
1116
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
1117
+ });
1118
+ return map_1((_arg, argument_1) => GlueSubstitution_substitute(substitutions, argument_1), substitutions);
1119
+ }
1120
+