@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,91 +1,118 @@
1
1
 
2
+ import { withInProgress, removeParenthesizedType } from "./Utils.js";
2
3
  import { GlueTypeUnion, GlueType, GluePrimitive } from "../GlueAST.js";
3
4
  import { ofArray } from "../../fable_modules/fable-library-js.5.17.2/List.js";
4
- import { structuralHash, equals, Exception } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
5
- import { Report_readerError_Z19516DCE } from "./Report.js";
6
5
  import { defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
7
6
  import { tryFind } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
8
7
  import { contains, item as item_2 } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
8
+ import { Exception, structuralHash, equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
9
+ import { Report_readerError_Z19516DCE } from "./Report.js";
9
10
  import { readTypeQueryNode } from "./TypeQueryNode.js";
10
11
  import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
11
12
  import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
12
13
 
13
- function removeParenthesizedType(node_mut) {
14
- removeParenthesizedType:
15
- while (true) {
16
- const node = node_mut;
17
- if (node.kind === 196) {
18
- node_mut = node.type;
19
- continue removeParenthesizedType;
20
- }
21
- else {
22
- return node;
23
- }
24
- break;
25
- }
26
- }
27
-
28
- const declarationsInProgress = [];
29
-
30
14
  export function readTypeOperatorNode(reader, node) {
31
15
  let declarations;
32
16
  const matchValue = node.operator;
33
17
  switch (matchValue) {
34
18
  case 143: {
35
19
  const operandNode = removeParenthesizedType(node.type);
20
+ const arrayKeys = new GlueType(/* Union */ 7, [new GlueTypeUnion(ofArray([new GlueType(/* Primitive */ 3, [GluePrimitive.String$]), new GlueType(/* Primitive */ 3, [GluePrimitive.Number$])]))]);
36
21
  const matchValue_1 = operandNode.kind;
22
+ let matchResult;
37
23
  switch (matchValue_1) {
38
- case 133:
39
- return new GlueType(/* Union */ 7, [new GlueTypeUnion(ofArray([new GlueType(/* Primitive */ 3, [GluePrimitive.String$]), new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]), new GlueType(/* Primitive */ 3, [GluePrimitive.Symbol$])]))]);
40
- case 183: {
24
+ case 133: {
25
+ matchResult = 3;
26
+ break;
27
+ }
28
+ case 184: {
29
+ matchResult = 0;
30
+ break;
31
+ }
32
+ case 187: {
33
+ matchResult = 1;
34
+ break;
35
+ }
36
+ case 189: {
37
+ matchResult = 4;
38
+ break;
39
+ }
40
+ case 194:
41
+ case 200: {
42
+ matchResult = 2;
43
+ break;
44
+ }
45
+ case 199: {
46
+ if (operandNode.type.kind === 189) {
47
+ matchResult = 5;
48
+ }
49
+ else {
50
+ matchResult = 6;
51
+ }
52
+ break;
53
+ }
54
+ default:
55
+ matchResult = 6;
56
+ }
57
+ switch (matchResult) {
58
+ case 0: {
41
59
  const typeReferenceNode = operandNode;
42
60
  const symbolOpt = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(typeReferenceNode.typeName);
43
61
  if (symbolOpt != null) {
44
62
  const symbol = symbolOpt;
45
63
  const matchValue_2 = symbol.declarations;
46
- if (matchValue_2 == null) {
47
- throw new Exception(Report_readerError_Z19516DCE("type operator (keyof)", "Missing declarations", node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 65));
48
- }
49
- else if ((declarations = matchValue_2, declarations.length > 0)) {
50
- const declarations_1 = matchValue_2;
51
- const declaration_1 = defaultArg(tryFind((declaration) => (declaration.kind === 263), declarations_1), item_2(0, declarations_1));
52
- if (declaration_1.kind === 168) {
53
- return new GlueType(/* KeyOf */ 9, [new GlueType(/* TypeParameter */ 16, [symbol.name])]);
54
- }
55
- else if (contains(declaration_1, declarationsInProgress, {
56
- Equals: equals,
57
- GetHashCode: (x) => (structuralHash(x) | 0),
58
- })) {
59
- return new GlueType(/* KeyOf */ 9, [GlueType.Discard]);
64
+ let matchResult_1, declarations_1;
65
+ if (matchValue_2 != null) {
66
+ if ((declarations = matchValue_2, declarations.length > 0)) {
67
+ matchResult_1 = 0;
68
+ declarations_1 = matchValue_2;
60
69
  }
61
70
  else {
62
- void (declarationsInProgress.push(declaration_1));
63
- try {
64
- return new GlueType(/* KeyOf */ 9, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1)]);
65
- }
66
- finally {
67
- declarationsInProgress.splice(declarationsInProgress.length - 1, 1);
68
- }
71
+ matchResult_1 = 1;
69
72
  }
70
73
  }
71
74
  else {
72
- throw new Exception(Report_readerError_Z19516DCE("type operator (keyof)", "Missing declarations", node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 61));
75
+ matchResult_1 = 1;
76
+ }
77
+ switch (matchResult_1) {
78
+ case 0: {
79
+ const declaration_1 = defaultArg(tryFind((declaration) => (declaration.kind === 264), declarations_1), item_2(0, declarations_1));
80
+ if (declaration_1.kind === 169) {
81
+ return new GlueType(/* KeyOf */ 9, [new GlueType(/* TypeParameter */ 16, [symbol.name])]);
82
+ }
83
+ else if (contains(declaration_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().KeyOfDeclarations, {
84
+ Equals: equals,
85
+ GetHashCode: (x) => (structuralHash(x) | 0),
86
+ })) {
87
+ return new GlueType(/* KeyOf */ 9, [GlueType.Discard]);
88
+ }
89
+ else {
90
+ return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().KeyOfDeclarations, declaration_1, () => (new GlueType(/* KeyOf */ 9, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1)])));
91
+ }
92
+ }
93
+ default:
94
+ throw new Exception(Report_readerError_Z19516DCE("type operator (keyof)", "Missing declarations", node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 61));
73
95
  }
74
96
  }
75
97
  else if (node.pos < 0) {
76
98
  return new GlueType(/* KeyOf */ 9, [GlueType.Discard]);
77
99
  }
78
100
  else {
79
- throw new Exception(Report_readerError_Z19516DCE("type operator (keyof)", "Missing symbol", node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 35));
101
+ throw new Exception(Report_readerError_Z19516DCE("type operator (keyof)", "Missing symbol", node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 37));
80
102
  }
81
103
  }
82
- case 186:
104
+ case 1:
83
105
  return new GlueType(/* KeyOf */ 9, [readTypeQueryNode(reader, operandNode)]);
84
- case 193:
85
- case 199:
106
+ case 2:
86
107
  return new GlueType(/* KeyOf */ 9, [GlueType.Discard]);
108
+ case 3:
109
+ return new GlueType(/* Union */ 7, [new GlueTypeUnion(ofArray([new GlueType(/* Primitive */ 3, [GluePrimitive.String$]), new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]), new GlueType(/* Primitive */ 3, [GluePrimitive.Symbol$])]))]);
110
+ case 4:
111
+ return arrayKeys;
112
+ case 5:
113
+ return arrayKeys;
87
114
  default: {
88
- const item = Report_readerError_Z19516DCE("type operator (keyof)", concat("Was expecting a type reference or a type query instead got a Node of type ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(operandNode.kind)), node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 88);
115
+ const item = Report_readerError_Z19516DCE("type operator (keyof)", concat("Was expecting a type reference or a type query instead got a Node of type ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(operandNode.kind)), node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 91);
89
116
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
90
117
  void (objectArg.push(item));
91
118
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -93,11 +120,11 @@ export function readTypeOperatorNode(reader, node) {
93
120
  }
94
121
  }
95
122
  case 148:
96
- return new GlueType(/* ReadOnly */ 29, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](node.type)]);
123
+ return new GlueType(/* ReadOnly */ 30, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](node.type)]);
97
124
  case 158:
98
125
  return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](node.type);
99
126
  default: {
100
- const item_1 = Report_readerError_Z19516DCE("type operator", concat("Unsupported operator ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(node.operator)), node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 102);
127
+ const item_1 = Report_readerError_Z19516DCE("type operator", concat("Unsupported operator ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(node.operator)), node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 105);
101
128
  const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
102
129
  void (objectArg_1.push(item_1));
103
130
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -1,10 +1,13 @@
1
1
 
2
- import { isFromEsLib, isFromEs5Lib, identifierText, modulePathForSymbol, declaredName, resolveAlias, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
2
+ import { primitiveOfFlags, isFromEsLib, isFromEs5Lib, withInProgress, identifierText, isTopLevelModuleDeclaration, modulePathForSymbol, declaredName, $007CHasSymbolFlags$007C_$007C, resolveAlias, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
3
3
  import { defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
4
4
  import { contains, item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
5
- import { filter, append, isEmpty, map, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
5
+ import { collect as collect_1, append as append_1, delay, toList, exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
6
+ import { filter, isEmpty, singleton, append, map, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
6
7
  import { GlueFunctionDeclaration, GlueSubstitution_substituteParameter, GlueSubstitution_substitute, GlueSubstitution_mentionedTypeParameters, GlueFunctionType, GlueTypeReference, GlueType, GluePrimitive } from "../GlueAST.js";
7
- import { collect as collect_1, append as append_1, delay, toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
8
+ import { sanitizeTypeName, removeSurroundingQuotes } from "../Utils/Naming.js";
9
+ import { PackageContext__ModulePath_Z721C83C5 } from "./Types.js";
10
+ import { normalizePath } from "../Utils/String.js";
8
11
  import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
9
12
  import { FSharpSet__Contains, ofSeq } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
10
13
  import { structuralHash, equals, comparePrimitives } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
@@ -14,14 +17,12 @@ import { FSharpResult$2 } from "../../fable_modules/fable-library-js.5.17.2/Resu
14
17
  import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
15
18
  import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
16
19
 
17
- const declarationsInProgress = [];
18
-
19
20
  export function readTypeQueryNode(reader, typeQueryNode) {
20
21
  let declarations_1;
21
22
  const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
22
23
  const typ = checker.getTypeAtLocation(typeQueryNode.exprName);
23
24
  const matchValue = typ.flags;
24
- if ($007CHasTypeFlags$007C_$007C(524288, matchValue) != null) {
25
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
25
26
  const exprNameKind = typeQueryNode.exprName.kind;
26
27
  const matchValue_1 = typ.getSymbol();
27
28
  if (matchValue_1 != null) {
@@ -44,71 +45,136 @@ export function readTypeQueryNode(reader, typeQueryNode) {
44
45
  switch (matchResult) {
45
46
  case 0: {
46
47
  const declaration_1 = item(0, declarations_2);
47
- const matchValue_6 = declaration_1.kind;
48
- let matchResult_1;
49
- switch (matchValue_6) {
50
- case 173:
51
- case 174: {
52
- matchResult_1 = 3;
53
- break;
48
+ const hasValueExport = (isOwnDeclaration) => exists((export$) => {
49
+ let declarations_3;
50
+ const export$_1 = defaultArg(resolveAlias(checker, export$), export$);
51
+ const matchValue_6 = export$_1.flags;
52
+ if ($007CHasSymbolFlags$007C_$007C(111551, matchValue_6) != null) {
53
+ const matchValue_7 = export$_1.declarations;
54
+ let matchResult_1, declarations_4;
55
+ if (matchValue_7 != null) {
56
+ if ((declarations_3 = matchValue_7, declarations_3.length > 0)) {
57
+ matchResult_1 = 0;
58
+ declarations_4 = matchValue_7;
59
+ }
60
+ else {
61
+ matchResult_1 = 1;
62
+ }
63
+ }
64
+ else {
65
+ matchResult_1 = 1;
66
+ }
67
+ switch (matchResult_1) {
68
+ case 0:
69
+ return isOwnDeclaration(item(0, declarations_4));
70
+ default:
71
+ return false;
72
+ }
54
73
  }
55
- case 262: {
56
- matchResult_1 = 2;
74
+ else {
75
+ return false;
76
+ }
77
+ }, checker.getExportsOfModule(symbol_1));
78
+ const matchValue_8 = declaration_1.kind;
79
+ let matchResult_2;
80
+ switch (matchValue_8) {
81
+ case 174:
82
+ case 175: {
83
+ matchResult_2 = 4;
57
84
  break;
58
85
  }
59
86
  case 263: {
60
- matchResult_1 = 0;
87
+ matchResult_2 = 3;
88
+ break;
89
+ }
90
+ case 264: {
91
+ matchResult_2 = 0;
92
+ break;
93
+ }
94
+ case 268: {
95
+ matchResult_2 = 1;
61
96
  break;
62
97
  }
63
- case 267: {
64
- matchResult_1 = 1;
98
+ case 308: {
99
+ matchResult_2 = 2;
65
100
  break;
66
101
  }
67
102
  default:
68
103
  if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
69
- matchResult_1 = 4;
104
+ matchResult_2 = 5;
70
105
  }
71
106
  else {
72
- matchResult_1 = 5;
107
+ matchResult_2 = 6;
73
108
  }
74
109
  }
75
- switch (matchResult_1) {
110
+ switch (matchResult_2) {
76
111
  case 0: {
77
112
  let typeArguments;
78
- const matchValue_7 = declaration_1.typeParameters;
79
- typeArguments = ((matchValue_7 == null) ? empty() : map((_arg_6) => (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])), toList(matchValue_7)));
113
+ const matchValue_9 = declaration_1.typeParameters;
114
+ typeArguments = ((matchValue_9 == null) ? empty() : map((_arg_6) => (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])), toList(matchValue_9)));
80
115
  return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(defaultArg(declaredName(symbol_1), symbol_1.name), checker.getFullyQualifiedName(symbol_1), modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), false, symbol_1), typeArguments, false)]);
81
116
  }
82
117
  case 1:
83
- return GlueType.Discard;
118
+ if (!hasValueExport((_arg_7) => true)) {
119
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
120
+ }
121
+ else {
122
+ const moduleDeclaration = declaration_1;
123
+ const rawName = removeSurroundingQuotes(moduleDeclaration.name.getText());
124
+ const moduleName = isTopLevelModuleDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), declaration_1) ? sanitizeTypeName(rawName + "_") : sanitizeTypeName(rawName);
125
+ return new GlueType(/* TypeReference */ 13, [new GlueTypeReference("Exports", checker.getFullyQualifiedName(symbol_1), append(modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), false, symbol_1), singleton(moduleName)), empty(), false)]);
126
+ }
84
127
  case 2: {
85
- const matchValue_8 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1);
86
- if (matchValue_8.tag === 6) {
87
- if (!isEmpty(matchValue_8.fields[0].TypeParameters)) {
88
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
128
+ const sourceFile = declaration_1;
129
+ const matchValue_10 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
130
+ let matchResult_3, packageContext_1;
131
+ if (matchValue_10 != null) {
132
+ if (hasValueExport((declaration_2) => (normalizePath(declaration_2.getSourceFile().fileName) === normalizePath(sourceFile.fileName)))) {
133
+ matchResult_3 = 0;
134
+ packageContext_1 = matchValue_10;
89
135
  }
90
136
  else {
91
- return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(matchValue_8.fields[0].Documentation, matchValue_8.fields[0].Type, matchValue_8.fields[0].TypeParameters, empty(), matchValue_8.fields[0].Parameters)]);
137
+ matchResult_3 = 1;
92
138
  }
93
139
  }
94
140
  else {
95
- return matchValue_8;
141
+ matchResult_3 = 1;
142
+ }
143
+ switch (matchResult_3) {
144
+ case 0:
145
+ return new GlueType(/* TypeReference */ 13, [new GlueTypeReference("Exports", checker.getFullyQualifiedName(symbol_1), PackageContext__ModulePath_Z721C83C5(packageContext_1, sourceFile.fileName), empty(), false)]);
146
+ default:
147
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
96
148
  }
97
149
  }
98
150
  case 3: {
151
+ const matchValue_11 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1);
152
+ if (matchValue_11.tag === 6) {
153
+ if (!isEmpty(matchValue_11.fields[0].TypeParameters)) {
154
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
155
+ }
156
+ else {
157
+ return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(matchValue_11.fields[0].Documentation, matchValue_11.fields[0].Type, matchValue_11.fields[0].TypeParameters, empty(), matchValue_11.fields[0].Parameters)]);
158
+ }
159
+ }
160
+ else {
161
+ return matchValue_11;
162
+ }
163
+ }
164
+ case 4: {
99
165
  let inScope;
100
166
  const collect = (node_mut, acc_mut) => {
101
167
  collect:
102
168
  while (true) {
103
169
  const node = node_mut, acc = acc_mut;
170
+ let input_11;
104
171
  if (Operators_IsNull(node)) {
105
172
  return acc;
106
173
  }
107
174
  else {
108
- const typeParameters_1 = node.typeParameters;
109
- const acc_1 = (typeParameters_1 == null) ? acc : append(acc, map((typeParameter) => identifierText(typeParameter.name), toList(typeParameters_1)));
175
+ const names = defaultArg((input_11 = node.typeParameters, (input_11 == null) ? undefined : map((typeParameter) => identifierText(typeParameter.name), toList(input_11))), empty());
110
176
  node_mut = node.parent;
111
- acc_mut = acc_1;
177
+ acc_mut = append(acc, names);
112
178
  continue collect;
113
179
  }
114
180
  break;
@@ -123,37 +189,31 @@ export function readTypeQueryNode(reader, typeQueryNode) {
123
189
  });
124
190
  return new GlueType(/* FunctionDeclaration */ 6, [new GlueFunctionDeclaration(documentation, true, name, GlueSubstitution_substitute(free, returnType), map((parameter_1) => GlueSubstitution_substituteParameter(free, parameter_1), parameters), empty())]);
125
191
  };
126
- const matchValue_9 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_1);
127
- switch (matchValue_9.tag) {
192
+ const matchValue_12 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_1);
193
+ switch (matchValue_12.tag) {
128
194
  case 0: {
129
- const info_3 = matchValue_9.fields[0];
195
+ const info_3 = matchValue_12.fields[0];
130
196
  return toFunctionDeclaration(info_3.Name, info_3.Documentation, info_3.Parameters, info_3.Type);
131
197
  }
132
198
  case 6: {
133
- const info_4 = matchValue_9.fields[0];
199
+ const info_4 = matchValue_12.fields[0];
134
200
  return toFunctionDeclaration(info_4.Name, info_4.Documentation, info_4.Parameters, info_4.Type);
135
201
  }
136
202
  default:
137
203
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
138
204
  }
139
205
  }
140
- case 4:
206
+ case 5:
141
207
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
142
208
  default:
143
- if (contains(declaration_1, declarationsInProgress, {
209
+ if (contains(declaration_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, {
144
210
  Equals: equals,
145
211
  GetHashCode: (x_10) => (structuralHash(x_10) | 0),
146
212
  })) {
147
213
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
148
214
  }
149
215
  else {
150
- void (declarationsInProgress.push(declaration_1));
151
- try {
152
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1);
153
- }
154
- finally {
155
- declarationsInProgress.splice(declarationsInProgress.length - 1, 1);
156
- }
216
+ return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, declaration_1, () => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1));
157
217
  }
158
218
  }
159
219
  }
@@ -166,7 +226,7 @@ export function readTypeQueryNode(reader, typeQueryNode) {
166
226
  let _arg_5;
167
227
  let input_9;
168
228
  const option = checker.getSymbolAtLocation(exprName);
169
- const error = Report_readerError_Z19516DCE("type node (TypeQuery)", "Missing symbol", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 31);
229
+ const error = Report_readerError_Z19516DCE("type node (TypeQuery)", "Missing symbol", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 29);
170
230
  const option_1 = option;
171
231
  input_9 = ((option_1 == null) ? (new FSharpResult$2(/* Error */ 1, [error])) : (new FSharpResult$2(/* Ok */ 0, [option_1])));
172
232
  if (input_9.tag === 1) {
@@ -175,7 +235,7 @@ export function readTypeQueryNode(reader, typeQueryNode) {
175
235
  else {
176
236
  let input_7;
177
237
  const option_2 = input_9.fields[0].declarations;
178
- const error_2 = Report_readerError_Z19516DCE("type node (TypeQuery)", "Missing declarations", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 41);
238
+ const error_2 = Report_readerError_Z19516DCE("type node (TypeQuery)", "Missing declarations", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 39);
179
239
  const option_3 = option_2;
180
240
  input_7 = ((option_3 == null) ? (new FSharpResult$2(/* Error */ 1, [error_2])) : (new FSharpResult$2(/* Ok */ 0, [option_3])));
181
241
  if (input_7.tag === 1) {
@@ -183,7 +243,7 @@ export function readTypeQueryNode(reader, typeQueryNode) {
183
243
  }
184
244
  else {
185
245
  const declarations = input_7.fields[0];
186
- const input_5 = (declarations.length !== 1) ? (new FSharpResult$2(/* Error */ 1, [Report_readerError_Z19516DCE("type node (TypeQuery)", "Expected exactly one declaration", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 50)])) : (new FSharpResult$2(/* Ok */ 0, [item(0, declarations)]));
246
+ const input_5 = (declarations.length !== 1) ? (new FSharpResult$2(/* Error */ 1, [Report_readerError_Z19516DCE("type node (TypeQuery)", "Expected exactly one declaration", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 48)])) : (new FSharpResult$2(/* Ok */ 0, [item(0, declarations)]));
187
247
  if (input_5.tag === 1) {
188
248
  _arg_5 = (new FSharpResult$2(/* Error */ 1, [input_5.fields[0]]));
189
249
  }
@@ -191,14 +251,14 @@ export function readTypeQueryNode(reader, typeQueryNode) {
191
251
  const declaration = input_5.fields[0];
192
252
  let input_3;
193
253
  const matchValue_3 = declaration.kind;
194
- input_3 = ((matchValue_3 === 260) ? (new FSharpResult$2(/* Ok */ 0, [declaration])) : (new FSharpResult$2(/* Error */ 1, [Report_readerError_Z19516DCE("type node (TypeQuery)", concat("Unsupported declaration kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue_3)), typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 66)])));
254
+ input_3 = ((matchValue_3 === 261) ? (new FSharpResult$2(/* Ok */ 0, [declaration])) : (new FSharpResult$2(/* Error */ 1, [Report_readerError_Z19516DCE("type node (TypeQuery)", concat("Unsupported declaration kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue_3)), typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 64)])));
195
255
  if (input_3.tag === 1) {
196
256
  _arg_5 = (new FSharpResult$2(/* Error */ 1, [input_3.fields[0]]));
197
257
  }
198
258
  else {
199
259
  let input_1;
200
260
  const option_4 = input_3.fields[0].type;
201
- const error_4 = Report_readerError_Z19516DCE("type node (TypeQuery)", "Missing type", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 76);
261
+ const error_4 = Report_readerError_Z19516DCE("type node (TypeQuery)", "Missing type", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 74);
202
262
  const option_5 = option_4;
203
263
  input_1 = ((option_5 == null) ? (new FSharpResult$2(/* Error */ 1, [error_4])) : (new FSharpResult$2(/* Ok */ 0, [option_5])));
204
264
  if (input_1.tag === 1) {
@@ -208,17 +268,17 @@ export function readTypeQueryNode(reader, typeQueryNode) {
208
268
  const typeNode = input_1.fields[0];
209
269
  const matchValue_4 = typeNode.kind;
210
270
  switch (matchValue_4) {
211
- case 189: {
271
+ case 190: {
212
272
  _arg_5 = (new FSharpResult$2(/* Ok */ 0, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode)]));
213
273
  break;
214
274
  }
215
- case 198: {
275
+ case 199: {
216
276
  const typeOperatorNode = typeNode;
217
277
  _arg_5 = (new FSharpResult$2(/* Ok */ 0, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeOperatorNodeZ6830FC33"](typeOperatorNode)]));
218
278
  break;
219
279
  }
220
280
  default:
221
- _arg_5 = (new FSharpResult$2(/* Error */ 1, [Report_readerError_Z19516DCE("type node (TypeQuery)", concat("Unsupported declaration kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue_4)), typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 88)]));
281
+ _arg_5 = (new FSharpResult$2(/* Error */ 1, [Report_readerError_Z19516DCE("type node (TypeQuery)", concat("Unsupported declaration kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue_4)), typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 86)]));
222
282
  }
223
283
  }
224
284
  }
@@ -234,28 +294,13 @@ export function readTypeQueryNode(reader, typeQueryNode) {
234
294
  }
235
295
  }
236
296
  else {
237
- const warning_1 = Report_readerError_Z19516DCE("type node (TypeQuery)", "Expected an Identifier", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 104);
297
+ const warning_1 = Report_readerError_Z19516DCE("type node (TypeQuery)", "Expected an Identifier", typeQueryNode, "/_//src/Glutinum.Converter/Reader/TypeQueryNode.fs", 102);
238
298
  void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning_1));
239
299
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
240
300
  }
241
301
  }
242
- else if ($007CHasTypeFlags$007C_$007C(4, matchValue) != null) {
243
- return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
244
- }
245
- else if ($007CHasTypeFlags$007C_$007C(8, matchValue) != null) {
246
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]);
247
- }
248
- else if ($007CHasTypeFlags$007C_$007C(16, matchValue) != null) {
249
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Bool]);
250
- }
251
- else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
252
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
253
- }
254
- else if ($007CHasTypeFlags$007C_$007C(16384, matchValue) != null) {
255
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Unit]);
256
- }
257
302
  else {
258
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
303
+ return primitiveOfFlags(typ);
259
304
  }
260
305
  }
261
306
 
@@ -4,9 +4,10 @@ import { readClassDeclaration } from "./ClassDeclaration.js";
4
4
  import { readEnumDeclaration } from "./EnumDeclaration.js";
5
5
  import { GluePrimitive, GlueType } from "../GlueAST.js";
6
6
  import { readFunctionDeclaration } from "./FunctionDeclaration.js";
7
- import { readInterfaceDeclaration } from "./InterfaceDeclaration.js";
7
+ import { tryReadExternalRedeclaration, readInterfaceDeclaration } from "./InterfaceDeclaration.js";
8
8
  import { readModuleDeclaration } from "./ModuleDeclaration.js";
9
9
  import { readNode } from "./Node.js";
10
+ import { addToSet } from "../../fable_modules/fable-library-js.5.17.2/MapUtil.js";
10
11
  import { readTypeAliasDeclaration } from "./TypeAliasDeclaration.js";
11
12
  import { readTypeNode } from "./TypeNode.js";
12
13
  import { readVariableStatement } from "./VariableStatement.js";
@@ -20,19 +21,28 @@ import { readExportAssignment } from "./ExportAssignment.js";
20
21
  import { readDocumentationForNode, readDocumentationForSignature } from "./Documentation.js";
21
22
  import { readNamedTupleMember } from "./NamedTupleMember.js";
22
23
  import { readMappedTypeNode } from "./MappedTypeNode.js";
24
+ import { HashSet } from "../../fable_modules/fable-library-js.5.17.2/MutableSet.js";
25
+ import { HashIdentity_Reference } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Collections.js";
26
+ import { ReadInProgress_Create } from "./Types.js";
23
27
  import { class_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
24
28
 
25
29
  export class TypeScriptReader {
26
30
  constructor(checker, packageContext) {
27
- this["checker@27"] = checker;
31
+ this["checker@28"] = checker;
28
32
  this.packageContext = packageContext;
29
33
  this.warnings = [];
30
34
  this.typeMemory = [];
35
+ this.readNodes = (new HashSet([], HashIdentity_Reference()));
36
+ this.inProgress = ReadInProgress_Create();
31
37
  this["SyntheticContext@"] = undefined;
32
38
  }
33
39
  "Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"() {
34
40
  const _ = this;
35
- return _["checker@27"];
41
+ return _["checker@28"];
42
+ }
43
+ "Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"() {
44
+ const _ = this;
45
+ return _.inProgress;
36
46
  }
37
47
  "Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"() {
38
48
  const _ = this;
@@ -72,16 +82,24 @@ export class TypeScriptReader {
72
82
  }
73
83
  "Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadInterfaceDeclaration1CB6FA10"(interfaceDeclaration) {
74
84
  const this$ = this;
75
- return new GlueType(/* Interface */ 1, [readInterfaceDeclaration(this$, interfaceDeclaration)]);
85
+ const glueInterface = readInterfaceDeclaration(this$, interfaceDeclaration);
86
+ const matchValue = tryReadExternalRedeclaration(this$, interfaceDeclaration, glueInterface);
87
+ return (matchValue == null) ? (new GlueType(/* Interface */ 1, [glueInterface])) : matchValue;
76
88
  }
77
89
  "Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadModuleDeclarationC29C54F"(moduleDeclaration) {
78
90
  const this$ = this;
79
91
  return new GlueType(/* ModuleDeclaration */ 11, [readModuleDeclaration(this$, moduleDeclaration)]);
80
92
  }
93
+ "Glutinum.Converter.Reader.Types.ITypeScriptReader.HasRead6C0FD055"(node) {
94
+ const _ = this;
95
+ return _.readNodes.has(node);
96
+ }
81
97
  "Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"(node) {
82
98
  const this$ = this;
83
99
  const typ = readNode(this$, node);
84
- void (this$.typeMemory.push(typ));
100
+ if (addToSet(node, this$.readNodes)) {
101
+ void (this$.typeMemory.push(typ));
102
+ }
85
103
  return typ;
86
104
  }
87
105
  "Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeAliasDeclarationZ7FA16745"(typeAliasDeclaration) {
@@ -104,7 +122,7 @@ export class TypeScriptReader {
104
122
  const this$ = this;
105
123
  return readDeclaration(this$, declaration);
106
124
  }
107
- "Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParametersZ17143B5B"(parameters) {
125
+ "Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"(parameters) {
108
126
  const this$ = this;
109
127
  return readParameters(this$, parameters);
110
128
  }
@@ -120,7 +138,7 @@ export class TypeScriptReader {
120
138
  const this$ = this;
121
139
  return readIndexedAccessType(this$, declaration);
122
140
  }
123
- "Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4088FB9E"(typeParametersOpt) {
141
+ "Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"(typeParametersOpt) {
124
142
  const this$ = this;
125
143
  return readTypeParameters(this$, typeParametersOpt);
126
144
  }