@glutinum/cli 1.0.0-beta.2 → 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 +34 -21
  7. package/dist/Glutinum.Converter/GlueAST.js +79 -41
  8. package/dist/Glutinum.Converter/Hosting.js +132 -157
  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 +396 -423
  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 +3568 -8456
  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 +18 -10
  47. package/package.json +1 -1
@@ -1,32 +1,16 @@
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 === 197) {
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;
@@ -43,40 +27,44 @@ export function readTypeOperatorNode(reader, node) {
43
27
  if (symbolOpt != null) {
44
28
  const symbol = symbolOpt;
45
29
  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 === 264), declarations_1), item_2(0, declarations_1));
52
- if (declaration_1.kind === 169) {
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]);
30
+ let matchResult, declarations_1;
31
+ if (matchValue_2 != null) {
32
+ if ((declarations = matchValue_2, declarations.length > 0)) {
33
+ matchResult = 0;
34
+ declarations_1 = matchValue_2;
60
35
  }
61
36
  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
- }
37
+ matchResult = 1;
69
38
  }
70
39
  }
71
40
  else {
72
- throw new Exception(Report_readerError_Z19516DCE("type operator (keyof)", "Missing declarations", node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 61));
41
+ matchResult = 1;
42
+ }
43
+ switch (matchResult) {
44
+ case 0: {
45
+ const declaration_1 = defaultArg(tryFind((declaration) => (declaration.kind === 264), declarations_1), item_2(0, declarations_1));
46
+ if (declaration_1.kind === 169) {
47
+ return new GlueType(/* KeyOf */ 9, [new GlueType(/* TypeParameter */ 16, [symbol.name])]);
48
+ }
49
+ else if (contains(declaration_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().KeyOfDeclarations, {
50
+ Equals: equals,
51
+ GetHashCode: (x) => (structuralHash(x) | 0),
52
+ })) {
53
+ return new GlueType(/* KeyOf */ 9, [GlueType.Discard]);
54
+ }
55
+ else {
56
+ 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)])));
57
+ }
58
+ }
59
+ default:
60
+ throw new Exception(Report_readerError_Z19516DCE("type operator (keyof)", "Missing declarations", node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 52));
73
61
  }
74
62
  }
75
63
  else if (node.pos < 0) {
76
64
  return new GlueType(/* KeyOf */ 9, [GlueType.Discard]);
77
65
  }
78
66
  else {
79
- throw new Exception(Report_readerError_Z19516DCE("type operator (keyof)", "Missing symbol", node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 35));
67
+ throw new Exception(Report_readerError_Z19516DCE("type operator (keyof)", "Missing symbol", node, "/_//src/Glutinum.Converter/Reader/TypeOperatorNode.fs", 28));
80
68
  }
81
69
  }
82
70
  case 187:
@@ -85,7 +73,7 @@ export function readTypeOperatorNode(reader, node) {
85
73
  case 200:
86
74
  return new GlueType(/* KeyOf */ 9, [GlueType.Discard]);
87
75
  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);
76
+ 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", 75);
89
77
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
90
78
  void (objectArg.push(item));
91
79
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -97,7 +85,7 @@ export function readTypeOperatorNode(reader, node) {
97
85
  case 158:
98
86
  return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](node.type);
99
87
  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);
88
+ 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", 89);
101
89
  const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
102
90
  void (objectArg_1.push(item_1));
103
91
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -1,5 +1,5 @@
1
1
 
2
- import { isFromEsLib, isFromEs5Lib, identifierText, isTopLevelModuleDeclaration, modulePathForSymbol, declaredName, $007CHasSymbolFlags$007C_$007C, 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
5
  import { collect as collect_1, append as append_1, delay, toList, exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
@@ -17,8 +17,6 @@ import { FSharpResult$2 } from "../../fable_modules/fable-library-js.5.17.2/Resu
17
17
  import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
18
18
  import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
19
19
 
20
- const declarationsInProgress = [];
21
-
22
20
  export function readTypeQueryNode(reader, typeQueryNode) {
23
21
  let declarations_1;
24
22
  const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
@@ -169,14 +167,14 @@ export function readTypeQueryNode(reader, typeQueryNode) {
169
167
  collect:
170
168
  while (true) {
171
169
  const node = node_mut, acc = acc_mut;
170
+ let input_11;
172
171
  if (Operators_IsNull(node)) {
173
172
  return acc;
174
173
  }
175
174
  else {
176
- const typeParameters_1 = node.typeParameters;
177
- 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());
178
176
  node_mut = node.parent;
179
- acc_mut = acc_1;
177
+ acc_mut = append(acc, names);
180
178
  continue collect;
181
179
  }
182
180
  break;
@@ -208,20 +206,14 @@ export function readTypeQueryNode(reader, typeQueryNode) {
208
206
  case 5:
209
207
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
210
208
  default:
211
- if (contains(declaration_1, declarationsInProgress, {
209
+ if (contains(declaration_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, {
212
210
  Equals: equals,
213
211
  GetHashCode: (x_10) => (structuralHash(x_10) | 0),
214
212
  })) {
215
213
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
216
214
  }
217
215
  else {
218
- void (declarationsInProgress.push(declaration_1));
219
- try {
220
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1);
221
- }
222
- finally {
223
- declarationsInProgress.splice(declarationsInProgress.length - 1, 1);
224
- }
216
+ return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, declaration_1, () => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1));
225
217
  }
226
218
  }
227
219
  }
@@ -234,7 +226,7 @@ export function readTypeQueryNode(reader, typeQueryNode) {
234
226
  let _arg_5;
235
227
  let input_9;
236
228
  const option = checker.getSymbolAtLocation(exprName);
237
- 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);
238
230
  const option_1 = option;
239
231
  input_9 = ((option_1 == null) ? (new FSharpResult$2(/* Error */ 1, [error])) : (new FSharpResult$2(/* Ok */ 0, [option_1])));
240
232
  if (input_9.tag === 1) {
@@ -243,7 +235,7 @@ export function readTypeQueryNode(reader, typeQueryNode) {
243
235
  else {
244
236
  let input_7;
245
237
  const option_2 = input_9.fields[0].declarations;
246
- 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);
247
239
  const option_3 = option_2;
248
240
  input_7 = ((option_3 == null) ? (new FSharpResult$2(/* Error */ 1, [error_2])) : (new FSharpResult$2(/* Ok */ 0, [option_3])));
249
241
  if (input_7.tag === 1) {
@@ -251,7 +243,7 @@ export function readTypeQueryNode(reader, typeQueryNode) {
251
243
  }
252
244
  else {
253
245
  const declarations = input_7.fields[0];
254
- 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)]));
255
247
  if (input_5.tag === 1) {
256
248
  _arg_5 = (new FSharpResult$2(/* Error */ 1, [input_5.fields[0]]));
257
249
  }
@@ -259,14 +251,14 @@ export function readTypeQueryNode(reader, typeQueryNode) {
259
251
  const declaration = input_5.fields[0];
260
252
  let input_3;
261
253
  const matchValue_3 = declaration.kind;
262
- 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", 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)])));
263
255
  if (input_3.tag === 1) {
264
256
  _arg_5 = (new FSharpResult$2(/* Error */ 1, [input_3.fields[0]]));
265
257
  }
266
258
  else {
267
259
  let input_1;
268
260
  const option_4 = input_3.fields[0].type;
269
- 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);
270
262
  const option_5 = option_4;
271
263
  input_1 = ((option_5 == null) ? (new FSharpResult$2(/* Error */ 1, [error_4])) : (new FSharpResult$2(/* Ok */ 0, [option_5])));
272
264
  if (input_1.tag === 1) {
@@ -286,7 +278,7 @@ export function readTypeQueryNode(reader, typeQueryNode) {
286
278
  break;
287
279
  }
288
280
  default:
289
- _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)]));
290
282
  }
291
283
  }
292
284
  }
@@ -302,28 +294,13 @@ export function readTypeQueryNode(reader, typeQueryNode) {
302
294
  }
303
295
  }
304
296
  else {
305
- 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);
306
298
  void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning_1));
307
299
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
308
300
  }
309
301
  }
310
- else if ($007CHasTypeFlags$007C_$007C(32, matchValue) != null) {
311
- return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
312
- }
313
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue) != null) {
314
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]);
315
- }
316
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue) != null) {
317
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Bool]);
318
- }
319
- else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
320
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
321
- }
322
- else if ($007CHasTypeFlags$007C_$007C(16, matchValue) != null) {
323
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Unit]);
324
- }
325
302
  else {
326
- return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
303
+ return primitiveOfFlags(typ);
327
304
  }
328
305
  }
329
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) {