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

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.
@@ -13,7 +13,7 @@ import { escape, create, isMatch, replace as replace_2 } from "../fable_modules/
13
13
  import { removeConsecutiveEmptyLines, trimEmptyLines } from "./Utils/List.js";
14
14
  import { FSharpInterface, FSharpAttribute } from "./FsharpAST.js";
15
15
  import { singleton as singleton_1, append as append_1, delay, toList } from "../fable_modules/fable-library-js.5.17.2/Seq.js";
16
- import { List_distinct } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
16
+ import { List_distinctBy } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
17
17
 
18
18
  export class Printer {
19
19
  constructor() {
@@ -957,7 +957,7 @@ function printUnion(printer, unionInfo) {
957
957
  }
958
958
  }, unionInfo.Attributes)) {
959
959
  const returnType = printTypeNameWithTypeParameters(unionInfo.Name, unionInfo.TypeParameters);
960
- iterate((caseType) => {
960
+ iterate((caseType_1) => {
961
961
  const enumerator = getEnumerator(["op_Implicit", "op_ErasedCast"]);
962
962
  try {
963
963
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
@@ -965,14 +965,21 @@ function printUnion(printer, unionInfo) {
965
965
  Printer__get_NewLine(printer);
966
966
  Printer__Write_Z721C83C5(printer, "[<Emit(\"$0\")>]");
967
967
  Printer__get_NewLine(printer);
968
- Printer__Write_Z721C83C5(printer, `static member ${name_2}(value: ${caseType}) : ${returnType} = nativeOnly`);
968
+ Printer__Write_Z721C83C5(printer, `static member ${name_2}(value: ${caseType_1}) : ${returnType} = nativeOnly`);
969
969
  Printer__get_NewLine(printer);
970
970
  }
971
971
  }
972
972
  finally {
973
973
  disposeSafe(enumerator);
974
974
  }
975
- }, List_distinct(choose((_arg_1) => {
975
+ }, List_distinctBy((caseType) => {
976
+ if (caseType === "JS.Uint8ClampedArray") {
977
+ return "JS.Uint8Array";
978
+ }
979
+ else {
980
+ return caseType;
981
+ }
982
+ }, choose((_arg_1) => {
976
983
  if (_arg_1.tag === 2) {
977
984
  return printType(_arg_1.fields[1]);
978
985
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { GluePrimitive, GlueType, GlueIndexedAccessType } from "../GlueAST.js";
3
- import { typeNodeBuilderFlags, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
3
+ import { typeNodeBuilderFlags, $007CHasTypeFlags$007C_$007C, enclosingDeclarationOf } from "./Utils.js";
4
4
  import { Report_readerError_Z19516DCE } from "./Report.js";
5
5
  import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
6
6
  import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
@@ -12,7 +12,7 @@ export function readIndexedAccessType(reader, declaration) {
12
12
  const node = declaration;
13
13
  const tryTypeToTypeNode = (typ, flags) => {
14
14
  try {
15
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, node, flags);
15
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, enclosingDeclarationOf(node), flags);
16
16
  }
17
17
  catch (matchValue) {
18
18
  return undefined;
@@ -2,7 +2,7 @@
2
2
  import { Union } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
3
3
  import { union_type, class_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
4
4
  import { contains as contains_2, item as item_4 } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
5
- import { tryReadLiteral, resolvedBaseTypeArguments, declaredName, isFromEsLib, isFromEs5Lib, crossesNamespace, modulePathForSymbol, knownExternalTypeNames, isExternalToPackages, importedName, typeLiteralId, readTypeArguments, getFullNameOrEmpty, defaultTypeArguments, isTupleType, withInProgress, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, primitiveOfFlags, entityNameText, mainDeclaration, resolveAlias, symbolAtLocation, identifierText, $007CHasTypeFlags$007C_$007C, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags } from "./Utils.js";
5
+ import { tryReadLiteral, resolvedBaseTypeArguments, declaredName, isFromEsLib, isFromEs5Lib, crossesNamespace, modulePathForSymbol, knownExternalTypeNames, isExternalToPackages, importedName, typeLiteralId, readTypeArguments, getFullNameOrEmpty, defaultTypeArguments, isTupleType, withInProgress, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, primitiveOfFlags, entityNameText, mainDeclaration, resolveAlias, symbolAtLocation, identifierText, $007CHasTypeFlags$007C_$007C, enclosingDeclarationOf, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags } from "./Utils.js";
6
6
  import { Report_readerError_Z19516DCE } from "./Report.js";
7
7
  import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
8
8
  import { forAll as forAll_1, concat as concat_1, head, tail, item as item_5, contains, filter as filter_1, map as map_1, ofArray, length, truncate, isEmpty, exists as exists_1, choose, cons, collect as collect_1, singleton, tryFind, fold, append, reverse, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
@@ -78,8 +78,7 @@ function readInstantiatedMember(reader, contextNode, property, declaration) {
78
78
  return declaredMember;
79
79
  }
80
80
  else {
81
- const enclosingDeclaration = (contextNode.pos < 0) ? undefined : contextNode;
82
- const matchValue = checker.typeToTypeNode(instantiatedType, enclosingDeclaration, typeNodeBuilderFlags);
81
+ const matchValue = checker.typeToTypeNode(instantiatedType, enclosingDeclarationOf(contextNode), typeNodeBuilderFlags);
83
82
  if (matchValue != null) {
84
83
  const typeNode = matchValue;
85
84
  const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
@@ -609,7 +608,7 @@ function tryResolveDeferred(reader, typeNode) {
609
608
  }), typ);
610
609
  if (option_1 != null) {
611
610
  const resolved = option_1;
612
- option_3 = checker.typeToTypeNode(resolved, typeNode, typeNodeBuilderFlags);
611
+ option_3 = checker.typeToTypeNode(resolved, enclosingDeclarationOf(typeNode), typeNodeBuilderFlags);
613
612
  }
614
613
  else {
615
614
  option_3 = undefined;
@@ -851,7 +850,7 @@ export function UtilityType_readExclude(reader, typeReferenceNode) {
851
850
  }
852
851
  switch (matchResult) {
853
852
  case 0:
854
- return new GlueType(/* Union */ 7, [new GlueTypeUnion((matchValue_1 = typ.flags, ($007CHasTypeFlags$007C_$007C(1024, matchValue_1) != null) ? ((activePatternResult_4 = Type_StringLiteral_$007CString$007COther$007C(typ), (activePatternResult_4.tag === 1) ? (((item = Report_readerError_Z19516DCE("Exclude", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 697), (objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg.push(item)))), empty())) : singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_4.fields[0]])])))) : (($007CHasTypeFlags$007C_$007C(2048, matchValue_1) != null) ? ((activePatternResult_6 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ), (activePatternResult_6.tag === 1) ? singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_6.fields[0]])])) : ((activePatternResult_6.tag === 2) ? (((item_1 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 712), (objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_1.push(item_1)))), empty())) : singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_6.fields[0]])]))))) : choose((typ_1) => {
853
+ return new GlueType(/* Union */ 7, [new GlueTypeUnion((matchValue_1 = typ.flags, ($007CHasTypeFlags$007C_$007C(1024, matchValue_1) != null) ? ((activePatternResult_4 = Type_StringLiteral_$007CString$007COther$007C(typ), (activePatternResult_4.tag === 1) ? (((item = Report_readerError_Z19516DCE("Exclude", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 696), (objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg.push(item)))), empty())) : singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_4.fields[0]])])))) : (($007CHasTypeFlags$007C_$007C(2048, matchValue_1) != null) ? ((activePatternResult_6 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ), (activePatternResult_6.tag === 1) ? singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_6.fields[0]])])) : ((activePatternResult_6.tag === 2) ? (((item_1 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 711), (objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_1.push(item_1)))), empty())) : singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_6.fields[0]])]))))) : choose((typ_1) => {
855
854
  const matchValue_2 = typ_1.flags;
856
855
  if ($007CHasTypeFlags$007C_$007C(1024, matchValue_2) != null) {
857
856
  const literalType = typ_1;
@@ -863,7 +862,7 @@ export function UtilityType_readExclude(reader, typeReferenceNode) {
863
862
  case 1:
864
863
  return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_9.fields[0]])]);
865
864
  case 2: {
866
- const item_2 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 739);
865
+ const item_2 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 738);
867
866
  const objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
868
867
  void (objectArg_2.push(item_2));
869
868
  return undefined;
@@ -958,7 +957,7 @@ export function UtilityType_readExclude(reader, typeReferenceNode) {
958
957
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
959
958
  }
960
959
  else {
961
- const item_3 = Report_readerError_Z19516DCE("Exclude", "Was expecting the resolved type to be a literal or a union", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 795);
960
+ const item_3 = Report_readerError_Z19516DCE("Exclude", "Was expecting the resolved type to be a literal or a union", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 794);
962
961
  const objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
963
962
  void (objectArg_3.push(item_3));
964
963
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -1279,7 +1278,7 @@ function UtilityType_withoutForeignTypeParameters(reader, bound, members) {
1279
1278
  export function UtilityType_readPartial(reader, typeReferenceNode) {
1280
1279
  const baseType = UtilityType_baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
1281
1280
  if (exists((typ) => (typ === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials)) {
1282
- const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1041);
1281
+ const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1040);
1283
1282
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1284
1283
  void (objectArg.push(item));
1285
1284
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -1332,7 +1331,7 @@ export function UtilityType_readPartial(reader, typeReferenceNode) {
1332
1331
  }
1333
1332
  default:
1334
1333
  if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
1335
- const item_1 = Report_readerError_Z19516DCE("partial inner type", "Was not able to resolve the inner type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1083);
1334
+ const item_1 = Report_readerError_Z19516DCE("partial inner type", "Was not able to resolve the inner type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1082);
1336
1335
  const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1337
1336
  void (objectArg_1.push(item_1));
1338
1337
  members = empty();
@@ -1441,7 +1440,7 @@ export function UtilityType_readOmitOrPick(reader, typeReferenceNode, keepListed
1441
1440
  const tryReadValueOfKeys = (typ) => {
1442
1441
  const activePatternResult_3 = Type_StringLiteral_$007CString$007COther$007C(typ);
1443
1442
  if (activePatternResult_3.tag === 1) {
1444
- const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1205);
1443
+ const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1204);
1445
1444
  const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1446
1445
  void (objectArg_1.push(item));
1447
1446
  return undefined;
@@ -1506,7 +1505,7 @@ export function UtilityType_readOmitOrPick(reader, typeReferenceNode, keepListed
1506
1505
  const filteredProperties = toList(filter((prop) => (keepListedKeys === contains_1(prop.name, keysToOmit, {
1507
1506
  Equals: (x, y) => (x === y),
1508
1507
  GetHashCode: (x) => (stringHash(x) | 0),
1509
- })), (matchValue_4 = baseType.flags, ($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? ((literalMembers != null) ? [] : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1240), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType))))) : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1240), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType)))))));
1508
+ })), (matchValue_4 = baseType.flags, ($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? ((literalMembers != null) ? [] : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1239), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType))))) : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1239), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType)))))));
1510
1509
  const isInProgress = exists((inProgress) => (inProgress === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
1511
1510
  const members_1 = isInProgress ? empty() : withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions, baseType, () => collect_1((property) => UtilityType_readPropertyMembers(reader, typeReferenceNode, property), filteredProperties));
1512
1511
  const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
@@ -1598,7 +1597,7 @@ export function UtilityType_readReadonly(reader, typeReferenceNode) {
1598
1597
  }, unionType.types))])])]);
1599
1598
  }
1600
1599
  catch (matchValue_1) {
1601
- const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1364);
1600
+ const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 1363);
1602
1601
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
1603
1602
  void (objectArg.push(item));
1604
1603
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -2456,7 +2455,7 @@ export function readTypeNode(reader, typeNode) {
2456
2455
  const literalTypeNode = typeNode;
2457
2456
  const matchValue_2 = tryReadLiteral(checker, literalTypeNode.literal);
2458
2457
  if (matchValue_2 == null) {
2459
- throw new Exception(Report_readerError_Z19516DCE("type node - literal type", "Could not read literal type", typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 2239));
2458
+ throw new Exception(Report_readerError_Z19516DCE("type node - literal type", "Could not read literal type", typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 2238));
2460
2459
  }
2461
2460
  else {
2462
2461
  return new GlueType(/* Literal */ 8, [matchValue_2]);
@@ -2471,7 +2470,7 @@ export function readTypeNode(reader, typeNode) {
2471
2470
  case 234:
2472
2471
  return readExpressionWithTypeArguments(reader, typeNode);
2473
2472
  default: {
2474
- const item = Report_readerError_Z19516DCE("type node", concat("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(typeNode.kind)), typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 2365);
2473
+ const item = Report_readerError_Z19516DCE("type node", concat("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(typeNode.kind)), typeNode, "/_//src/Glutinum.Converter/Reader/TypeNode.fs", 2364);
2475
2474
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
2476
2475
  void (objectArg.push(item));
2477
2476
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -253,14 +253,29 @@ export function entityNameText(node) {
253
253
  }
254
254
 
255
255
  /**
256
- * Identity of an anonymous type, a node synthesized by `typeToTypeNode` has none
256
+ * A node synthesized by `typeToTypeNode` has a negative position, or in TypeScript 6 a
257
+ * position without a source file; the checker throws when given one as enclosing declaration
257
258
  */
258
- export function typeLiteralId(node) {
259
+ export function enclosingDeclarationOf(node) {
259
260
  if ((node.pos < 0) ? true : Operators_IsNull(node.getSourceFile())) {
260
261
  return undefined;
261
262
  }
262
263
  else {
263
- return `${normalizePath(node.getSourceFile().fileName)}:${node.pos}`;
264
+ return node;
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Identity of an anonymous type, a node synthesized by `typeToTypeNode` has none
270
+ */
271
+ export function typeLiteralId(node) {
272
+ let node_1;
273
+ const option_1 = enclosingDeclarationOf(node);
274
+ if (option_1 != null) {
275
+ return (node_1 = option_1, `${normalizePath(node_1.getSourceFile().fileName)}:${node_1.pos}`);
276
+ }
277
+ else {
278
+ return undefined;
264
279
  }
265
280
  }
266
281
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { FSharpRef, Record } from "../fable_modules/fable-library-js.5.17.2/Types.js";
3
- import { Reporter__get_HasIterable, Reporter__get_HasReadonlyArray, Reporter__get_HasRegEpx, Reporter__get_Errors, Reporter__get_Warnings, TransformState_Create_Z68CEF8E2, TypeLiteralsMemory_$ctor, Reporter_$ctor, TransformContext__ToList, TransformContext_$ctor_Z1635F75A, TransformContext__get__Reporter, TransformContext__set_SiblingTypeNames_2FCB1351, TypeLiteralsMemory__LeaveModule, TypeLiteralsMemory__EnterModule_Z721C83C5, TransformContext__ExposeTypeAlias_1CE4A880, TransformContext__AddWarning_Z721C83C5, sanitizeTypeNameAndPushScope, ImportSource, importAllAttribute, TransformContext__get_TypeMemory, importAttribute, sanitizeMemberNameAndPushScope, TransformContext__get_ImportSource, importDefaultAttribute, TransformContext__AddError_Z721C83C5, TypeLiteralsMemory__Remember_74C8CBB, TransformContext__get_TypeLiteralsMemory, TransformContext__get_Root, TypeLiteralsMemory__TryReference_433E080, TransformContext__get_State, TransformContext__NewTypeName, TransformContext__get_FullName, TransformContext__ExposeType_Z1D58A540, TransformContext__PushScope_27AED5E3, sanitizeNameAndPushScope, TransformContext__get_CurrentScopeName, TransformContext__ExposeIterable, TransformContext__ReferenceName_Z721C83C5, TransformContext__get_OriginalScopeName, TransformContext__ExposeTypeAlias_Z721C83C5, TransformContext__ExposeReadonlyArray, ImportSource_$reflection, TransformContext_$reflection } from "./Transformer/Context.js";
3
+ import { Reporter__get_HasIterable, Reporter__get_HasReadonlyArray, Reporter__get_HasRegEpx, Reporter__get_Errors, Reporter__get_Warnings, TransformState_Create_Z68CEF8E2, TypeLiteralsMemory_$ctor, Reporter_$ctor, TransformContext__ToList, TransformContext_$ctor_Z1635F75A, TransformContext__get__Reporter, TransformContext__set_SiblingTypeNames_2FCB1351, TypeLiteralsMemory__LeaveModule, TypeLiteralsMemory__EnterModule_Z721C83C5, TransformContext__ExposeTypeAlias_1CE4A880, TransformContext__AddWarning_Z721C83C5, sanitizeTypeNameAndPushScope, ImportSource, importAllAttribute, TransformContext__get_TypeMemory, importAttribute, sanitizeMemberNameAndPushScope, TransformContext__get_ImportSource, importDefaultAttribute, TransformContext__AddError_Z721C83C5, TypeLiteralsMemory__Remember_74C8CBB, TransformContext__get_TypeLiteralsMemory, TransformContext__get_Root, TypeLiteralsMemory__TryReference_433E080, TransformContext__get_State, TransformContext__get_FullName, TransformContext__ExposeType_Z1D58A540, TransformContext__PushScope_27AED5E3, sanitizeNameAndPushScope, TransformContext__NewTypeName, TransformContext__get_CurrentScopeName, TransformContext__ExposeIterable, TransformContext__ReferenceName_Z721C83C5, TransformContext__get_OriginalScopeName, TransformContext__ExposeTypeAlias_Z721C83C5, TransformContext__ExposeReadonlyArray, ImportSource_$reflection, TransformContext_$reflection } from "./Transformer/Context.js";
4
4
  import { int32_type, array_type, option_type, list_type, record_type, class_type, string_type, bool_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
5
5
  import { FSharpModule, FSharpSingleErasedCaseUnion, FSharpJSApi, FSharpEnum, FSharpEnumCase, FSharpLiteral, FSharpTypeParameterInfo_Create_Z6CFD3565, FSharpUnionCaseNamed, FSharpClass, FSharpConstructor, FSharpExplicitField, FSharpStaticMemberInfo, FSharpAccessor, FSharpMemberInfoBody, FSharpAccessibility, FSharpMember, FSharpMemberInfo, FSharpParameter, FSharpThisType, FSharpPrimitive, FSharpTypeAlias, FSharpDelegate, FSharpFunctionType, FSharpTypeReference, FSharpUnion, FSharpUnionCase, FSharpTypeParameter, FSharpMapped, FSharpInterface, FSharpAttribute, FSharpType, FSharpType_$reflection, FSharpTypeParameter_$reflection, FSharpMember_$reflection } from "./FsharpAST.js";
6
6
  import { GlueReExport, GlueClassDeclaration, GlueLiteral__ToText, GlueIndexSignature, GlueLiteral, GlueMember__TryGetAccessor, GlueMember__get_Documentation, GlueProperty, GlueAccessor, GlueMethod, GlueMethodSignature, GlueSubstitution_mentionedTypeParameters, GlueFunctionType, GlueParameter, GlueTypeUnion, GlueFunctionDeclaration, GlueVariable, GlueType__get_Name, GlueConstructor, GlueTypeReference, GluePrimitive, GlueType, GlueTypeLiteral, GlueMember, GlueTypeParameter, GlueSubstitution_substitute, GlueSubstitution_substituteParameter, GlueInterface, GlueTypeAliasDeclaration_$reflection, GlueType_$reflection } from "./GlueAST.js";
@@ -8,8 +8,8 @@ import { transformComment, TransformCommentResult_$reflection } from "./Transfor
8
8
  import { add, contains as contains_2, union, empty as empty_2, ofSeq, singleton as singleton_2, ofList, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.17.2/Set.js";
9
9
  import { aggregatedExports, replaceSelfReference, isUnitAlias, typedArrayNames, transformPrimitive, requiredBeforeParamArray, isDataObject, Interface_makePartial, tryUnwrapOption, iteratorNames } from "./Transformer/Utils.js";
10
10
  import { value as value_7, unwrap, toArray, defaultArg } from "../fable_modules/fable-library-js.5.17.2/Option.js";
11
- import { zip, mapFold, item, concat as concat_1, reverse, iterate, cons, foldBack, fold, tryFind, ofSeq as ofSeq_1, forAll as forAll_1, sortBy, tryPick, truncate, exists, contains, mapIndexed, partition, filter, append, length, collect, tryLast, choose, tryHead, singleton, empty, ofArray, map, head as head_1, tail as tail_3, isEmpty } from "../fable_modules/fable-library-js.5.17.2/List.js";
12
- import { aliasArities, namedTypeParameters, membersNameUndeclaredTypeParameters, mentionsTypeParameter, ownTypeParameterDefaults, typeParameterNames as typeParameterNames_1, unconstrained, memberTypeParameterNames, typeArguments, declaredTypeParameters } from "./Transformer/TypeParameters.js";
11
+ import { zip, mapFold, item, concat as concat_1, reverse, iterate, cons, foldBack, fold, tryFind, ofSeq as ofSeq_1, forAll as forAll_1, sortBy, tryPick, truncate, exists, contains, partition, mapIndexed, filter, append, length, collect, tryLast, choose, tryHead, singleton, empty, ofArray, map, head as head_1, tail as tail_3, isEmpty } from "../fable_modules/fable-library-js.5.17.2/List.js";
12
+ import { aliasArities, namedTypeParameters, membersNameUndeclaredTypeParameters, mentionsTypeParameter, ownTypeParameterDefaults, typeParameterNames as typeParameterNames_2, unconstrained, memberTypeParameterNames, typeArguments, declaredTypeParameters } from "./Transformer/TypeParameters.js";
13
13
  import { List_groupBy, List_distinct } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
14
14
  import { uncurry2, curry2, Lazy, structuralHash, Exception, numberHash, int32ToString, disposeSafe, getEnumerator, defaultOf, comparePrimitives, safeHash, equals, stringHash } from "../fable_modules/fable-library-js.5.17.2/Util.js";
15
15
  import { replace, trim, printf, toFail, substring, interpolate, concat } from "../fable_modules/fable-library-js.5.17.2/String.js";
@@ -595,14 +595,23 @@ function UtilityType_readonlyInterface(context, members) {
595
595
  }
596
596
 
597
597
  function UtilityType_readonlyUnion(context, interfaces) {
598
- const patternInput = sanitizeNameAndPushScope(`U${length(interfaces)}`, context);
599
- return new FSharpType(/* Union */ 1, [new FSharpUnion(empty(), patternInput[0], map((glueInterface) => {
600
- const context_2 = TransformContext__PushScope_27AED5E3(patternInput[1], concat("ReadOnly", glueInterface.Name));
601
- const initialInterface = transformInterface(context_2, glueInterface);
598
+ const isLarge = length(interfaces) > 9;
599
+ const name = isLarge ? TransformContext__NewTypeName(context) : (`U${length(interfaces)}`);
600
+ const caseContext = isLarge ? context : sanitizeNameAndPushScope(name, context)[1];
601
+ const caseTypes = map((glueInterface) => {
602
+ const context_1 = TransformContext__PushScope_27AED5E3(caseContext, concat("ReadOnly", glueInterface.Name));
603
+ const initialInterface = transformInterface(context_1, glueInterface);
602
604
  const adaptedInterface = new FSharpInterface(initialInterface.Attributes, initialInterface.Name, initialInterface.XmlDoc, initialInterface.OriginalName, initialInterface.TypeParameters, TransformMembers_forceReadonly(initialInterface.Members), initialInterface.Inheritance);
603
- TransformContext__ExposeType_Z1D58A540(context_2, new FSharpType(/* Interface */ 5, [new FSharpInterface(adaptedInterface.Attributes, TransformContext__get_CurrentScopeName(context_2), adaptedInterface.XmlDoc, adaptedInterface.OriginalName, adaptedInterface.TypeParameters, adaptedInterface.Members, adaptedInterface.Inheritance)]));
604
- return new FSharpUnionCase(/* Typed */ 1, [new FSharpType(/* Interface */ 5, [new FSharpInterface(adaptedInterface.Attributes, TransformContext__get_FullName(context_2), adaptedInterface.XmlDoc, adaptedInterface.OriginalName, adaptedInterface.TypeParameters, adaptedInterface.Members, adaptedInterface.Inheritance)])]);
605
- }, interfaces), false, empty(), empty())]);
605
+ TransformContext__ExposeType_Z1D58A540(context_1, new FSharpType(/* Interface */ 5, [new FSharpInterface(adaptedInterface.Attributes, TransformContext__get_CurrentScopeName(context_1), adaptedInterface.XmlDoc, adaptedInterface.OriginalName, adaptedInterface.TypeParameters, adaptedInterface.Members, adaptedInterface.Inheritance)]));
606
+ return new FSharpType(/* Interface */ 5, [new FSharpInterface(adaptedInterface.Attributes, TransformContext__get_FullName(context_1), adaptedInterface.XmlDoc, adaptedInterface.OriginalName, adaptedInterface.TypeParameters, adaptedInterface.Members, adaptedInterface.Inheritance)]);
607
+ }, interfaces);
608
+ if (isLarge) {
609
+ TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Union */ 1, [erasedUnion(name, empty(), caseTypes)]));
610
+ return referenceToExposed(context, name, empty());
611
+ }
612
+ else {
613
+ return new FSharpType(/* Union */ 1, [new FSharpUnion(empty(), name, map((Item_3) => (new FSharpUnionCase(/* Typed */ 1, [Item_3])), caseTypes), false, empty(), empty())]);
614
+ }
606
615
  }
607
616
 
608
617
  function UtilityType_transformReadOnlyInline(context, readonlyInfo) {
@@ -700,7 +709,7 @@ function UtilityType_transform(context, utilityType) {
700
709
  return FSharpType.Object$;
701
710
  case 2: {
702
711
  const name_2 = TransformContext__NewTypeName(context);
703
- const freeTypeParameterNames_1 = List_distinct(append(typeParameterNames_1(recordInfo.KeyType), typeParameterNames_1(recordInfo.ValueType)), {
712
+ const freeTypeParameterNames_1 = List_distinct(append(typeParameterNames_2(recordInfo.KeyType), typeParameterNames_2(recordInfo.ValueType)), {
704
713
  Equals: (x_1, y_1) => (x_1 === y_1),
705
714
  GetHashCode: (x_1) => (stringHash(x_1) | 0),
706
715
  });
@@ -758,6 +767,15 @@ function $007CRememberedTypeLiteral$007C_$007C(context, glueType) {
758
767
  }
759
768
  }
760
769
 
770
+ function erasedUnion(name, typeParameters, caseTypes) {
771
+ return new FSharpUnion(ofArray([FSharpAttribute.RequireQualifiedAccess, FSharpAttribute.Erase]), name, mapIndexed((index, caseType) => (new FSharpUnionCase(/* Field */ 2, [`Case${index + 1}`, caseType])), caseTypes), false, typeParameters, empty());
772
+ }
773
+
774
+ function referenceToExposed(context, name, typeParameterNames) {
775
+ const fullName = TransformContext__ReferenceName_Z721C83C5(context, name);
776
+ return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(fullName, fullName, empty(), map((Item) => (new FSharpType(/* TypeParameter */ 13, [Item])), typeParameterNames), FSharpType.Discard)]);
777
+ }
778
+
761
779
  function transformUnionType(context, cases) {
762
780
  let typ, unionInfo;
763
781
  const patternInput = partition((glueType) => {
@@ -789,22 +807,16 @@ function transformUnionType(context, cases) {
789
807
  return FSharpType.Object$;
790
808
  }
791
809
  }
792
- else if (length(others) > 9) {
793
- if (isOptional) {
794
- return new FSharpType(/* Option */ 3, [FSharpType.Object$]);
795
- }
796
- else {
797
- return FSharpType.Object$;
798
- }
799
- }
800
810
  else if (length(others) === 1) {
801
811
  return transformType(context, head_1(others));
802
812
  }
803
813
  else {
804
814
  const matchValue = tryOptimizeUnionType(context, TransformContext__get_CurrentScopeName(context), others);
805
815
  if (matchValue == null) {
806
- const patternInput_1 = sanitizeNameAndPushScope(`U${length(others)}`, context);
807
- const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(patternInput_1[1], `Case${index + 1}`), caseType), others), {
816
+ const isLarge = length(others) > 9;
817
+ const name_1 = isLarge ? TransformContext__NewTypeName(context) : (`U${length(others)}`);
818
+ const caseContext = isLarge ? context : sanitizeNameAndPushScope(name_1, context)[1];
819
+ const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(caseContext, `Case${index + 1}`), caseType), others), {
808
820
  Equals: equals,
809
821
  GetHashCode: (x_1) => (safeHash(x_1) | 0),
810
822
  });
@@ -814,25 +826,45 @@ function transformUnionType(context, cases) {
814
826
  matchResult = 0;
815
827
  single = head_1(caseTypes);
816
828
  }
817
- else {
829
+ else if (isLarge) {
818
830
  matchResult = 1;
819
831
  }
832
+ else {
833
+ matchResult = 2;
834
+ }
820
835
  }
821
- else {
836
+ else if (isLarge) {
822
837
  matchResult = 1;
823
838
  }
839
+ else {
840
+ matchResult = 2;
841
+ }
824
842
  switch (matchResult) {
825
843
  case 0:
826
844
  return single;
845
+ case 1: {
846
+ const typeParameterNames_1 = List_distinct(collect(typeParameterNames_2, others), {
847
+ Equals: (x_2, y_2) => (x_2 === y_2),
848
+ GetHashCode: (x_2) => (stringHash(x_2) | 0),
849
+ });
850
+ TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Union */ 1, [erasedUnion(name_1, declaredTypeParameters(typeParameterNames_1), caseTypes)]));
851
+ const reference = referenceToExposed(context, name_1, typeParameterNames_1);
852
+ if (isOptional) {
853
+ return new FSharpType(/* Option */ 3, [reference]);
854
+ }
855
+ else {
856
+ return reference;
857
+ }
858
+ }
827
859
  default: {
828
- const cases_1 = map((Item_2) => (new FSharpUnionCase(/* Typed */ 1, [Item_2])), caseTypes);
860
+ const cases_1 = map((Item_1) => (new FSharpUnionCase(/* Typed */ 1, [Item_1])), caseTypes);
829
861
  return new FSharpType(/* Union */ 1, [new FSharpUnion(empty(), `U${length(caseTypes)}`, cases_1, isOptional, empty(), empty())]);
830
862
  }
831
863
  }
832
864
  }
833
865
  else {
834
866
  const name = TransformContext__NewTypeName(context);
835
- const typeParameterNames = List_distinct(collect(typeParameterNames_1, others), {
867
+ const typeParameterNames = List_distinct(collect(typeParameterNames_2, others), {
836
868
  Equals: (x, y) => (x === y),
837
869
  GetHashCode: (x) => (stringHash(x) | 0),
838
870
  });
@@ -842,8 +874,7 @@ function transformUnionType(context, cases) {
842
874
  if (option_3 != null) {
843
875
  TransformContext__ExposeType_Z1D58A540(context, option_3);
844
876
  }
845
- const fullName = TransformContext__ReferenceName_Z721C83C5(context, name);
846
- return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(fullName, fullName, empty(), map((Item) => (new FSharpType(/* TypeParameter */ 13, [Item])), typeParameterNames), FSharpType.Discard)]);
877
+ return referenceToExposed(context, name, typeParameterNames);
847
878
  }
848
879
  }
849
880
  }
@@ -954,7 +985,7 @@ function transformIntersectionOfReferences(context, references, members) {
954
985
  return FSharpType.Object$;
955
986
  }
956
987
  else {
957
- const typeParameterNames = List_distinct(collect(typeParameterNames_1, references), {
988
+ const typeParameterNames = List_distinct(collect(typeParameterNames_2, references), {
958
989
  Equals: (x, y) => (x === y),
959
990
  GetHashCode: (x) => (stringHash(x) | 0),
960
991
  });
@@ -988,7 +1019,7 @@ function transformMappedType(context, mappedType) {
988
1019
  }
989
1020
  else {
990
1021
  const name = TransformContext__NewTypeName(context);
991
- const freeTypeParameterNames = List_distinct(filter((typeParameterName) => (typeParameterName !== mappedType.TypeParameter.Name), defaultArg((option_1 = mappedType.Type, (option_1 != null) ? typeParameterNames_1(option_1) : undefined), empty())), {
1022
+ const freeTypeParameterNames = List_distinct(filter((typeParameterName) => (typeParameterName !== mappedType.TypeParameter.Name), defaultArg((option_1 = mappedType.Type, (option_1 != null) ? typeParameterNames_2(option_1) : undefined), empty())), {
992
1023
  Equals: (x, y) => (x === y),
993
1024
  GetHashCode: (x) => (stringHash(x) | 0),
994
1025
  });
@@ -3959,7 +3990,8 @@ function TypeParameter_mapFSharpType(seadledTypes, typ) {
3959
3990
  }
3960
3991
 
3961
3992
  function TypeParameter_mapFsharpParameter(seadledTypes, parameter) {
3962
- return new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, TypeParameter_mapFSharpType(seadledTypes, parameter.Type), parameter.OriginalGlueMember);
3993
+ const typ = TypeParameter_mapFSharpType(seadledTypes, parameter.Type);
3994
+ return new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, parameter.IsOptional ? defaultArg(tryUnwrapOption(typ), typ) : typ, parameter.OriginalGlueMember);
3963
3995
  }
3964
3996
 
3965
3997
  function transformTypeParameters(context, typeParameters) {
@@ -4759,27 +4791,46 @@ function aliasOfUnion(scope, cases, unionType) {
4759
4791
  return false;
4760
4792
  }
4761
4793
  }, cases);
4762
- let matchResult_1, single;
4794
+ let matchResult_1, single, others_3;
4763
4795
  if (!isEmpty(matchValue_1[0])) {
4764
4796
  if (!isEmpty(matchValue_1[1])) {
4765
4797
  if (isEmpty(tail_3(matchValue_1[1]))) {
4766
4798
  matchResult_1 = 0;
4767
4799
  single = head_1(matchValue_1[1]);
4768
4800
  }
4769
- else {
4801
+ else if (length(matchValue_1[1]) > 9) {
4770
4802
  matchResult_1 = 1;
4803
+ others_3 = matchValue_1[1];
4804
+ }
4805
+ else {
4806
+ matchResult_1 = 2;
4771
4807
  }
4772
4808
  }
4773
- else {
4809
+ else if (length(matchValue_1[1]) > 9) {
4774
4810
  matchResult_1 = 1;
4811
+ others_3 = matchValue_1[1];
4812
+ }
4813
+ else {
4814
+ matchResult_1 = 2;
4775
4815
  }
4776
4816
  }
4777
- else {
4817
+ else if (length(matchValue_1[1]) > 9) {
4778
4818
  matchResult_1 = 1;
4819
+ others_3 = matchValue_1[1];
4820
+ }
4821
+ else {
4822
+ matchResult_1 = 2;
4779
4823
  }
4780
4824
  switch (matchResult_1) {
4781
4825
  case 0:
4782
4826
  return aliasOf(scope, new FSharpType(/* Option */ 3, [transformType(TransformContext__PushScope_27AED5E3(context, "Value"), single)]));
4827
+ case 1: {
4828
+ const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(context, `Case${index + 1}`), caseType), others_3), {
4829
+ Equals: equals,
4830
+ GetHashCode: (x) => (safeHash(x) | 0),
4831
+ });
4832
+ return new FSharpType(/* Union */ 1, [erasedUnion(scope.Name, scope.TypeParameters.Value.TypeParameters, caseTypes)]);
4833
+ }
4783
4834
  default:
4784
4835
  return aliasOf(scope, transformType(context, unionType));
4785
4836
  }
@@ -4943,7 +4994,7 @@ function aliasOfUtilityType(scope, utilityType) {
4943
4994
  case 4: {
4944
4995
  const typeParameters = scope.TypeParameters.Value.TypeParameters;
4945
4996
  const candidate = new GlueInterface(scope.Declaration.Documentation, scope.Declaration.FullName, scope.Declaration.Name, members, scope.Declaration.TypeParameters, empty());
4946
- const creates = isCandidate(TransformContext__get_State(context).ParamObjects, TransformContext__get_TypeMemory(context), candidate) ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(scope.Name, typeParameters)]), members) : empty();
4997
+ const creates = isCandidate(TransformContext__get_TypeMemory(context), candidate) ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(scope.Name, typeParameters)]), members) : empty();
4947
4998
  return aliasInterfaceOf(scope, typeParameters, append(TransformMembers_toFSharpMember(context, members), creates), empty());
4948
4999
  }
4949
5000
  default:
@@ -4964,7 +5015,7 @@ function aliasOfTypeLiteral(scope, typeLiteralInfo) {
4964
5015
  const context = scope.Context;
4965
5016
  const typeParameters = scope.TypeParameters.Value.TypeParameters;
4966
5017
  const candidate = new GlueInterface(scope.Declaration.Documentation, scope.Declaration.FullName, scope.Declaration.Name, typeLiteralInfo.Members, scope.Declaration.TypeParameters, empty());
4967
- const creates = isCandidate(TransformContext__get_State(context).ParamObjects, TransformContext__get_TypeMemory(context), candidate) ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(scope.Name, typeParameters)]), typeLiteralInfo.Members) : empty();
5018
+ const creates = isCandidate(TransformContext__get_TypeMemory(context), candidate) ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(scope.Name, typeParameters)]), typeLiteralInfo.Members) : empty();
4968
5019
  return aliasInterfaceOf(scope, typeParameters, append(TransformMembers_toFSharpMember(context, typeLiteralInfo.Members), creates), ofArray(toArray(TypeLiteral_tryFindIterableType(context, typeLiteralInfo.Members))));
4969
5020
  }
4970
5021
 
@@ -5534,7 +5585,7 @@ function transformToFsharp(context, glueTypes) {
5534
5585
  break;
5535
5586
  }
5536
5587
  default:
5537
- if (isCandidate(TransformContext__get_State(context).ParamObjects, TransformContext__get_TypeMemory(context), _arg_1.fields[0])) {
5588
+ if (isCandidate(TransformContext__get_TypeMemory(context), _arg_1.fields[0])) {
5538
5589
  matchResult = 0;
5539
5590
  interfaceInfo_1 = _arg_1.fields[0];
5540
5591
  }
@@ -6,8 +6,7 @@ import { isEmpty, empty, singleton, contains, map } from "../../fable_modules/fa
6
6
  import { FSharpModule, FSharpTypeAlias, FSharpEnum, FSharpUnion, FSharpDelegate, FSharpClass, FSharpInterface, FSharpAttribute, FSharpMember, FSharpMemberInfo, FSharpType } from "../FsharpAST.js";
7
7
  import { Union, FSharpRef, Record } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
8
8
  import { create, State_$reflection } from "./Conditionals.js";
9
- import { create as create_1, State_$reflection as State_$reflection_1 } from "./ParamObjectCandidate.js";
10
- import { create as create_2, State_$reflection as State_$reflection_2 } from "./KeyOfMaps.js";
9
+ import { create as create_1, State_$reflection as State_$reflection_1 } from "./KeyOfMaps.js";
11
10
  import { getItemFromDict, tryGetValue } from "../../fable_modules/fable-library-js.5.17.2/MapUtil.js";
12
11
  import { collect, append, delay, toList, tryFindIndex } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
13
12
  import { setItem } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
@@ -165,10 +164,9 @@ export function typeName(typ) {
165
164
  * The indexes of the run over the type memory, and the declarations being expanded
166
165
  */
167
166
  export class TransformState extends Record {
168
- constructor(Conditionals, ParamObjects, KeyOfMaps, PartialHeritageBeingExpanded, MaxOverloads) {
167
+ constructor(Conditionals, KeyOfMaps, PartialHeritageBeingExpanded, MaxOverloads) {
169
168
  super();
170
169
  this.Conditionals = Conditionals;
171
- this.ParamObjects = ParamObjects;
172
170
  this.KeyOfMaps = KeyOfMaps;
173
171
  this.PartialHeritageBeingExpanded = PartialHeritageBeingExpanded;
174
172
  this.MaxOverloads = (MaxOverloads | 0);
@@ -176,11 +174,11 @@ export class TransformState extends Record {
176
174
  }
177
175
 
178
176
  export function TransformState_$reflection() {
179
- return record_type("Glutinum.Converter.Transformer.Context.TransformState", [], TransformState, () => [["Conditionals", State_$reflection()], ["ParamObjects", State_$reflection_1()], ["KeyOfMaps", State_$reflection_2()], ["PartialHeritageBeingExpanded", array_type(string_type)], ["MaxOverloads", int32_type]]);
177
+ return record_type("Glutinum.Converter.Transformer.Context.TransformState", [], TransformState, () => [["Conditionals", State_$reflection()], ["KeyOfMaps", State_$reflection_1()], ["PartialHeritageBeingExpanded", array_type(string_type)], ["MaxOverloads", int32_type]]);
180
178
  }
181
179
 
182
180
  export function TransformState_Create_Z68CEF8E2(typeMemory, maxOverloads) {
183
- return new TransformState(create(typeMemory), create_1(typeMemory), create_2(typeMemory), [], maxOverloads);
181
+ return new TransformState(create(typeMemory), create_1(typeMemory), [], maxOverloads);
184
182
  }
185
183
 
186
184
  /**
@@ -1,81 +1,39 @@
1
1
 
2
- import { length, exists, ofSeq, forAll, cons, tryFind, filter, choose, tail, head, isEmpty, map, fold, tryPick, append, empty, collect as collect_1, singleton } from "../../fable_modules/fable-library-js.5.17.2/List.js";
3
- import { FSharpSet__Contains, ofSeq as ofSeq_1, empty as empty_1, ofList, add, contains } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
4
- import { defaultOf, disposeSafe, getEnumerator, safeHash, equals, comparePrimitives, curry2 } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
5
- import { GlueType, GluePrimitive, GlueMember, GlueProperty } from "../GlueAST.js";
2
+ import { substring } from "../../fable_modules/fable-library-js.5.17.2/String.js";
3
+ import { length, collect, filter, choose, empty, append, forAll, exists, tail, head, isEmpty, map, fold, tryPick } from "../../fable_modules/fable-library-js.5.17.2/List.js";
4
+ import { FSharpSet__Contains, empty as empty_1, ofList, add, contains } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
5
+ import { safeHash, equals, comparePrimitives, curry2 } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
6
+ import { GluePrimitive, GlueSubstitution_substituteMember, GlueTypeUnion, GlueTypeReference, GlueType, GlueSubstitution_substitute, GlueSubstitution_ofTypeArguments, GlueMember, GlueProperty } from "../GlueAST.js";
6
7
  import { List_distinct, List_distinctBy } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
7
8
  import { FSharpChoice$2 } from "../../fable_modules/fable-library-js.5.17.2/Choice.js";
8
- import { defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
9
- import { FSharpRef, Record } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
10
- import { record_type, class_type, string_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
11
- import { tryGetValue, addToSet } from "../../fable_modules/fable-library-js.5.17.2/MapUtil.js";
12
9
  import { isUnionCaseName } from "./Utils.js";
13
10
  import { memberTypeParameterNames } from "./TypeParameters.js";
11
+ import { defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
14
12
 
15
- function typeReferenceFullNames(glueType) {
16
- switch (glueType.tag) {
17
- case 13:
18
- return singleton(glueType.fields[0].FullName);
19
- case 7:
20
- return collect_1(typeReferenceFullNames, glueType.fields[0].fields[0]);
21
- default:
22
- return empty();
13
+ function containerOf(fullName) {
14
+ let unquoted;
15
+ if (fullName.startsWith("\"")) {
16
+ const matchValue = fullName.indexOf("\".", 1) | 0;
17
+ unquoted = ((matchValue === -1) ? fullName : substring(fullName, matchValue + 2));
23
18
  }
24
- }
25
-
26
- function memberParameters(glueMember) {
27
- switch (glueMember.tag) {
28
- case 6:
29
- return glueMember.fields[0].Parameters;
30
- case 4:
31
- return glueMember.fields[0].Parameters;
32
- case 7:
33
- return glueMember.fields[0].Parameters;
34
- case 1:
35
- case 2:
36
- case 3:
37
- case 5:
38
- return empty();
39
- default:
40
- return glueMember.fields[0].Parameters;
19
+ else {
20
+ unquoted = fullName;
21
+ }
22
+ const matchValue_1 = unquoted.lastIndexOf(".") | 0;
23
+ if (matchValue_1 === -1) {
24
+ return "";
25
+ }
26
+ else {
27
+ return substring(unquoted, 0, matchValue_1);
41
28
  }
42
29
  }
43
30
 
44
- function parameters(glueType_mut) {
45
- parameters:
46
- while (true) {
47
- const glueType = glueType_mut;
48
- switch (glueType.tag) {
49
- case 6:
50
- return glueType.fields[0].Parameters;
51
- case 12: {
52
- const info_1 = glueType.fields[0];
53
- return append(collect_1((_arg) => _arg.Parameters, info_1.Constructors), collect_1(memberParameters, info_1.Members));
54
- }
55
- case 1:
56
- return collect_1(memberParameters, glueType.fields[0].Members);
57
- case 22:
58
- return collect_1(memberParameters, glueType.fields[0].Members);
59
- case 15:
60
- return glueType.fields[0].Parameters;
61
- case 29:
62
- return glueType.fields[0].Parameters;
63
- case 5: {
64
- glueType_mut = glueType.fields[0].Type;
65
- continue parameters;
66
- }
67
- case 2: {
68
- glueType_mut = glueType.fields[0].Type;
69
- continue parameters;
70
- }
71
- case 25: {
72
- glueType_mut = glueType.fields[0];
73
- continue parameters;
74
- }
75
- default:
76
- return empty();
77
- }
78
- break;
31
+ function isEnclosing(container, inner) {
32
+ if ((container === "") ? true : (container === inner)) {
33
+ return true;
34
+ }
35
+ else {
36
+ return inner.startsWith(container + ".");
79
37
  }
80
38
  }
81
39
 
@@ -108,9 +66,9 @@ export function tryResolveMembers(typeMemory, info) {
108
66
  }
109
67
  else {
110
68
  const visited_1 = add(info_1.FullName, visited);
111
- const option_7 = fold((acc, heritageClause_1) => {
69
+ const option_9 = fold((acc, heritageClause_1) => {
112
70
  let typeReference;
113
- let matchValue_1;
71
+ let matchValue_3;
114
72
  const heritageClause = heritageClause_1;
115
73
  let matchResult_1, typeReference_1, members, typeReference_2;
116
74
  switch (heritageClause.tag) {
@@ -173,7 +131,7 @@ export function tryResolveMembers(typeMemory, info) {
173
131
  const binder = curry2(resolve)(visited_1);
174
132
  const option_1 = option;
175
133
  option_3 = ((option_1 != null) ? binder(option_1) : undefined);
176
- matchValue_1 = ((option_3 != null) ? map((_arg_1) => {
134
+ matchValue_3 = ((option_3 != null) ? map((_arg_1) => {
177
135
  if (_arg_1.tag === 1) {
178
136
  const property = _arg_1.fields[0];
179
137
  return new GlueMember(/* Property */ 1, [new GlueProperty(property.Name, property.Documentation, property.Type, property.IsStatic, true, property.Accessor, property.IsPrivate)]);
@@ -185,65 +143,225 @@ export function tryResolveMembers(typeMemory, info) {
185
143
  break;
186
144
  }
187
145
  default:
188
- matchValue_1 = undefined;
146
+ matchValue_3 = undefined;
189
147
  }
190
148
  break;
191
149
  }
192
150
  case 1: {
193
- matchValue_1 = members;
151
+ matchValue_3 = members;
194
152
  break;
195
153
  }
196
154
  case 2: {
197
- const option_4 = tryFindInterface(typeReference_2.FullName);
198
- const binder_2 = curry2(resolve)(visited_1);
199
- const option_5 = option_4;
200
- matchValue_1 = ((option_5 != null) ? binder_2(option_5) : undefined);
155
+ const matchValue_1 = tryFindInterface(typeReference_2.FullName);
156
+ if (matchValue_1 == null) {
157
+ matchValue_3 = undefined;
158
+ }
159
+ else {
160
+ const baseInterface = matchValue_1;
161
+ const substitutions = GlueSubstitution_ofTypeArguments(baseInterface.TypeParameters, typeReference_2.TypeArguments);
162
+ const qualifySelf = (glueType) => {
163
+ let reference;
164
+ let matchResult_3, thisType_1, reference_1, reference_2, cases, elementType, innerType, glueType_2;
165
+ switch (glueType.tag) {
166
+ case 17: {
167
+ if (glueType.fields[0].Name === baseInterface.Name) {
168
+ matchResult_3 = 0;
169
+ thisType_1 = glueType.fields[0];
170
+ }
171
+ else {
172
+ matchResult_3 = 6;
173
+ glueType_2 = glueType;
174
+ }
175
+ break;
176
+ }
177
+ case 13: {
178
+ if ((reference = glueType.fields[0], (reference.FullName === baseInterface.FullName) && isEmpty(reference.ModulePath))) {
179
+ matchResult_3 = 1;
180
+ reference_1 = glueType.fields[0];
181
+ }
182
+ else {
183
+ matchResult_3 = 2;
184
+ reference_2 = glueType.fields[0];
185
+ }
186
+ break;
187
+ }
188
+ case 7: {
189
+ matchResult_3 = 3;
190
+ cases = glueType.fields[0].fields[0];
191
+ break;
192
+ }
193
+ case 14: {
194
+ matchResult_3 = 4;
195
+ elementType = glueType.fields[0];
196
+ break;
197
+ }
198
+ case 23: {
199
+ matchResult_3 = 5;
200
+ innerType = glueType.fields[0];
201
+ break;
202
+ }
203
+ default: {
204
+ matchResult_3 = 6;
205
+ glueType_2 = glueType;
206
+ }
207
+ }
208
+ switch (matchResult_3) {
209
+ case 0:
210
+ return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(baseInterface.Name, baseInterface.FullName, typeReference_2.ModulePath, map((typeParameter) => GlueSubstitution_substitute(substitutions, new GlueType(/* TypeParameter */ 16, [typeParameter.Name])), thisType_1.TypeParameters), false)]);
211
+ case 1:
212
+ return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(reference_1.Name, reference_1.FullName, typeReference_2.ModulePath, map(qualifySelf, reference_1.TypeArguments), reference_1.IsStandardLibrary)]);
213
+ case 2:
214
+ return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(reference_2.Name, reference_2.FullName, reference_2.ModulePath, map(qualifySelf, reference_2.TypeArguments), reference_2.IsStandardLibrary)]);
215
+ case 3:
216
+ return new GlueType(/* Union */ 7, [new GlueTypeUnion(map(qualifySelf, cases))]);
217
+ case 4:
218
+ return new GlueType(/* Array */ 14, [qualifySelf(elementType)]);
219
+ case 5:
220
+ return new GlueType(/* OptionalType */ 23, [qualifySelf(innerType)]);
221
+ default:
222
+ return glueType_2;
223
+ }
224
+ };
225
+ const namesForeignType = (glueType_3_mut) => {
226
+ namesForeignType:
227
+ while (true) {
228
+ const glueType_3 = glueType_3_mut;
229
+ let matchResult_4, innerType_1;
230
+ switch (glueType_3.tag) {
231
+ case 13: {
232
+ matchResult_4 = 0;
233
+ break;
234
+ }
235
+ case 7: {
236
+ matchResult_4 = 1;
237
+ break;
238
+ }
239
+ case 14: {
240
+ matchResult_4 = 2;
241
+ innerType_1 = glueType_3.fields[0];
242
+ break;
243
+ }
244
+ case 30: {
245
+ matchResult_4 = 2;
246
+ innerType_1 = glueType_3.fields[0];
247
+ break;
248
+ }
249
+ case 23: {
250
+ matchResult_4 = 2;
251
+ innerType_1 = glueType_3.fields[0];
252
+ break;
253
+ }
254
+ case 18: {
255
+ matchResult_4 = 3;
256
+ break;
257
+ }
258
+ case 15: {
259
+ matchResult_4 = 4;
260
+ break;
261
+ }
262
+ default:
263
+ matchResult_4 = 5;
264
+ }
265
+ switch (matchResult_4) {
266
+ case 0: {
267
+ const reference_3 = glueType_3.fields[0];
268
+ if ((isEmpty(reference_3.ModulePath) && !reference_3.IsStandardLibrary) && !isEnclosing(containerOf(reference_3.FullName), containerOf(info_1.FullName))) {
269
+ return true;
270
+ }
271
+ else {
272
+ return exists(namesForeignType, reference_3.TypeArguments);
273
+ }
274
+ }
275
+ case 1:
276
+ return exists(namesForeignType, glueType_3.fields[0].fields[0]);
277
+ case 2: {
278
+ glueType_3_mut = innerType_1;
279
+ continue namesForeignType;
280
+ }
281
+ case 3:
282
+ return exists(namesForeignType, glueType_3.fields[0]);
283
+ case 4: {
284
+ const functionType = glueType_3.fields[0];
285
+ if (namesForeignType(functionType.Type)) {
286
+ return true;
287
+ }
288
+ else {
289
+ return exists((parameter) => namesForeignType(parameter.Type), functionType.Parameters);
290
+ }
291
+ }
292
+ default:
293
+ return false;
294
+ }
295
+ break;
296
+ }
297
+ };
298
+ let option_7;
299
+ const option_5 = resolve(visited_1, baseInterface);
300
+ option_7 = ((option_5 != null) ? map((glueMember_1) => {
301
+ const matchValue_2 = GlueSubstitution_substituteMember(substitutions, glueMember_1);
302
+ if (matchValue_2.tag === 1) {
303
+ const property_1 = matchValue_2.fields[0];
304
+ return new GlueMember(/* Property */ 1, [new GlueProperty(property_1.Name, property_1.Documentation, qualifySelf(property_1.Type), property_1.IsStatic, property_1.IsOptional, property_1.Accessor, property_1.IsPrivate)]);
305
+ }
306
+ else {
307
+ return matchValue_2;
308
+ }
309
+ }, option_5) : undefined);
310
+ matchValue_3 = ((option_7 != null) ? (forAll((_arg_2) => {
311
+ if (_arg_2.tag === 1) {
312
+ return !namesForeignType(_arg_2.fields[0].Type);
313
+ }
314
+ else {
315
+ return true;
316
+ }
317
+ }, option_7) ? option_7 : undefined) : undefined);
318
+ }
201
319
  break;
202
320
  }
203
321
  default:
204
- matchValue_1 = undefined;
322
+ matchValue_3 = undefined;
205
323
  }
206
- let matchResult_3, acc_1, members_1;
324
+ let matchResult_5, acc_1, members_1;
207
325
  if (acc != null) {
208
- if (matchValue_1 != null) {
209
- matchResult_3 = 0;
326
+ if (matchValue_3 != null) {
327
+ matchResult_5 = 0;
210
328
  acc_1 = acc;
211
- members_1 = matchValue_1;
329
+ members_1 = matchValue_3;
212
330
  }
213
331
  else {
214
- matchResult_3 = 1;
332
+ matchResult_5 = 1;
215
333
  }
216
334
  }
217
335
  else {
218
- matchResult_3 = 1;
336
+ matchResult_5 = 1;
219
337
  }
220
- switch (matchResult_3) {
338
+ switch (matchResult_5) {
221
339
  case 0:
222
340
  return append(acc_1, members_1);
223
341
  default:
224
342
  return undefined;
225
343
  }
226
344
  }, empty(), info_1.HeritageClauses);
227
- if (option_7 != null) {
228
- return (inheritedMembers = option_7, (ownNames = ofList(choose((_arg_2) => {
229
- if (_arg_2.tag === 1) {
230
- return _arg_2.fields[0].Name;
345
+ if (option_9 != null) {
346
+ return (inheritedMembers = option_9, (ownNames = ofList(choose((_arg_3) => {
347
+ if (_arg_3.tag === 1) {
348
+ return _arg_3.fields[0].Name;
231
349
  }
232
350
  else {
233
351
  return undefined;
234
352
  }
235
353
  }, info_1.Members), {
236
354
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
237
- }), append(List_distinctBy((_arg_4) => {
238
- if (_arg_4.tag === 1) {
239
- return new FSharpChoice$2(/* Choice1Of2 */ 0, [_arg_4.fields[0].Name]);
355
+ }), append(List_distinctBy((_arg_5) => {
356
+ if (_arg_5.tag === 1) {
357
+ return new FSharpChoice$2(/* Choice1Of2 */ 0, [_arg_5.fields[0].Name]);
240
358
  }
241
359
  else {
242
- return new FSharpChoice$2(/* Choice2Of2 */ 1, [_arg_4]);
360
+ return new FSharpChoice$2(/* Choice2Of2 */ 1, [_arg_5]);
243
361
  }
244
- }, filter((_arg_3) => {
245
- if (_arg_3.tag === 1) {
246
- return !contains(_arg_3.fields[0].Name, ownNames);
362
+ }, filter((_arg_4) => {
363
+ if (_arg_4.tag === 1) {
364
+ return !contains(_arg_4.fields[0].Name, ownNames);
247
365
  }
248
366
  else {
249
367
  return true;
@@ -263,260 +381,7 @@ export function tryResolveMembers(typeMemory, info) {
263
381
  }), info);
264
382
  }
265
383
 
266
- function constrainedParameterFullNames(glueType) {
267
- const ofSignature = (typeParameters, parameters_1) => collect_1((parameter) => {
268
- let option_3, option_1;
269
- const matchValue = parameter.Type;
270
- if (matchValue.tag === 16) {
271
- return defaultArg((option_3 = ((option_1 = tryFind((typeParameter) => (typeParameter.Name === matchValue.fields[0]), typeParameters), (option_1 != null) ? option_1.Constraint : undefined)), (option_3 != null) ? typeReferenceFullNames(option_3) : undefined), empty());
272
- }
273
- else {
274
- return empty();
275
- }
276
- }, parameters_1);
277
- const ofMember = (glueMember) => {
278
- switch (glueMember.tag) {
279
- case 0: {
280
- const info = glueMember.fields[0];
281
- return ofSignature(info.TypeParameters, info.Parameters);
282
- }
283
- case 6: {
284
- const info_1 = glueMember.fields[0];
285
- return ofSignature(info_1.TypeParameters, info_1.Parameters);
286
- }
287
- case 4: {
288
- const info_2 = glueMember.fields[0];
289
- return ofSignature(info_2.TypeParameters, info_2.Parameters);
290
- }
291
- default:
292
- return empty();
293
- }
294
- };
295
- const collect = (glueType_2_mut) => {
296
- collect:
297
- while (true) {
298
- const glueType_2 = glueType_2_mut;
299
- switch (glueType_2.tag) {
300
- case 6: {
301
- const info_3 = glueType_2.fields[0];
302
- return ofSignature(info_3.TypeParameters, info_3.Parameters);
303
- }
304
- case 12:
305
- return collect_1(ofMember, glueType_2.fields[0].Members);
306
- case 1:
307
- return collect_1(ofMember, glueType_2.fields[0].Members);
308
- case 22:
309
- return collect_1(ofMember, glueType_2.fields[0].Members);
310
- case 5: {
311
- glueType_2_mut = glueType_2.fields[0].Type;
312
- continue collect;
313
- }
314
- case 2: {
315
- glueType_2_mut = glueType_2.fields[0].Type;
316
- continue collect;
317
- }
318
- case 25: {
319
- glueType_2_mut = glueType_2.fields[0];
320
- continue collect;
321
- }
322
- default:
323
- return empty();
324
- }
325
- break;
326
- }
327
- };
328
- return collect(glueType);
329
- }
330
-
331
- function propertyTypeReferences(glueType_mut) {
332
- propertyTypeReferences:
333
- while (true) {
334
- const glueType = glueType_mut;
335
- let matchResult, innerType;
336
- switch (glueType.tag) {
337
- case 13: {
338
- matchResult = 0;
339
- break;
340
- }
341
- case 7: {
342
- matchResult = 1;
343
- break;
344
- }
345
- case 14: {
346
- matchResult = 2;
347
- innerType = glueType.fields[0];
348
- break;
349
- }
350
- case 30: {
351
- matchResult = 2;
352
- innerType = glueType.fields[0];
353
- break;
354
- }
355
- case 23: {
356
- matchResult = 2;
357
- innerType = glueType.fields[0];
358
- break;
359
- }
360
- case 18: {
361
- matchResult = 3;
362
- break;
363
- }
364
- default:
365
- matchResult = 4;
366
- }
367
- switch (matchResult) {
368
- case 0: {
369
- const typeReference = glueType.fields[0];
370
- return cons(typeReference.FullName, collect_1(propertyTypeReferences, typeReference.TypeArguments));
371
- }
372
- case 1:
373
- return collect_1(propertyTypeReferences, glueType.fields[0].fields[0]);
374
- case 2: {
375
- glueType_mut = innerType;
376
- continue propertyTypeReferences;
377
- }
378
- case 3:
379
- return collect_1(propertyTypeReferences, glueType.fields[0]);
380
- default:
381
- return empty();
382
- }
383
- break;
384
- }
385
- }
386
-
387
- export class State extends Record {
388
- constructor(ArgumentReachable) {
389
- super();
390
- this.ArgumentReachable = ArgumentReachable;
391
- }
392
- }
393
-
394
- export function State_$reflection() {
395
- return record_type("Glutinum.Converter.Transformer.ParamObjectCandidate.State", [], State, () => [["ArgumentReachable", class_type("Microsoft.FSharp.Collections.FSharpSet`1", [string_type])]]);
396
- }
397
-
398
- export function create(typeMemory) {
399
- const argumentReachable = new Set([]);
400
- const optionBags = new Map([]);
401
- const enumerator = getEnumerator(typeMemory);
402
- try {
403
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
404
- let info;
405
- const glueType = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
406
- let matchResult, info_1;
407
- if (glueType.tag === 1) {
408
- if ((info = glueType.fields[0], !isEmpty(info.Members) && forAll((_arg) => {
409
- if (_arg.tag === 1) {
410
- return true;
411
- }
412
- else {
413
- return false;
414
- }
415
- }, info.Members))) {
416
- matchResult = 0;
417
- info_1 = glueType.fields[0];
418
- }
419
- else {
420
- matchResult = 1;
421
- }
422
- }
423
- else {
424
- matchResult = 1;
425
- }
426
- switch (matchResult) {
427
- case 0: {
428
- optionBags.set(info_1.FullName, info_1);
429
- break;
430
- }
431
- }
432
- }
433
- }
434
- finally {
435
- disposeSafe(enumerator);
436
- }
437
- const enumerator_1 = getEnumerator(typeMemory);
438
- try {
439
- while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
440
- const glueType_1 = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
441
- const enumerator_2 = getEnumerator(parameters(glueType_1));
442
- try {
443
- while (enumerator_2["System.Collections.IEnumerator.MoveNext"]()) {
444
- const enumerator_3 = getEnumerator(typeReferenceFullNames(enumerator_2["System.Collections.Generic.IEnumerator`1.get_Current"]().Type));
445
- try {
446
- while (enumerator_3["System.Collections.IEnumerator.MoveNext"]()) {
447
- addToSet(enumerator_3["System.Collections.Generic.IEnumerator`1.get_Current"](), argumentReachable);
448
- }
449
- }
450
- finally {
451
- disposeSafe(enumerator_3);
452
- }
453
- }
454
- }
455
- finally {
456
- disposeSafe(enumerator_2);
457
- }
458
- const enumerator_4 = getEnumerator(constrainedParameterFullNames(glueType_1));
459
- try {
460
- while (enumerator_4["System.Collections.IEnumerator.MoveNext"]()) {
461
- addToSet(enumerator_4["System.Collections.Generic.IEnumerator`1.get_Current"](), argumentReachable);
462
- }
463
- }
464
- finally {
465
- disposeSafe(enumerator_4);
466
- }
467
- }
468
- }
469
- finally {
470
- disposeSafe(enumerator_1);
471
- }
472
- let changed = true;
473
- while (changed) {
474
- changed = false;
475
- const enumerator_5 = getEnumerator(ofSeq(argumentReachable));
476
- try {
477
- while (enumerator_5["System.Collections.IEnumerator.MoveNext"]()) {
478
- const fullName_2 = enumerator_5["System.Collections.Generic.IEnumerator`1.get_Current"]();
479
- let matchValue;
480
- let outArg = defaultOf();
481
- matchValue = [tryGetValue(optionBags, fullName_2, new FSharpRef(() => outArg, (v) => {
482
- outArg = v;
483
- })), outArg];
484
- if (matchValue[0]) {
485
- const enumerator_6 = getEnumerator(matchValue[1].Members);
486
- try {
487
- while (enumerator_6["System.Collections.IEnumerator.MoveNext"]()) {
488
- const glueMember = enumerator_6["System.Collections.Generic.IEnumerator`1.get_Current"]();
489
- if (glueMember.tag === 1) {
490
- const enumerator_7 = getEnumerator(propertyTypeReferences(glueMember.fields[0].Type));
491
- try {
492
- while (enumerator_7["System.Collections.IEnumerator.MoveNext"]()) {
493
- if (addToSet(enumerator_7["System.Collections.Generic.IEnumerator`1.get_Current"](), argumentReachable)) {
494
- changed = true;
495
- }
496
- }
497
- }
498
- finally {
499
- disposeSafe(enumerator_7);
500
- }
501
- }
502
- }
503
- }
504
- finally {
505
- disposeSafe(enumerator_6);
506
- }
507
- }
508
- }
509
- }
510
- finally {
511
- disposeSafe(enumerator_5);
512
- }
513
- }
514
- return new State(ofSeq_1(argumentReachable, {
515
- Compare: (x, y) => (comparePrimitives(x, y) | 0),
516
- }));
517
- }
518
-
519
- export function isCandidate(state, typeMemory, info) {
384
+ export function isCandidate(typeMemory, info) {
520
385
  const members = tryResolveMembers(typeMemory, info);
521
386
  let hasOnlyProperties;
522
387
  if (members == null) {
@@ -550,7 +415,7 @@ export function isCandidate(state, typeMemory, info) {
550
415
  }, members_1));
551
416
  }
552
417
  let typeParametersAreInferable;
553
- const mentioned = ofList(collect_1(memberTypeParameterNames, defaultArg(members, info.Members)), {
418
+ const mentioned = ofList(collect(memberTypeParameterNames, defaultArg(members, info.Members)), {
554
419
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
555
420
  });
556
421
  typeParametersAreInferable = forAll((typeParameter) => {
@@ -561,7 +426,6 @@ export function isCandidate(state, typeMemory, info) {
561
426
  return typeParameter.Default != null;
562
427
  }
563
428
  }, info.TypeParameters);
564
- const isUsedAsArgument = FSharpSet__Contains(state.ArgumentReachable, info.FullName);
565
429
  const isDeclaredOnce = length(List_distinct(choose((_arg_2) => {
566
430
  let matchResult, candidate_1;
567
431
  if (_arg_2.tag === 1) {
@@ -586,7 +450,7 @@ export function isCandidate(state, typeMemory, info) {
586
450
  Equals: equals,
587
451
  GetHashCode: (x_1) => (safeHash(x_1) | 0),
588
452
  })) <= 1;
589
- if ((hasOnlyProperties && typeParametersAreInferable) && isUsedAsArgument) {
453
+ if (hasOnlyProperties && typeParametersAreInferable) {
590
454
  return isDeclaredOnce;
591
455
  }
592
456
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glutinum/cli",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "TypeScript definition to F# bindings converter",
5
5
  "type": "module",
6
6
  "main": "index.js",