@glutinum/cli 1.0.0-beta.8 → 1.0.0-beta.9

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.
@@ -1,5 +1,5 @@
1
1
 
2
- import { typeLiteralId, readTypeArguments, entityNameText, getFullNameOrEmpty, defaultTypeArguments, identifierText, resolveAlias, symbolAtLocation, isTupleType, withInProgress, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
2
+ import { typeLiteralId, readTypeArguments, entityNameText, getFullNameOrEmpty, defaultTypeArguments, identifierText, isTupleType, resolveAlias, symbolAtLocation, withInProgress, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
3
3
  import { Report_readerError_Z19516DCE } from "./Report.js";
4
4
  import { item as item_4, contains, filter as filter_1, append, collect, map, ofArray, isEmpty, choose, singleton, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
5
5
  import { GlueReadonly, GlueRecord, GlueUtilityType, GlueInterface, GlueSubstitution_substituteMember, GlueSubstitution_mentionedTypeParameters, GlueTypeLiteral, GluePrimitive, GlueTypeUnion, GlueType, GlueLiteral } from "../GlueAST.js";
@@ -196,7 +196,7 @@ function readMembers(reader, contextNode, typ) {
196
196
  * reference to the (generic) utility.
197
197
  */
198
198
  export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
199
- let matchValue, typeArguments, typNode;
199
+ let matchValue, typeArguments, option_5, option_3, option, binder, checker, option_1, symbol_2, typNode;
200
200
  if (!((matchValue = typeReferenceNode.typeArguments, (matchValue == null) ? false : ((typeArguments = matchValue, ~~typeArguments.length > 0))))) {
201
201
  return undefined;
202
202
  }
@@ -229,6 +229,14 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
229
229
  const matchValue_4 = symbol.flags;
230
230
  isTypeAliasApplication = ($007CHasSymbolFlags$007C_$007C(524288, matchValue_4) != null);
231
231
  }
232
+ const isObjectLiteralAlias = defaultArg((option_5 = ((option_3 = ((option = symbolAtLocation(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeReferenceNode.typeName), (binder = ((checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol_1) => resolveAlias(checker, symbol_1))), (option_1 = option, (option_1 != null) ? binder(option_1) : undefined)))), (option_3 != null) ? ((symbol_2 = option_3, symbol_2.declarations)) : undefined)), (option_5 != null) ? exists((declaration_1) => {
233
+ if (declaration_1.kind === 266) {
234
+ return declaration_1.type.kind === 188;
235
+ }
236
+ else {
237
+ return false;
238
+ }
239
+ }, option_5) : undefined), false);
232
240
  const isInProgress = exists((inProgress) => (inProgress === typ), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
233
241
  let isGenericMapped;
234
242
  const matchValue_5 = typ.flags;
@@ -257,9 +265,9 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
257
265
  }
258
266
  switch (matchResult) {
259
267
  case 0: {
260
- const option_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
261
- if (option_1 != null) {
262
- return (typNode = option_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
268
+ const option_8 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
269
+ if (option_8 != null) {
270
+ return (typNode = option_8, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
263
271
  }
264
272
  else {
265
273
  return undefined;
@@ -268,7 +276,7 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
268
276
  default: {
269
277
  let matchResult_1;
270
278
  if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
271
- if ((!isNamedDeclaration && !isInProgress) && !isGenericMapped) {
279
+ if (((!isNamedDeclaration && !isObjectLiteralAlias) && !isInProgress) && !isGenericMapped) {
272
280
  matchResult_1 = 0;
273
281
  }
274
282
  else {
@@ -470,7 +478,7 @@ function withoutForeignTypeParameters(reader, bound, members) {
470
478
  export function readPartial(reader, typeReferenceNode) {
471
479
  const baseType = baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
472
480
  if (exists((typ) => (typ === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials)) {
473
- const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 366);
481
+ const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 383);
474
482
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
475
483
  void (objectArg.push(item));
476
484
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -523,7 +531,7 @@ export function readPartial(reader, typeReferenceNode) {
523
531
  }
524
532
  default:
525
533
  if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
526
- 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/UtilityType.fs", 408);
534
+ 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/UtilityType.fs", 425);
527
535
  const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
528
536
  void (objectArg_1.push(item_1));
529
537
  members = empty();
@@ -632,7 +640,7 @@ export function readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
632
640
  const tryReadValueOfKeys = (typ) => {
633
641
  const activePatternResult_3 = Type_StringLiteral_$007CString$007COther$007C(typ);
634
642
  if (activePatternResult_3.tag === 1) {
635
- const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 527);
643
+ const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 544);
636
644
  const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
637
645
  void (objectArg_1.push(item));
638
646
  return undefined;
@@ -697,7 +705,7 @@ export function readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
697
705
  const filteredProperties = toList(filter((prop) => (keepListedKeys === contains_1(prop.name, keysToOmit, {
698
706
  Equals: (x, y) => (x === y),
699
707
  GetHashCode: (x) => (stringHash(x) | 0),
700
- })), (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/UtilityType.fs", 562), (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/UtilityType.fs", 562), (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)))))));
708
+ })), (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/UtilityType.fs", 579), (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/UtilityType.fs", 579), (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)))))));
701
709
  const isInProgress = exists((inProgress) => (inProgress === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
702
710
  const members_1 = isInProgress ? empty() : withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions, baseType, () => collect((property) => readPropertyMembers(reader, typeReferenceNode, property), filteredProperties));
703
711
  const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
@@ -789,7 +797,7 @@ export function readReadonly(reader, typeReferenceNode) {
789
797
  }, unionType.types))])])]);
790
798
  }
791
799
  catch (matchValue_1) {
792
- const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 686);
800
+ const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 703);
793
801
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
794
802
  void (objectArg.push(item));
795
803
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -2,11 +2,11 @@
2
2
  import { Record } from "../fable_modules/fable-library-js.5.17.2/Types.js";
3
3
  import { int32_type, bool_type, array_type, list_type, record_type, class_type, string_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
4
4
  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, importDefaultAttribute, TransformContext_$ctor_Z1635F75A, TypeLiteralsMemory__EnterFileModule_Z721C83C5, TransformContext__get__Reporter, TransformContext__set_SiblingTypeNames_2FCB1351, importAttribute, TypeLiteralsMemory__LeaveModule, TypeLiteralsMemory__EnterModule_Z721C83C5, TransformContext__ExposeTypeAlias_1CE4A880, TransformContext__AddWarning_Z721C83C5, sanitizeTypeNameAndPushScope, ImportSource, TransformContext__get_ImportSource, TransformContext__get_TypeMemory, sanitizeMemberNameAndPushScope, 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";
5
- import { GlueReExport, GlueVariable, GlueTypeReference, GlueClassDeclaration, GlueLiteral__ToText, GlueIndexSignature, GlueLiteral, GlueMember__TryGetAccessor, GlueMember__get_Documentation, GluePrimitive, GlueProperty, GlueAccessor, GlueFunctionDeclaration, GlueMethod, GlueMethodSignature, GlueSubstitution_mentionedTypeParameters, GlueFunctionType, GlueParameter, GlueTypeUnion, GlueType, GlueTypeLiteral, GlueMember, GlueTypeParameter, GlueSubstitution_substitute, GlueSubstitution_substituteParameter, GlueInterface, GlueTypeAliasDeclaration_$reflection } from "./GlueAST.js";
5
+ import { GlueReExport, GlueVariable, GlueTypeReference, GlueClassDeclaration, GlueLiteral__ToText, GlueIndexSignature, GlueLiteral, GlueTypeUnion, GlueMember__TryGetAccessor, GlueMember__get_Documentation, GluePrimitive, GlueProperty, GlueAccessor, GlueFunctionDeclaration, GlueMethod, GlueMethodSignature, GlueSubstitution_mentionedTypeParameters, GlueFunctionType, GlueParameter, GlueType, GlueTypeLiteral, GlueMember, GlueTypeParameter, GlueSubstitution_substitute, GlueSubstitution_substituteParameter, GlueInterface, GlueTypeAliasDeclaration_$reflection } from "./GlueAST.js";
6
6
  import { transformComment, TransformCommentResult_$reflection } from "./Transformer/Comment.js";
7
7
  import { SealedTypeInfo, TransformDeclarationTypeParametersResult, TransformTypeParametersResult, TransformResult_Create_403667D8, mapFSharpType, mapFsharpParameter, TransformDeclarationTypeParametersResult_$reflection } from "./Transformer/TypeParameter.js";
8
8
  import { FSharpModule, FSharpSingleErasedCaseUnion, FSharpJSApi, FSharpEnum, FSharpEnumCase, FSharpLiteral, FSharpUnionCaseNamed, FSharpClass, FSharpConstructor, FSharpExplicitField, FSharpMemberInfoBody, FSharpAccessibility, FSharpStaticMemberInfo, FSharpMember, FSharpMemberInfo, FSharpAccessor, FSharpParameter, FSharpThisType, FSharpPrimitive, FSharpTypeAlias, FSharpDelegate, FSharpFunctionType, FSharpTypeReference, FSharpUnion, FSharpUnionCase, FSharpTypeParameter, FSharpMapped, FSharpInterface, FSharpAttribute, FSharpType, FSharpType_$reflection } from "./FsharpAST.js";
9
- import { ofSeq as ofSeq_1, empty as empty_3, add, contains as contains_2, ofList, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.17.2/Set.js";
9
+ import { empty as empty_3, add, contains as contains_2, ofSeq as ofSeq_1, ofList, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.17.2/Set.js";
10
10
  import { aggregatedExports, replaceSelfReference, isUnitAlias, typedArrayNames, transformPrimitive, requiredBeforeParamArray, isDataObject, Interface_makePartial, tryUnwrapOption, iteratorNames } from "./Transformer/Utils.js";
11
11
  import { value as value_7, toArray, defaultArg } from "../fable_modules/fable-library-js.5.17.2/Option.js";
12
12
  import { zip, mapFold, tryPick, item, concat as concat_1, reverse, iterate, cons, foldBack, fold, sortBy, tryFind, ofSeq, forAll, truncate, contains, exists, partition, mapIndexed, filter, append, length, collect, tryLast, choose, tryHead, singleton, empty, ofArray, map, head as head_1, tail as tail_1, isEmpty } from "../fable_modules/fable-library-js.5.17.2/List.js";
@@ -22,12 +22,12 @@ import { capitalizeFirstLetter } from "./Utils/String.js";
22
22
  import { addToSet } from "../fable_modules/fable-library-js.5.17.2/MapUtil.js";
23
23
  import { expandMembers } from "./Transformer/AnyFunctionOverloads.js";
24
24
  import { isMap, keysModule, isMapNamed, expandMembers as expandMembers_1 } from "./Transformer/KeyOfMaps.js";
25
- import { defaultMaxOverloads, expandMembers as expandMembers_2 } from "./Transformer/UnionOverloads.js";
25
+ import { defaultMaxOverloads, isNullish, tryCases, expandMembers as expandMembers_2 } from "./Transformer/UnionOverloads.js";
26
26
  import { applyWith as applyWith_1, disambiguateOverloads, aliasesOf, parametersSignature, Aliases_get_Empty, distinctBySignature } from "./Merge.js";
27
27
  import { min } from "../fable_modules/fable-library-js.5.17.2/Double.js";
28
+ import { contains as contains_1 } from "../fable_modules/fable-library-js.5.17.2/Array.js";
28
29
  import { inheritsIterable, asMethods, tryCallableHeritage } from "./Transformer/CallableProperties.js";
29
30
  import { withoutBaseClassProperties, withoutBasesOfBases, isInheritableType, isSelfHeritage, isArrayHeritage, isErrorHeritage, withoutRedeclaredBases } from "./Transformer/Heritage.js";
30
- import { contains as contains_1 } from "../fable_modules/fable-library-js.5.17.2/Array.js";
31
31
  import { isCandidate, tryResolveMembers } from "./Transformer/ParamObjectCandidate.js";
32
32
  import { op_UnaryNegation_Int32 } from "../fable_modules/fable-library-js.5.17.2/Int32.js";
33
33
  import { transformEnum } from "./Transformer/Enum.js";
@@ -743,10 +743,11 @@ function transformUnionType(context, cases) {
743
743
  const others = patternInput[1];
744
744
  const optionalTypes = patternInput[0];
745
745
  const isOptional = !isEmpty(optionalTypes);
746
- if (isOptional && (length(others) === 1)) {
747
- return new FSharpType(/* Option */ 3, [transformType(context, head_1(others))]);
746
+ const others_1 = (length(others) > 1) ? map(arrayAsInput, others) : others;
747
+ if (isOptional && (length(others_1) === 1)) {
748
+ return new FSharpType(/* Option */ 3, [transformType(context, head_1(others_1))]);
748
749
  }
749
- else if (isEmpty(others)) {
750
+ else if (isEmpty(others_1)) {
750
751
  if (!isEmpty(optionalTypes)) {
751
752
  return transformType(context, head_1(optionalTypes));
752
753
  }
@@ -754,16 +755,16 @@ function transformUnionType(context, cases) {
754
755
  return FSharpType.Object$;
755
756
  }
756
757
  }
757
- else if (length(others) === 1) {
758
- return transformType(context, head_1(others));
758
+ else if (length(others_1) === 1) {
759
+ return transformType(context, head_1(others_1));
759
760
  }
760
761
  else {
761
- const matchValue = tryOptimizeUnionType(context, TransformContext__get_CurrentScopeName(context), others);
762
+ const matchValue = tryOptimizeUnionType(context, TransformContext__get_CurrentScopeName(context), others_1);
762
763
  if (matchValue == null) {
763
- const isLarge = length(others) > 9;
764
- const name_1 = isLarge ? TransformContext__NewTypeName(context) : (`U${length(others)}`);
764
+ const isLarge = length(others_1) > 9;
765
+ const name_1 = isLarge ? TransformContext__NewTypeName(context) : (`U${length(others_1)}`);
765
766
  const caseContext = isLarge ? context : sanitizeNameAndPushScope(name_1, context)[1];
766
- const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(caseContext, `Case${index + 1}`), caseType), others), {
767
+ const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(caseContext, `Case${index + 1}`), caseType), others_1), {
767
768
  Equals: equals,
768
769
  GetHashCode: (x_1) => (safeHash(x_1) | 0),
769
770
  });
@@ -790,7 +791,7 @@ function transformUnionType(context, cases) {
790
791
  case 0:
791
792
  return single;
792
793
  case 1: {
793
- const typeParameterNames_1 = List_distinct(collect(typeParameterNames_2, others), {
794
+ const typeParameterNames_1 = List_distinct(collect(typeParameterNames_2, others_1), {
794
795
  Equals: (x_2, y_2) => (x_2 === y_2),
795
796
  GetHashCode: (x_2) => (stringHash(x_2) | 0),
796
797
  });
@@ -811,12 +812,12 @@ function transformUnionType(context, cases) {
811
812
  }
812
813
  else {
813
814
  const name = TransformContext__NewTypeName(context);
814
- const typeParameterNames = List_distinct(collect(typeParameterNames_2, others), {
815
+ const typeParameterNames = List_distinct(collect(typeParameterNames_2, others_1), {
815
816
  Equals: (x, y) => (x === y),
816
817
  GetHashCode: (x) => (stringHash(x) | 0),
817
818
  });
818
819
  let option_3;
819
- const option_1 = tryOptimizeUnionType(context, name, others);
820
+ const option_1 = tryOptimizeUnionType(context, name, others_1);
820
821
  option_3 = ((option_1 != null) ? ((typ = option_1, (typ.tag === 1) ? ((unionInfo = typ.fields[0], new FSharpType(/* Union */ 1, [new FSharpUnion(unionInfo.Attributes, unionInfo.Name, unionInfo.Cases, unionInfo.IsOptional, declaredTypeParameters_1(typeParameterNames), unionInfo.Constants)]))) : typ)) : undefined);
821
822
  if (option_3 != null) {
822
823
  TransformContext__ExposeType_Z1D58A540(context, option_3);
@@ -1472,78 +1473,7 @@ function transformType(context_mut, glueType_mut) {
1472
1473
 
1473
1474
  function transformParameter(context, parameter) {
1474
1475
  const patternInput = sanitizeNameAndPushScope(parameter.Name, context);
1475
- const asArray = (glueType) => {
1476
- let matchResult, elementType, elementType_1, cases, glueType_1, glueType_2;
1477
- switch (glueType.tag) {
1478
- case 30: {
1479
- if (glueType.fields[0].tag === 14) {
1480
- matchResult = 0;
1481
- elementType = glueType.fields[0].fields[0];
1482
- }
1483
- else {
1484
- matchResult = 4;
1485
- glueType_2 = glueType;
1486
- }
1487
- break;
1488
- }
1489
- case 13: {
1490
- if (glueType.fields[0].Name === "ReadonlyArray") {
1491
- if (!isEmpty(glueType.fields[0].TypeArguments)) {
1492
- if (isEmpty(tail_1(glueType.fields[0].TypeArguments))) {
1493
- if (glueType.fields[0].IsStandardLibrary) {
1494
- matchResult = 1;
1495
- elementType_1 = head_1(glueType.fields[0].TypeArguments);
1496
- }
1497
- else {
1498
- matchResult = 4;
1499
- glueType_2 = glueType;
1500
- }
1501
- }
1502
- else {
1503
- matchResult = 4;
1504
- glueType_2 = glueType;
1505
- }
1506
- }
1507
- else {
1508
- matchResult = 4;
1509
- glueType_2 = glueType;
1510
- }
1511
- }
1512
- else {
1513
- matchResult = 4;
1514
- glueType_2 = glueType;
1515
- }
1516
- break;
1517
- }
1518
- case 7: {
1519
- matchResult = 2;
1520
- cases = glueType.fields[0].fields[0];
1521
- break;
1522
- }
1523
- case 23: {
1524
- matchResult = 3;
1525
- glueType_1 = glueType.fields[0];
1526
- break;
1527
- }
1528
- default: {
1529
- matchResult = 4;
1530
- glueType_2 = glueType;
1531
- }
1532
- }
1533
- switch (matchResult) {
1534
- case 0:
1535
- return new GlueType(/* Array */ 14, [elementType]);
1536
- case 1:
1537
- return new GlueType(/* Array */ 14, [elementType_1]);
1538
- case 2:
1539
- return new GlueType(/* Union */ 7, [new GlueTypeUnion(map(asArray, cases))]);
1540
- case 3:
1541
- return new GlueType(/* OptionalType */ 23, [asArray(glueType_1)]);
1542
- default:
1543
- return glueType_2;
1544
- }
1545
- };
1546
- const parameter_1 = new GlueParameter(parameter.Name, parameter.IsOptional, parameter.IsSpread, asArray(parameter.Type));
1476
+ const parameter_1 = new GlueParameter(parameter.Name, parameter.IsOptional, parameter.IsSpread, arrayAsInput(parameter.Type));
1547
1477
  let typ;
1548
1478
  const computedType = unwrapOptionIfAlreadyOptional(patternInput[1], parameter_1.Type, parameter_1.IsOptional);
1549
1479
  typ = (parameter_1.IsSpread ? ((computedType.tag === 14) ? computedType.fields[0] : ((computedType.tag === 11) ? ((computedType.fields[0].Name === "ResizeArray") ? (!isEmpty(computedType.fields[0].TypeArguments) ? (isEmpty(tail_1(computedType.fields[0].TypeArguments)) ? head_1(computedType.fields[0].TypeArguments) : computedType) : computedType) : computedType) : computedType)) : computedType);
@@ -2460,59 +2390,66 @@ function paramObjectParameters(context, members) {
2460
2390
  });
2461
2391
  }
2462
2392
 
2463
- function tryParameterCombinations(parameters) {
2464
- let signatures, aliases;
2465
- const variants = map((parameter_1) => {
2466
- let matchValue_1;
2467
- const matchValue = parameter_1.Type;
2468
- let matchResult, unionInfo_1;
2469
- if (matchValue.tag === 1) {
2470
- if (length(matchValue.fields[0].Cases) > 1) {
2471
- matchResult = 0;
2472
- unionInfo_1 = matchValue.fields[0];
2473
- }
2474
- else {
2475
- matchResult = 1;
2476
- }
2393
+ function tryErasedUnionCases(parameter) {
2394
+ const matchValue = parameter.Type;
2395
+ let matchResult, unionInfo_1;
2396
+ if (matchValue.tag === 1) {
2397
+ if (length(matchValue.fields[0].Cases) > 1) {
2398
+ matchResult = 0;
2399
+ unionInfo_1 = matchValue.fields[0];
2477
2400
  }
2478
2401
  else {
2479
2402
  matchResult = 1;
2480
2403
  }
2481
- switch (matchResult) {
2482
- case 0: {
2483
- const cases = map((_arg) => {
2484
- if (_arg.tag === 1) {
2485
- return _arg.fields[0];
2486
- }
2487
- else {
2488
- return undefined;
2489
- }
2490
- }, unionInfo_1.Cases);
2491
- matchValue_1 = (forAll((option) => (option != null), cases) ? choose((x) => x, cases) : undefined);
2492
- break;
2404
+ }
2405
+ else {
2406
+ matchResult = 1;
2407
+ }
2408
+ switch (matchResult) {
2409
+ case 0: {
2410
+ const cases = map((_arg) => {
2411
+ if (_arg.tag === 1) {
2412
+ return _arg.fields[0];
2413
+ }
2414
+ else {
2415
+ return undefined;
2416
+ }
2417
+ }, unionInfo_1.Cases);
2418
+ if (forAll((option) => (option != null), cases)) {
2419
+ return choose((x) => x, cases);
2420
+ }
2421
+ else {
2422
+ return undefined;
2493
2423
  }
2494
- default:
2495
- matchValue_1 = undefined;
2496
2424
  }
2497
- if (matchValue_1 == null) {
2498
- return singleton(parameter_1);
2425
+ default:
2426
+ return undefined;
2427
+ }
2428
+ }
2429
+
2430
+ function tryParameterCombinations(maxOverloads, parameters) {
2431
+ let signatures, aliases;
2432
+ const variants = map((parameter) => {
2433
+ const matchValue = tryErasedUnionCases(parameter);
2434
+ if (matchValue == null) {
2435
+ return singleton(parameter);
2499
2436
  }
2500
2437
  else {
2501
- const cases_1 = matchValue_1;
2502
- return toList(delay(() => append_1(parameter_1.IsOptional ? singleton_1(undefined) : empty_1(), delay(() => map_2((case$) => (new FSharpParameter(parameter_1.Attributes, parameter_1.Name, false, case$, parameter_1.OriginalGlueMember)), cases_1)))));
2438
+ const cases = matchValue;
2439
+ return toList(delay(() => append_1(parameter.IsOptional ? singleton_1(undefined) : empty_1(), delay(() => map_2((case$) => (new FSharpParameter(parameter.Attributes, parameter.Name, false, case$, parameter.OriginalGlueMember)), cases)))));
2503
2440
  }
2504
2441
  }, parameters);
2505
- const combinationsCount = fold((count, parameterVariants) => (min(count * length(parameterVariants), 13) | 0), 1, variants) | 0;
2506
- if ((combinationsCount === 1) ? true : (combinationsCount > 12)) {
2442
+ const combinationsCount = fold((count, parameterVariants) => (min(count * length(parameterVariants), maxOverloads + 1) | 0), 1, variants) | 0;
2443
+ if ((combinationsCount === 1) ? true : (combinationsCount > maxOverloads)) {
2507
2444
  return undefined;
2508
2445
  }
2509
2446
  else {
2510
- const combinations = map((arg) => sortBy((_arg_1) => _arg_1.IsOptional, choose((x_1) => x_1, arg), {
2511
- Compare: (x_2, y) => (comparePrimitives(x_2, y) | 0),
2447
+ const combinations = map((arg) => sortBy((_arg) => _arg.IsOptional, choose((x) => x, arg), {
2448
+ Compare: (x_1, y) => (comparePrimitives(x_1, y) | 0),
2512
2449
  }), foldBack((parameterVariants_1, acc) => collect((variant) => map((tail) => cons(variant, tail), acc), parameterVariants_1), variants, singleton(empty())));
2513
2450
  if ((signatures = map((aliases = Aliases_get_Empty(), (parameters_1) => parametersSignature(aliases, parameters_1)), combinations), length(List_distinct(signatures, {
2514
2451
  Equals: equals,
2515
- GetHashCode: (x_3) => (safeHash(x_3) | 0),
2452
+ GetHashCode: (x_2) => (safeHash(x_2) | 0),
2516
2453
  })) !== length(signatures))) {
2517
2454
  return undefined;
2518
2455
  }
@@ -2523,8 +2460,93 @@ function tryParameterCombinations(parameters) {
2523
2460
  }
2524
2461
 
2525
2462
  function paramObjectParameterSets(context, members) {
2463
+ let option_3;
2526
2464
  const parameters = paramObjectParameters(context, members);
2527
- return defaultArg(tryParameterCombinations(parameters), singleton(parameters));
2465
+ const expandable = map((parameter) => {
2466
+ let tupledArg;
2467
+ let aliasCases;
2468
+ const matchValue_1 = parameter.OriginalGlueMember;
2469
+ let matchResult, property;
2470
+ if (parameter.Type.tag === 1) {
2471
+ matchResult = 0;
2472
+ }
2473
+ else if (matchValue_1 != null) {
2474
+ if (matchValue_1.tag === 1) {
2475
+ matchResult = 1;
2476
+ property = matchValue_1.fields[0];
2477
+ }
2478
+ else {
2479
+ matchResult = 2;
2480
+ }
2481
+ }
2482
+ else {
2483
+ matchResult = 2;
2484
+ }
2485
+ switch (matchResult) {
2486
+ case 0: {
2487
+ aliasCases = undefined;
2488
+ break;
2489
+ }
2490
+ case 1: {
2491
+ let propertyType;
2492
+ const matchValue_3 = property.Type;
2493
+ propertyType = ((matchValue_3.tag === 23) ? matchValue_3.fields[0] : matchValue_3);
2494
+ let matchResult_1, fullName_1;
2495
+ if (propertyType.tag === 13) {
2496
+ if (isEmpty(propertyType.fields[0].TypeArguments)) {
2497
+ if (!contains_1(propertyType.fields[0].FullName, TransformContext__get_State(context).UnionAliasesBeingExpanded, {
2498
+ Equals: (x, y) => (x === y),
2499
+ GetHashCode: (x) => (stringHash(x) | 0),
2500
+ })) {
2501
+ matchResult_1 = 0;
2502
+ fullName_1 = propertyType.fields[0].FullName;
2503
+ }
2504
+ else {
2505
+ matchResult_1 = 1;
2506
+ }
2507
+ }
2508
+ else {
2509
+ matchResult_1 = 1;
2510
+ }
2511
+ }
2512
+ else {
2513
+ matchResult_1 = 1;
2514
+ }
2515
+ switch (matchResult_1) {
2516
+ case 0: {
2517
+ const option_1 = tryCases(TransformContext__get_TypeMemory(context), propertyType);
2518
+ aliasCases = ((option_1 != null) ? ((tupledArg = option_1, [fullName_1, tupledArg[0], tupledArg[1]])) : undefined);
2519
+ break;
2520
+ }
2521
+ default:
2522
+ aliasCases = undefined;
2523
+ }
2524
+ break;
2525
+ }
2526
+ default:
2527
+ aliasCases = undefined;
2528
+ }
2529
+ if (aliasCases == null) {
2530
+ return parameter;
2531
+ }
2532
+ else {
2533
+ const nullable_1 = aliasCases[2];
2534
+ const fullName_2 = aliasCases[0];
2535
+ const cases_1 = aliasCases[1];
2536
+ const context_1 = sanitizeNameAndPushScope(parameter.Name, context)[1];
2537
+ void (TransformContext__get_State(context_1).UnionAliasesBeingExpanded.push(fullName_2));
2538
+ try {
2539
+ return new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional ? true : nullable_1, new FSharpType(/* Union */ 1, [new FSharpUnion(empty(), "", map((arg_1) => (new FSharpUnionCase(/* Typed */ 1, [transformType(context_1, arrayAsInput(arg_1))])), cases_1), false, empty(), empty())]), parameter.OriginalGlueMember);
2540
+ }
2541
+ finally {
2542
+ TransformContext__get_State(context_1).UnionAliasesBeingExpanded.splice(TransformContext__get_State(context_1).UnionAliasesBeingExpanded.length - 1, 1);
2543
+ }
2544
+ }
2545
+ }, parameters);
2546
+ const expandedNames = ofSeq_1(map((_arg) => _arg.Name, filter((parameter_1) => (tryErasedUnionCases(parameter_1) != null), expandable)), {
2547
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
2548
+ });
2549
+ return defaultArg((option_3 = tryParameterCombinations(TransformContext__get_State(context).MaxOverloads, expandable), (option_3 != null) ? append(filter((list_4) => exists((parameter_2) => FSharpSet__Contains(expandedNames, parameter_2.Name), list_4), option_3), singleton(parameters)) : undefined), singleton(parameters));
2528
2550
  }
2529
2551
 
2530
2552
  function paramObjectCreateMembers(context, returnType, members) {
@@ -2544,7 +2566,7 @@ function transformParamObjectClass(context, name, documentation, members) {
2544
2566
  }, typeLiteralParameters);
2545
2567
  let patternInput_1;
2546
2568
  const paramObjectConstructor = (parameters) => (new FSharpConstructor(parameters, ofArray([FSharpAttribute.ParamObject, FSharpAttribute.EmitSelf]), FSharpAccessibility.Public));
2547
- const matchValue_1 = tryParameterCombinations(typeLiteralParameters);
2569
+ const matchValue_1 = tryParameterCombinations(TransformContext__get_State(context).MaxOverloads, typeLiteralParameters);
2548
2570
  if (matchValue_1 != null) {
2549
2571
  const patternInput = partition(isEmpty, matchValue_1);
2550
2572
  patternInput_1 = [isEmpty(patternInput[0]) ? (new FSharpConstructor(empty(), empty(), FSharpAccessibility.Private)) : paramObjectConstructor(empty()), map(paramObjectConstructor, patternInput[1])];
@@ -2555,6 +2577,78 @@ function transformParamObjectClass(context, name, documentation, members) {
2555
2577
  return new FSharpClass(toList(delay(() => append_1(xmlDocInfo.ObsoleteAttributes, delay(() => append_1(singleton_1(new FSharpAttribute(/* Global */ 21, [undefined])), delay(() => singleton_1(FSharpAttribute.AllowNullLiteral))))))), xmlDocInfo.XmlDoc, name, declaredTypeParameters_1(typeParameterNames), patternInput_1[0], patternInput_1[1], explicitFields);
2556
2578
  }
2557
2579
 
2580
+ function arrayAsInput(glueType) {
2581
+ let matchResult, elementType, elementType_1, cases, glueType_2, glueType_3;
2582
+ switch (glueType.tag) {
2583
+ case 30: {
2584
+ if (glueType.fields[0].tag === 14) {
2585
+ matchResult = 0;
2586
+ elementType = glueType.fields[0].fields[0];
2587
+ }
2588
+ else {
2589
+ matchResult = 4;
2590
+ glueType_3 = glueType;
2591
+ }
2592
+ break;
2593
+ }
2594
+ case 13: {
2595
+ if (glueType.fields[0].Name === "ReadonlyArray") {
2596
+ if (!isEmpty(glueType.fields[0].TypeArguments)) {
2597
+ if (isEmpty(tail_1(glueType.fields[0].TypeArguments))) {
2598
+ if (glueType.fields[0].IsStandardLibrary) {
2599
+ matchResult = 1;
2600
+ elementType_1 = head_1(glueType.fields[0].TypeArguments);
2601
+ }
2602
+ else {
2603
+ matchResult = 4;
2604
+ glueType_3 = glueType;
2605
+ }
2606
+ }
2607
+ else {
2608
+ matchResult = 4;
2609
+ glueType_3 = glueType;
2610
+ }
2611
+ }
2612
+ else {
2613
+ matchResult = 4;
2614
+ glueType_3 = glueType;
2615
+ }
2616
+ }
2617
+ else {
2618
+ matchResult = 4;
2619
+ glueType_3 = glueType;
2620
+ }
2621
+ break;
2622
+ }
2623
+ case 7: {
2624
+ matchResult = 2;
2625
+ cases = glueType.fields[0].fields[0];
2626
+ break;
2627
+ }
2628
+ case 23: {
2629
+ matchResult = 3;
2630
+ glueType_2 = glueType.fields[0];
2631
+ break;
2632
+ }
2633
+ default: {
2634
+ matchResult = 4;
2635
+ glueType_3 = glueType;
2636
+ }
2637
+ }
2638
+ switch (matchResult) {
2639
+ case 0:
2640
+ return new GlueType(/* Array */ 14, [elementType]);
2641
+ case 1:
2642
+ return new GlueType(/* Array */ 14, [elementType_1]);
2643
+ case 2:
2644
+ return new GlueType(/* Union */ 7, [new GlueTypeUnion(map(arrayAsInput, cases))]);
2645
+ case 3:
2646
+ return new GlueType(/* OptionalType */ 23, [arrayAsInput(glueType_2)]);
2647
+ default:
2648
+ return glueType_3;
2649
+ }
2650
+ }
2651
+
2558
2652
  function transformCallbackReturnType(context, returnType) {
2559
2653
  let matchResult;
2560
2654
  switch (returnType.tag) {
@@ -2578,7 +2672,7 @@ function transformCallbackReturnType(context, returnType) {
2578
2672
  case 0:
2579
2673
  return new FSharpType(/* Primitive */ 8, [FSharpPrimitive.Unit]);
2580
2674
  default:
2581
- return transformType(context, returnType);
2675
+ return transformType(context, arrayAsInput(returnType));
2582
2676
  }
2583
2677
  }
2584
2678
 
@@ -3910,84 +4004,113 @@ function aliasInterfaceOf(scope, typeParameters, members, inheritance) {
3910
4004
  return new FSharpType(/* Interface */ 5, [new FSharpInterface(ofArray([FSharpAttribute.AllowNullLiteral, FSharpAttribute.Interface]), scope.Name, empty(), scope.Declaration.Name, typeParameters, members, inheritance)]);
3911
4005
  }
3912
4006
 
3913
- function aliasOfUnion(scope, cases, unionType) {
3914
- const context = scope.Context;
3915
- const matchValue = tryOptimizeUnionType(context, scope.Name, cases);
3916
- if (matchValue == null) {
3917
- const matchValue_1 = partition((_arg) => {
3918
- let matchResult;
3919
- if (_arg.tag === 3) {
3920
- switch (_arg.fields[0].tag) {
3921
- case 7:
3922
- case 8: {
3923
- matchResult = 0;
3924
- break;
3925
- }
3926
- default:
3927
- matchResult = 1;
3928
- }
4007
+ function isSelfReferencingUnion(name, cases) {
4008
+ if (exists((case$) => !equals(replaceSelfReference(name, case$), case$), cases)) {
4009
+ return !exists((_arg) => {
4010
+ if (_arg.tag === 8) {
4011
+ return true;
3929
4012
  }
3930
4013
  else {
3931
- matchResult = 1;
4014
+ return false;
3932
4015
  }
3933
- switch (matchResult) {
3934
- case 0:
3935
- return true;
4016
+ }, cases);
4017
+ }
4018
+ else {
4019
+ return false;
4020
+ }
4021
+ }
4022
+
4023
+ function aliasOfUnion(scope, cases, unionType) {
4024
+ let unionInfo, typ;
4025
+ const context = scope.Context;
4026
+ const cases_1 = (length(filter((arg) => !isNullish(arg), cases)) > 1) ? map(arrayAsInput, cases) : cases;
4027
+ const isNullable = (_arg) => {
4028
+ let matchResult;
4029
+ if (_arg.tag === 3) {
4030
+ switch (_arg.fields[0].tag) {
4031
+ case 7:
4032
+ case 8: {
4033
+ matchResult = 0;
4034
+ break;
4035
+ }
3936
4036
  default:
3937
- return false;
4037
+ matchResult = 1;
3938
4038
  }
3939
- }, cases);
3940
- let matchResult_1, single, others_3;
3941
- if (!isEmpty(matchValue_1[0])) {
3942
- if (!isEmpty(matchValue_1[1])) {
3943
- if (isEmpty(tail_1(matchValue_1[1]))) {
3944
- matchResult_1 = 0;
3945
- single = head_1(matchValue_1[1]);
4039
+ }
4040
+ else {
4041
+ matchResult = 1;
4042
+ }
4043
+ switch (matchResult) {
4044
+ case 0:
4045
+ return true;
4046
+ default:
4047
+ return false;
4048
+ }
4049
+ };
4050
+ const isSelfReferencing = isSelfReferencingUnion(scope.Declaration.Name, cases_1);
4051
+ const erasedUnionOf = (others) => {
4052
+ const casesContext = TransformContext__PushScope_27AED5E3(context, "Cases");
4053
+ const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(casesContext, `Case${index + 1}`), caseType), others), {
4054
+ Equals: equals,
4055
+ GetHashCode: (x) => (safeHash(x) | 0),
4056
+ });
4057
+ return new FSharpType(/* Union */ 1, [erasedUnion(scope.Name, scope.TypeParameters.Value.TypeParameters, caseTypes)]);
4058
+ };
4059
+ void (TransformContext__get_State(context).UnionAliasesBeingExpanded.push(scope.Declaration.FullName));
4060
+ try {
4061
+ if (isSelfReferencing) {
4062
+ return erasedUnionOf(filter((arg_1) => !isNullable(arg_1), cases_1));
4063
+ }
4064
+ else {
4065
+ const matchValue = tryOptimizeUnionType(context, scope.Name, cases_1);
4066
+ if (matchValue == null) {
4067
+ const matchValue_1 = partition(isNullable, cases_1);
4068
+ let matchResult_1, single, others_4;
4069
+ if (!isEmpty(matchValue_1[0])) {
4070
+ if (!isEmpty(matchValue_1[1])) {
4071
+ if (isEmpty(tail_1(matchValue_1[1]))) {
4072
+ matchResult_1 = 0;
4073
+ single = head_1(matchValue_1[1]);
4074
+ }
4075
+ else if (length(matchValue_1[1]) > 9) {
4076
+ matchResult_1 = 1;
4077
+ others_4 = matchValue_1[1];
4078
+ }
4079
+ else {
4080
+ matchResult_1 = 2;
4081
+ }
4082
+ }
4083
+ else if (length(matchValue_1[1]) > 9) {
4084
+ matchResult_1 = 1;
4085
+ others_4 = matchValue_1[1];
4086
+ }
4087
+ else {
4088
+ matchResult_1 = 2;
4089
+ }
3946
4090
  }
3947
4091
  else if (length(matchValue_1[1]) > 9) {
3948
4092
  matchResult_1 = 1;
3949
- others_3 = matchValue_1[1];
4093
+ others_4 = matchValue_1[1];
3950
4094
  }
3951
4095
  else {
3952
4096
  matchResult_1 = 2;
3953
4097
  }
3954
- }
3955
- else if (length(matchValue_1[1]) > 9) {
3956
- matchResult_1 = 1;
3957
- others_3 = matchValue_1[1];
4098
+ switch (matchResult_1) {
4099
+ case 0:
4100
+ return aliasOf(scope, new FSharpType(/* Option */ 3, [transformType(TransformContext__PushScope_27AED5E3(context, "Value"), single)]));
4101
+ case 1:
4102
+ return erasedUnionOf(others_4);
4103
+ default:
4104
+ return aliasOf(scope, transformType(context, unionType));
4105
+ }
3958
4106
  }
3959
4107
  else {
3960
- matchResult_1 = 2;
3961
- }
3962
- }
3963
- else if (length(matchValue_1[1]) > 9) {
3964
- matchResult_1 = 1;
3965
- others_3 = matchValue_1[1];
3966
- }
3967
- else {
3968
- matchResult_1 = 2;
3969
- }
3970
- switch (matchResult_1) {
3971
- case 0:
3972
- return aliasOf(scope, new FSharpType(/* Option */ 3, [transformType(TransformContext__PushScope_27AED5E3(context, "Value"), single)]));
3973
- case 1: {
3974
- const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(context, `Case${index + 1}`), caseType), others_3), {
3975
- Equals: equals,
3976
- GetHashCode: (x) => (safeHash(x) | 0),
3977
- });
3978
- return new FSharpType(/* Union */ 1, [erasedUnion(scope.Name, scope.TypeParameters.Value.TypeParameters, caseTypes)]);
4108
+ return (matchValue.tag === 1) ? ((unionInfo = matchValue.fields[0], new FSharpType(/* Union */ 1, [new FSharpUnion(unionInfo.Attributes, unionInfo.Name, unionInfo.Cases, unionInfo.IsOptional, scope.TypeParameters.Value.TypeParameters, unionInfo.Constants)]))) : ((typ = matchValue, typ));
3979
4109
  }
3980
- default:
3981
- return aliasOf(scope, transformType(context, unionType));
3982
4110
  }
3983
4111
  }
3984
- else if (matchValue.tag === 1) {
3985
- const unionInfo = matchValue.fields[0];
3986
- return new FSharpType(/* Union */ 1, [new FSharpUnion(unionInfo.Attributes, unionInfo.Name, unionInfo.Cases, unionInfo.IsOptional, scope.TypeParameters.Value.TypeParameters, unionInfo.Constants)]);
3987
- }
3988
- else {
3989
- const typ = matchValue;
3990
- return typ;
4112
+ finally {
4113
+ TransformContext__get_State(context).UnionAliasesBeingExpanded.splice(TransformContext__get_State(context).UnionAliasesBeingExpanded.length - 1, 1);
3991
4114
  }
3992
4115
  }
3993
4116
 
@@ -4193,24 +4316,48 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
4193
4316
  const context_1 = patternInput[1];
4194
4317
  const scope = new AliasScope(typeAliasName, context_1, glueTypeAliasDeclaration, transformComment(glueTypeAliasDeclaration.Documentation), new Lazy(() => transformDeclarationTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters)));
4195
4318
  const aliasInterface = (members, inheritance) => aliasInterfaceOf(scope, scope.TypeParameters.Value.TypeParameters, members, inheritance);
4319
+ let aliasType;
4320
+ const matchValue = glueTypeAliasDeclaration.Type;
4321
+ let matchResult, cases_1, glueType;
4322
+ if (matchValue.tag === 7) {
4323
+ if (isSelfReferencingUnion(glueTypeAliasDeclaration.Name, matchValue.fields[0].fields[0])) {
4324
+ matchResult = 0;
4325
+ cases_1 = matchValue.fields[0].fields[0];
4326
+ }
4327
+ else {
4328
+ matchResult = 1;
4329
+ glueType = matchValue;
4330
+ }
4331
+ }
4332
+ else {
4333
+ matchResult = 1;
4334
+ glueType = matchValue;
4335
+ }
4336
+ switch (matchResult) {
4337
+ case 0: {
4338
+ aliasType = glueTypeAliasDeclaration.Type;
4339
+ break;
4340
+ }
4341
+ default:
4342
+ aliasType = replaceSelfReference(glueTypeAliasDeclaration.Name, glueType);
4343
+ }
4196
4344
  let fsharpType;
4197
- const matchValue = replaceSelfReference(glueTypeAliasDeclaration.Name, glueTypeAliasDeclaration.Type);
4198
- switch (matchValue.tag) {
4345
+ switch (aliasType.tag) {
4199
4346
  case 9: {
4200
- const matchValue_1 = TypeAliasDeclaration_transformKeyOf(context_1, glueTypeAliasDeclaration.Name, matchValue.fields[0]);
4347
+ const matchValue_1 = TypeAliasDeclaration_transformKeyOf(context_1, glueTypeAliasDeclaration.Name, aliasType.fields[0]);
4201
4348
  fsharpType = ((matchValue_1.tag === 10) ? aliasOf(scope, FSharpType.Object$) : matchValue_1);
4202
4349
  break;
4203
4350
  }
4204
4351
  case 10: {
4205
- fsharpType = aliasOfIndexedAccessType(scope, matchValue.fields[0]);
4352
+ fsharpType = aliasOfIndexedAccessType(scope, aliasType.fields[0]);
4206
4353
  break;
4207
4354
  }
4208
4355
  case 8: {
4209
- fsharpType = TypeAliasDeclaration_transformLiteral(scope.XmlDoc, typeAliasName, matchValue.fields[0]);
4356
+ fsharpType = TypeAliasDeclaration_transformLiteral(scope.XmlDoc, typeAliasName, aliasType.fields[0]);
4210
4357
  break;
4211
4358
  }
4212
4359
  case 3: {
4213
- fsharpType = aliasOf(scope, new FSharpType(/* Primitive */ 8, [transformPrimitive(matchValue.fields[0])]));
4360
+ fsharpType = aliasOf(scope, new FSharpType(/* Primitive */ 8, [transformPrimitive(aliasType.fields[0])]));
4214
4361
  break;
4215
4362
  }
4216
4363
  case 26: {
@@ -4218,36 +4365,36 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
4218
4365
  break;
4219
4366
  }
4220
4367
  case 13: {
4221
- fsharpType = aliasOfTypeReference(scope, matchValue.fields[0]);
4368
+ fsharpType = aliasOfTypeReference(scope, aliasType.fields[0]);
4222
4369
  break;
4223
4370
  }
4224
4371
  case 14: {
4225
- fsharpType = aliasOf(scope, transformType(context_1, new GlueType(/* Array */ 14, [matchValue.fields[0]])));
4372
+ fsharpType = aliasOf(scope, transformType(context_1, new GlueType(/* Array */ 14, [aliasType.fields[0]])));
4226
4373
  break;
4227
4374
  }
4228
4375
  case 27: {
4229
- fsharpType = aliasOfUtilityType(scope, matchValue.fields[0]);
4376
+ fsharpType = aliasOfUtilityType(scope, aliasType.fields[0]);
4230
4377
  break;
4231
4378
  }
4232
4379
  case 15: {
4233
- fsharpType = aliasOfFunctionType(scope, matchValue.fields[0]);
4380
+ fsharpType = aliasOfFunctionType(scope, aliasType.fields[0]);
4234
4381
  break;
4235
4382
  }
4236
4383
  case 18: {
4237
- fsharpType = aliasOf(scope, transformTupleType(TransformContext__PushScope_27AED5E3(context_1, "Item"), matchValue.fields[0]));
4384
+ fsharpType = aliasOf(scope, transformTupleType(TransformContext__PushScope_27AED5E3(context_1, "Item"), aliasType.fields[0]));
4238
4385
  break;
4239
4386
  }
4240
4387
  case 20: {
4241
- fsharpType = aliasInterface(TransformMembers_toFSharpMember(context_1, matchValue.fields[0]), empty());
4388
+ fsharpType = aliasInterface(TransformMembers_toFSharpMember(context_1, aliasType.fields[0]), empty());
4242
4389
  break;
4243
4390
  }
4244
4391
  case 21: {
4245
- const matchValue_2 = inheritableBases(context_1, matchValue.fields[0]);
4246
- fsharpType = (isEmpty(matchValue_2) ? aliasOf(scope, FSharpType.Object$) : aliasInterface(TransformMembers_toFSharpMember(context_1, matchValue.fields[1]), map((glueType_3) => transformType(context_1, glueType_3), matchValue_2)));
4392
+ const matchValue_2 = inheritableBases(context_1, aliasType.fields[0]);
4393
+ fsharpType = (isEmpty(matchValue_2) ? aliasOf(scope, FSharpType.Object$) : aliasInterface(TransformMembers_toFSharpMember(context_1, aliasType.fields[1]), map((glueType_4) => transformType(context_1, glueType_4), matchValue_2)));
4247
4394
  break;
4248
4395
  }
4249
4396
  case 22: {
4250
- fsharpType = aliasOfTypeLiteral(scope, matchValue.fields[0]);
4397
+ fsharpType = aliasOfTypeLiteral(scope, aliasType.fields[0]);
4251
4398
  break;
4252
4399
  }
4253
4400
  case 24: {
@@ -4255,19 +4402,19 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
4255
4402
  break;
4256
4403
  }
4257
4404
  case 16: {
4258
- fsharpType = aliasOf(scope, new FSharpType(/* TypeParameter */ 13, [matchValue.fields[0]]));
4405
+ fsharpType = aliasOf(scope, new FSharpType(/* TypeParameter */ 13, [aliasType.fields[0]]));
4259
4406
  break;
4260
4407
  }
4261
4408
  case 28: {
4262
- fsharpType = aliasInterface(TransformMembers_toFSharpMember(context_1, transformMappedTypeMembers(context_1, matchValue.fields[0])), empty());
4409
+ fsharpType = aliasInterface(TransformMembers_toFSharpMember(context_1, transformMappedTypeMembers(context_1, aliasType.fields[0])), empty());
4263
4410
  break;
4264
4411
  }
4265
4412
  case 29: {
4266
- fsharpType = aliasOfConstructorType(scope, matchValue.fields[0]);
4413
+ fsharpType = aliasOfConstructorType(scope, aliasType.fields[0]);
4267
4414
  break;
4268
4415
  }
4269
4416
  case 30: {
4270
- fsharpType = aliasOf(scope, transformReadOnlyModifier(TransformContext__PushScope_27AED5E3(context_1, "Item"), matchValue.fields[0]));
4417
+ fsharpType = aliasOf(scope, transformReadOnlyModifier(TransformContext__PushScope_27AED5E3(context_1, "Item"), aliasType.fields[0]));
4271
4418
  break;
4272
4419
  }
4273
4420
  case 12:
@@ -4289,7 +4436,7 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
4289
4436
  break;
4290
4437
  }
4291
4438
  default:
4292
- fsharpType = aliasOfUnion(scope, matchValue.fields[0].fields[0], matchValue);
4439
+ fsharpType = aliasOfUnion(scope, aliasType.fields[0].fields[0], aliasType);
4293
4440
  }
4294
4441
  if (scope.TypeParameters.IsValueCreated) {
4295
4442
  const typeParameters = scope.TypeParameters.Value.TypeParameters;
@@ -164,21 +164,22 @@ export function typeName(typ) {
164
164
  * The indexes of the run over the type memory, and the declarations being expanded
165
165
  */
166
166
  export class TransformState extends Record {
167
- constructor(Conditionals, KeyOfMaps, PartialHeritageBeingExpanded, MaxOverloads) {
167
+ constructor(Conditionals, KeyOfMaps, PartialHeritageBeingExpanded, UnionAliasesBeingExpanded, MaxOverloads) {
168
168
  super();
169
169
  this.Conditionals = Conditionals;
170
170
  this.KeyOfMaps = KeyOfMaps;
171
171
  this.PartialHeritageBeingExpanded = PartialHeritageBeingExpanded;
172
+ this.UnionAliasesBeingExpanded = UnionAliasesBeingExpanded;
172
173
  this.MaxOverloads = (MaxOverloads | 0);
173
174
  }
174
175
  }
175
176
 
176
177
  export function TransformState_$reflection() {
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]]);
178
+ return record_type("Glutinum.Converter.Transformer.Context.TransformState", [], TransformState, () => [["Conditionals", State_$reflection()], ["KeyOfMaps", State_$reflection_1()], ["PartialHeritageBeingExpanded", array_type(string_type)], ["UnionAliasesBeingExpanded", array_type(string_type)], ["MaxOverloads", int32_type]]);
178
179
  }
179
180
 
180
181
  export function TransformState_Create_Z68CEF8E2(typeMemory, maxOverloads) {
181
- return new TransformState(create(typeMemory), create_1(typeMemory), [], maxOverloads);
182
+ return new TransformState(create(typeMemory), create_1(typeMemory), [], [], maxOverloads);
182
183
  }
183
184
 
184
185
  /**
@@ -9,7 +9,7 @@ import { map as map_1, empty as empty_1, singleton as singleton_1, append as app
9
9
 
10
10
  export const defaultMaxOverloads = 16;
11
11
 
12
- function isNullish(glueType) {
12
+ export function isNullish(glueType) {
13
13
  let matchResult;
14
14
  if (glueType.tag === 3) {
15
15
  switch (glueType.fields[0].tag) {
@@ -33,7 +33,10 @@ function isNullish(glueType) {
33
33
  }
34
34
  }
35
35
 
36
- function tryCases(typeMemory_mut, glueType_mut) {
36
+ /**
37
+ * The cases of a union generated as `U2..U9`, with whether `null` or `undefined` is one of them
38
+ */
39
+ export function tryCases(typeMemory_mut, glueType_mut) {
37
40
  tryCases:
38
41
  while (true) {
39
42
  const typeMemory = typeMemory_mut, glueType = glueType_mut;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glutinum/cli",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.0-beta.9",
4
4
  "description": "TypeScript definition to F# bindings converter",
5
5
  "type": "module",
6
6
  "main": "index.js",