@glutinum/cli 1.0.0-beta.14 → 1.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/Glutinum.Converter/GlueAST.js +19 -14
  2. package/dist/Glutinum.Converter/Merge.js +490 -206
  3. package/dist/Glutinum.Converter/Packages.js +2 -2
  4. package/dist/Glutinum.Converter/Printer.js +26 -21
  5. package/dist/Glutinum.Converter/Read.js +377 -169
  6. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +25 -8
  7. package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +2 -2
  8. package/dist/Glutinum.Converter/Reader/Declaration.js +15 -15
  9. package/dist/Glutinum.Converter/Reader/Deferred.js +114 -43
  10. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +98 -44
  11. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +2 -2
  12. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +61 -46
  13. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +31 -26
  14. package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +38 -25
  15. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +6 -5
  16. package/dist/Glutinum.Converter/Reader/Node.js +1 -1
  17. package/dist/Glutinum.Converter/Reader/TypeNode.js +292 -30
  18. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +1 -1
  19. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +143 -35
  20. package/dist/Glutinum.Converter/Reader/UtilityType.js +179 -34
  21. package/dist/Glutinum.Converter/Reader/Utils.js +186 -17
  22. package/dist/Glutinum.Converter/Reader/VariableStatement.js +46 -16
  23. package/dist/Glutinum.Converter/Transform.js +1073 -638
  24. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +2 -2
  25. package/dist/Glutinum.Converter/Transformer/Conditionals.js +17 -16
  26. package/dist/Glutinum.Converter/Transformer/Context.js +12 -4
  27. package/dist/Glutinum.Converter/Transformer/Exports.js +242 -66
  28. package/dist/Glutinum.Converter/Transformer/Heritage.js +449 -17
  29. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +4 -4
  30. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +105 -19
  31. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +2 -2
  32. package/dist/Glutinum.Converter/Transformer/Utils.js +3 -3
  33. package/dist/Glutinum.Converter/Utils/Naming.js +10 -3
  34. package/package.json +1 -1
@@ -1,17 +1,17 @@
1
1
 
2
2
  import { Record } from "../fable_modules/fable-library-js.5.21.0/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.21.0/Reflection.js";
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, 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";
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, sanitizeMemberNameAndPushScope, TransformContext__AddError_Z721C83C5, TypeLiteralsMemory__get_RootModuleName, TypeLiteralsMemory__Remember_74C8CBB, TransformContext__get_TypeMemory, 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, GlueClassDeclaration, GlueLiteral__ToText, GlueIndexSignature, GlueLiteral, GlueThisType, GlueMember__TryGetAccessor, GlueMember__get_Documentation, GlueTypeUnion, GluePrimitive, GlueAccessor, GlueFunctionDeclaration, GlueSubstitution_mentionedTypeParameters, GlueSubstitution_substitute, GlueFunctionType, GlueParameter, GlueTypeLiteral, GlueGetAccessor, GlueProperty, GlueMethod, GlueConstructor, GlueMember, GlueMethodSignature, GlueTypeReference, GlueType, GlueTypeParameter, 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
- 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";
8
+ import { FSharpModule, FSharpSingleErasedCaseUnion, FSharpJSApi, FSharpEnum, FSharpEnumCase, FSharpLiteral, FSharpUnionCaseNamed, FSharpClass, FSharpConstructor, FSharpExplicitField, FSharpMemberInfoBody, FSharpAccessibility, FSharpStaticMemberInfo, FSharpAccessor, FSharpParameter, FSharpThisType, FSharpPrimitive, FSharpMember, FSharpMemberInfo, FSharpTypeAlias, FSharpDelegate, FSharpFunctionType, FSharpTypeReference, FSharpUnion, FSharpUnionCase, FSharpTypeParameter, FSharpMapped, FSharpInterface, FSharpAttribute, FSharpType, FSharpType_$reflection } from "./FsharpAST.js";
9
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.21.0/Set.js";
10
10
  import { aggregatedExports, replaceSelfReference, isUnitAlias, typedArrayNames, transformPrimitive, requiredBeforeParamArray, isDataObject, Interface_makePartial, tryUnwrapOption, iteratorNames } from "./Transformer/Utils.js";
11
- import { toArray, value as value_7, defaultArg } from "../fable_modules/fable-library-js.5.21.0/Option.js";
12
- import { zip, mapFold, tryPick, item, concat as concat_1, reverse, iterate, cons, foldBack, fold, sortBy, tryFind, ofSeq, truncate, contains, exists, partition, mapIndexed, forAll, map2, 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.21.0/List.js";
11
+ import { toArray, value as value_8, defaultArg } from "../fable_modules/fable-library-js.5.21.0/Option.js";
12
+ import { zip, mapFold, item as item_1, concat as concat_1, reverse, iterate, foldBack, fold, sortBy, tryFind, ofSeq, truncate, cons, contains, exists, partition, tryPick, mapIndexed, forAll, map2, 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.21.0/List.js";
13
13
  import { aliasArities, membersNameUndeclaredTypeParameters, mentionsTypeParameter, ownTypeParameterDefaults, typeParameterNames as typeParameterNames_2, unconstrained, memberTypeParameterNames, typeArguments, declaredTypeParameters as declaredTypeParameters_1 } from "./Transformer/TypeParameters.js";
14
- import { List_groupBy, List_distinct } from "../fable_modules/fable-library-js.5.21.0/Seq2.js";
14
+ import { List_groupBy, List_distinctBy, List_distinct } from "../fable_modules/fable-library-js.5.21.0/Seq2.js";
15
15
  import { uncurry2, curry2, Lazy, Exception, numberHash, int32ToString, comparePrimitives, safeHash, structuralHash, equals, stringHash } from "../fable_modules/fable-library-js.5.21.0/Util.js";
16
16
  import { replace, interpolate, substring, trimStart, split, trim, concat } from "../fable_modules/fable-library-js.5.21.0/String.js";
17
17
  import { resolveMembers, isConditionalAlias, isInterfaceDeclaration } from "./Transformer/Conditionals.js";
@@ -25,10 +25,10 @@ import { expandMembers } from "./Transformer/AnyFunctionOverloads.js";
25
25
  import { isMap, keysModule, isMapNamed, expandMembers as expandMembers_1 } from "./Transformer/KeyOfMaps.js";
26
26
  import { defaultMaxOverloads, isNullish, tryCases, expandMembers as expandMembers_2 } from "./Transformer/UnionOverloads.js";
27
27
  import { applyWith as applyWith_1, disambiguateOverloads, aliasesOf, parametersSignature, Aliases_get_Empty, distinctBySignature } from "./Merge.js";
28
- import { min } from "../fable_modules/fable-library-js.5.21.0/Double.js";
28
+ import { isCandidate, tryResolveMembers, methodAsProperty } from "./Transformer/ParamObjectCandidate.js";
29
+ import { max, min } from "../fable_modules/fable-library-js.5.21.0/Double.js";
29
30
  import { inheritsIterable, asMethods, tryCallableHeritage } from "./Transformer/CallableProperties.js";
30
- import { withoutBaseClassProperties, withoutBasesOfBases, isInheritableType, isSelfHeritage, isArrayHeritage, isErrorHeritage, withoutRedeclaredBases } from "./Transformer/Heritage.js";
31
- import { isCandidate, tryResolveMembers } from "./Transformer/ParamObjectCandidate.js";
31
+ import { withoutBaseClassProperties, tryAllProperties, withoutBasesOfBases, isInheritableType, isSelfHeritage, isArrayHeritage, isErrorHeritage, thisMembersOfBases, withoutConflictingInstantiations, withoutRedeclaredBases } from "./Transformer/Heritage.js";
32
32
  import { op_UnaryNegation_Int32 } from "../fable_modules/fable-library-js.5.21.0/Int32.js";
33
33
  import { transformEnum } from "./Transformer/Enum.js";
34
34
  import { Transforms, transformExports } from "./Transformer/Exports.js";
@@ -933,7 +933,7 @@ function erasedUnion(name, typeParameters, caseTypes) {
933
933
  else {
934
934
  return false;
935
935
  }
936
- }, names)) ? map(value_7, names) : mapIndexed((index, _arg) => (`Case${index + 1}`), caseTypes), caseTypes), false, typeParameters, empty(), empty());
936
+ }, names)) ? map(value_8, names) : mapIndexed((index, _arg) => (`Case${index + 1}`), caseTypes), caseTypes), false, typeParameters, empty(), empty());
937
937
  }
938
938
 
939
939
  function referenceToExposed(context, name, typeParameterNames) {
@@ -941,6 +941,74 @@ function referenceToExposed(context, name, typeParameterNames) {
941
941
  return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(fullName, fullName, empty(), map((Item) => (new FSharpType(/* TypeParameter */ 13, [Item])), typeParameterNames), FSharpType.Discard)]);
942
942
  }
943
943
 
944
+ function withoutAliasesOfSamePrimitive(context, cases) {
945
+ const primitiveOfAlias = (depth, glueType) => {
946
+ let reference;
947
+ let matchResult, reference_1;
948
+ switch (glueType.tag) {
949
+ case 3: {
950
+ matchResult = 0;
951
+ break;
952
+ }
953
+ case 13: {
954
+ if ((reference = glueType.fields[0], ((depth < 5) && isEmpty(reference.TypeArguments)) && (reference.FullName !== ""))) {
955
+ matchResult = 1;
956
+ reference_1 = glueType.fields[0];
957
+ }
958
+ else {
959
+ matchResult = 2;
960
+ }
961
+ break;
962
+ }
963
+ default:
964
+ matchResult = 2;
965
+ }
966
+ switch (matchResult) {
967
+ case 0:
968
+ return glueType;
969
+ case 1:
970
+ return tryPick((_arg) => {
971
+ let matchResult_1, aliased_1, fullName_1;
972
+ if (_arg.tag === 5) {
973
+ if (isEmpty(_arg.fields[0].TypeParameters)) {
974
+ if (_arg.fields[0].FullName === reference_1.FullName) {
975
+ matchResult_1 = 0;
976
+ aliased_1 = _arg.fields[0].Type;
977
+ fullName_1 = _arg.fields[0].FullName;
978
+ }
979
+ else {
980
+ matchResult_1 = 1;
981
+ }
982
+ }
983
+ else {
984
+ matchResult_1 = 1;
985
+ }
986
+ }
987
+ else {
988
+ matchResult_1 = 1;
989
+ }
990
+ switch (matchResult_1) {
991
+ case 0:
992
+ return primitiveOfAlias(depth + 1, aliased_1);
993
+ default:
994
+ return undefined;
995
+ }
996
+ }, TransformContext__get_TypeMemory(context));
997
+ default:
998
+ return undefined;
999
+ }
1000
+ };
1001
+ if (length(cases) > 1) {
1002
+ return List_distinctBy((case$) => defaultArg(primitiveOfAlias(0, case$), case$), cases, {
1003
+ Equals: equals,
1004
+ GetHashCode: (x) => (safeHash(x) | 0),
1005
+ });
1006
+ }
1007
+ else {
1008
+ return cases;
1009
+ }
1010
+ }
1011
+
944
1012
  function transformUnionType(context, cases) {
945
1013
  let typ, unionInfo;
946
1014
  const patternInput = partition((glueType) => {
@@ -961,11 +1029,11 @@ function transformUnionType(context, cases) {
961
1029
  const others = patternInput[1];
962
1030
  const optionalTypes = patternInput[0];
963
1031
  const isOptional = !isEmpty(optionalTypes);
964
- const others_1 = (length(others) > 1) ? map(arrayAsInput, others) : others;
965
- if (isOptional && (length(others_1) === 1)) {
966
- return new FSharpType(/* Option */ 3, [transformType(context, head_1(others_1))]);
1032
+ const others_2 = withoutAliasesOfSamePrimitive(context, (length(others) > 1) ? map(arrayAsInput, others) : others);
1033
+ if (isOptional && (length(others_2) === 1)) {
1034
+ return new FSharpType(/* Option */ 3, [transformType(context, head_1(others_2))]);
967
1035
  }
968
- else if (isEmpty(others_1)) {
1036
+ else if (isEmpty(others_2)) {
969
1037
  if (!isEmpty(optionalTypes)) {
970
1038
  return transformType(context, head_1(optionalTypes));
971
1039
  }
@@ -973,16 +1041,16 @@ function transformUnionType(context, cases) {
973
1041
  return FSharpType.Object$;
974
1042
  }
975
1043
  }
976
- else if (length(others_1) === 1) {
977
- return transformType(context, head_1(others_1));
1044
+ else if (length(others_2) === 1) {
1045
+ return transformType(context, head_1(others_2));
978
1046
  }
979
1047
  else {
980
- const matchValue = tryOptimizeUnionType(context, TransformContext__get_CurrentScopeName(context), others_1);
1048
+ const matchValue = tryOptimizeUnionType(context, TransformContext__get_CurrentScopeName(context), others_2);
981
1049
  if (matchValue == null) {
982
- const isLarge = length(others_1) > 9;
983
- const name_1 = isLarge ? TransformContext__NewTypeName(context) : (`U${length(others_1)}`);
1050
+ const isLarge = length(others_2) > 9;
1051
+ const name_1 = isLarge ? TransformContext__NewTypeName(context) : (`U${length(others_2)}`);
984
1052
  const caseContext = isLarge ? context : sanitizeNameAndPushScope(name_1, context)[1];
985
- const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(caseContext, `Case${index + 1}`), caseType), others_1), {
1053
+ const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(caseContext, `Case${index + 1}`), caseType), others_2), {
986
1054
  Equals: equals,
987
1055
  GetHashCode: (x_1) => (safeHash(x_1) | 0),
988
1056
  });
@@ -1009,7 +1077,7 @@ function transformUnionType(context, cases) {
1009
1077
  case 0:
1010
1078
  return single;
1011
1079
  case 1: {
1012
- const typeParameterNames_1 = List_distinct(collect(typeParameterNames_2, others_1), {
1080
+ const typeParameterNames_1 = List_distinct(collect(typeParameterNames_2, others_2), {
1013
1081
  Equals: (x_2, y_2) => (x_2 === y_2),
1014
1082
  GetHashCode: (x_2) => (stringHash(x_2) | 0),
1015
1083
  });
@@ -1030,12 +1098,12 @@ function transformUnionType(context, cases) {
1030
1098
  }
1031
1099
  else {
1032
1100
  const name = TransformContext__NewTypeName(context);
1033
- const typeParameterNames = List_distinct(collect(typeParameterNames_2, others_1), {
1101
+ const typeParameterNames = List_distinct(collect(typeParameterNames_2, others_2), {
1034
1102
  Equals: (x, y) => (x === y),
1035
1103
  GetHashCode: (x) => (stringHash(x) | 0),
1036
1104
  });
1037
1105
  let option_3;
1038
- const option_1 = tryOptimizeUnionType(context, name, others_1);
1106
+ const option_1 = tryOptimizeUnionType(context, name, others_2);
1039
1107
  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, unionInfo.Conversions)]))) : typ)) : undefined);
1040
1108
  if (option_3 != null) {
1041
1109
  TransformContext__ExposeType_Z1D58A540(context, option_3);
@@ -1091,7 +1159,7 @@ function transformFunctionType(context, functionTypeInfo) {
1091
1159
  switch (matchResult) {
1092
1160
  case 0: {
1093
1161
  const ownDefaults = ownTypeParameterDefaults(functionTypeInfo);
1094
- return new FSharpType(/* Function */ 16, [new FSharpFunctionType(requiredBeforeParamArray(map((parameter_2) => transformParameter(context, parameter_2), map((parameter_1) => GlueSubstitution_substituteParameter(ownDefaults, parameter_1), paremeters))), transformCallbackReturnType(context, GlueSubstitution_substitute(ownDefaults, functionTypeInfo.Type)))]);
1162
+ return new FSharpType(/* Function */ 16, [new FSharpFunctionType(requiredBeforeParamArray(map((parameter_2) => transformParameter(context, parameter_2), map((parameter_1) => GlueSubstitution_substituteParameter(ownDefaults, parameter_1), paremeters))), transformOwnCallbackReturnType(context, ownDefaults, functionTypeInfo.Type))]);
1095
1163
  }
1096
1164
  default: {
1097
1165
  let typParameters;
@@ -1159,7 +1227,7 @@ function transformTypeLiteral(context, typeLiteralInfo) {
1159
1227
  TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Class */ 17, [transformParamObjectClass(context, name, empty(), typeLiteralInfo.Members)]));
1160
1228
  }
1161
1229
  else {
1162
- const creates = isParamObjectCandidate ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(name, typeArguments(typeParameterNames))]), typeLiteralInfo.Members) : empty();
1230
+ const creates = isParamObjectCandidate ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(name, typeArguments(typeParameterNames))]), typeLiteralInfo.Members) : dictionaryCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(name, typeArguments(typeParameterNames))]), typeLiteralInfo.Members);
1163
1231
  const inheritance = ofArray(toArray(TypeLiteral_tryFindIterableType(context, typeLiteralInfo.Members)));
1164
1232
  TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Interface */ 5, [(bind$0040 = anonymousInterface(context, name, typeParameterNames, append(transformedMembers, creates), inheritance), new FSharpInterface(bind$0040.Attributes, bind$0040.Name, bind$0040.XmlDoc, "", bind$0040.TypeParameters, bind$0040.Members, bind$0040.Inheritance))]));
1165
1233
  }
@@ -1177,7 +1245,12 @@ function transformTypeLiteral(context, typeLiteralInfo) {
1177
1245
  function transformIntersectionOfReferences(context, references, members) {
1178
1246
  const bases = inheritableBases(context, references);
1179
1247
  if (isEmpty(bases)) {
1180
- return FSharpType.Object$;
1248
+ if (isEmpty(references)) {
1249
+ return FSharpType.Object$;
1250
+ }
1251
+ else {
1252
+ return transformType(context, head_1(references));
1253
+ }
1181
1254
  }
1182
1255
  else {
1183
1256
  const typeParameterNames = List_distinct(collect(typeParameterNames_2, references), {
@@ -1223,125 +1296,209 @@ function transformMappedType(context, mappedType) {
1223
1296
  }
1224
1297
  }
1225
1298
 
1299
+ function transformClassConstructor(context, reference) {
1300
+ if (exists((_arg) => {
1301
+ if (_arg.tag === 12) {
1302
+ return _arg.fields[0].FullName === reference.FullName;
1303
+ }
1304
+ else {
1305
+ return false;
1306
+ }
1307
+ }, TransformContext__get_TypeMemory(context))) {
1308
+ const className = mapTypeNameToFableCoreAwareName(context, reference);
1309
+ return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference((equals(TypeLiteralsMemory__get_RootModuleName(TransformContext__get_TypeLiteralsMemory(context)), sanitizeTypeName(className)) ? (className + "_") : className) + ".Constructor", reference.FullName + ".Constructor", reference.ModulePath, empty(), FSharpType.Discard)]);
1310
+ }
1311
+ else {
1312
+ return FSharpType.Object$;
1313
+ }
1314
+ }
1315
+
1316
+ function exposeClassConstructor(classContext, info) {
1317
+ let bind$0040;
1318
+ const context = TransformContext__PushScope_27AED5E3(classContext, "Constructor");
1319
+ const instanceType = new GlueType(/* TypeReference */ 13, [new GlueTypeReference(info.Name, info.FullName, empty(), map((typeParameter) => (new GlueType(/* TypeParameter */ 16, [typeParameter.Name])), info.TypeParameters), false)]);
1320
+ TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Interface */ 5, [(bind$0040 = anonymousInterface(context, "Constructor", empty(), append(map((_arg) => {
1321
+ if (_arg.tag === 0) {
1322
+ const method = _arg.fields[0];
1323
+ return new FSharpMember(/* Method */ 0, [new FSharpMemberInfo(cons(FSharpAttribute.EmitConstructor, method.Attributes), method.Name, method.OriginalName, method.TypeParameters, method.Parameters, method.Type, method.IsOptional, method.IsStatic, method.Accessor, method.Accessibility, method.XmlDoc, method.Body)]);
1324
+ }
1325
+ else {
1326
+ return _arg;
1327
+ }
1328
+ }, TransformMembers_toFSharpMember(context, map((constructor) => (new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature("Create", constructor.Documentation, info.TypeParameters, constructor.Parameters, instanceType, false)])), isEmpty(info.Constructors) ? singleton(new GlueConstructor(empty(), empty())) : info.Constructors))), TransformMembers_toFSharpMember(context, choose((_arg_1) => {
1329
+ let property, accessor;
1330
+ let matchResult, method_2, property_1, accessor_1;
1331
+ switch (_arg_1.tag) {
1332
+ case 0: {
1333
+ if (_arg_1.fields[0].IsStatic) {
1334
+ matchResult = 0;
1335
+ method_2 = _arg_1.fields[0];
1336
+ }
1337
+ else {
1338
+ matchResult = 3;
1339
+ }
1340
+ break;
1341
+ }
1342
+ case 1: {
1343
+ if ((property = _arg_1.fields[0], property.IsStatic && !property.IsPrivate)) {
1344
+ matchResult = 1;
1345
+ property_1 = _arg_1.fields[0];
1346
+ }
1347
+ else {
1348
+ matchResult = 3;
1349
+ }
1350
+ break;
1351
+ }
1352
+ case 2: {
1353
+ if ((accessor = _arg_1.fields[0], accessor.IsStatic && !accessor.IsPrivate)) {
1354
+ matchResult = 2;
1355
+ accessor_1 = _arg_1.fields[0];
1356
+ }
1357
+ else {
1358
+ matchResult = 3;
1359
+ }
1360
+ break;
1361
+ }
1362
+ default:
1363
+ matchResult = 3;
1364
+ }
1365
+ switch (matchResult) {
1366
+ case 0:
1367
+ return new GlueMember(/* Method */ 0, [new GlueMethod(method_2.Name, method_2.Documentation, method_2.TypeParameters, method_2.Parameters, method_2.Type, method_2.IsOptional, false)]);
1368
+ case 1:
1369
+ return new GlueMember(/* Property */ 1, [new GlueProperty(property_1.Name, property_1.Documentation, property_1.Type, false, property_1.IsOptional, property_1.Accessor, property_1.IsPrivate)]);
1370
+ case 2:
1371
+ return new GlueMember(/* GetAccessor */ 2, [new GlueGetAccessor(accessor_1.Name, accessor_1.Documentation, accessor_1.Type, false, accessor_1.IsPrivate)]);
1372
+ default:
1373
+ return undefined;
1374
+ }
1375
+ }, info.Members))), empty()), new FSharpInterface(bind$0040.Attributes, bind$0040.Name, bind$0040.XmlDoc, "", bind$0040.TypeParameters, bind$0040.Members, bind$0040.Inheritance))]));
1376
+ }
1377
+
1226
1378
  function transformType(context_mut, glueType_mut) {
1227
1379
  transformType:
1228
1380
  while (true) {
1229
1381
  const context = context_mut, glueType = glueType_mut;
1230
- let matchResult, constructSignature, primitiveInfo, glueType_21, thisTypeInfo, glueTypes, glueType_22, cases, typeReference_2, typeReference_3, argument, typeReference_4, glueType_25, classDeclaration, name, functionTypeInfo, interfaceInfo, name_1, typeLiteralInfo, glueType_26, info, innerGlueType, namedTupleType, glueLiteral, functionDeclaration_1, functionDeclaration_2, members, references, members_1, utilityType, typeAliasDeclaration, mappedType;
1382
+ let matchResult, reference, constructSignature, primitiveInfo, glueType_21, thisTypeInfo, glueTypes, glueType_22, cases, typeReference_2, typeReference_3, argument, typeReference_4, glueType_25, classDeclaration, name, functionTypeInfo, interfaceInfo, name_1, typeLiteralInfo, glueType_26, info, innerGlueType, namedTupleType, glueLiteral, functionDeclaration_1, functionDeclaration_2, members, references, members_1, utilityType, typeAliasDeclaration, mappedType;
1231
1383
  switch (glueType.tag) {
1232
- case 29: {
1384
+ case 30: {
1233
1385
  matchResult = 1;
1386
+ reference = glueType.fields[0];
1387
+ break;
1388
+ }
1389
+ case 29: {
1390
+ matchResult = 2;
1234
1391
  constructSignature = glueType.fields[0];
1235
1392
  break;
1236
1393
  }
1237
1394
  case 3: {
1238
- matchResult = 2;
1395
+ matchResult = 3;
1239
1396
  primitiveInfo = glueType.fields[0];
1240
1397
  break;
1241
1398
  }
1242
1399
  case 26: {
1243
- matchResult = 3;
1400
+ matchResult = 4;
1244
1401
  break;
1245
1402
  }
1246
1403
  case 23: {
1247
- matchResult = 4;
1404
+ matchResult = 5;
1248
1405
  glueType_21 = glueType.fields[0];
1249
1406
  break;
1250
1407
  }
1251
1408
  case 17: {
1252
- matchResult = 5;
1409
+ matchResult = 6;
1253
1410
  thisTypeInfo = glueType.fields[0];
1254
1411
  break;
1255
1412
  }
1256
1413
  case 18: {
1257
- matchResult = 6;
1414
+ matchResult = 7;
1258
1415
  glueTypes = glueType.fields[0];
1259
1416
  break;
1260
1417
  }
1261
- case 30: {
1262
- matchResult = 7;
1418
+ case 31: {
1419
+ matchResult = 8;
1263
1420
  glueType_22 = glueType.fields[0];
1264
1421
  break;
1265
1422
  }
1266
1423
  case 7: {
1267
- matchResult = 8;
1424
+ matchResult = 9;
1268
1425
  cases = glueType.fields[0].fields[0];
1269
1426
  break;
1270
1427
  }
1271
1428
  case 13: {
1272
1429
  if (isConditionalAlias(TransformContext__get_State(context).Conditionals, glueType.fields[0].FullName)) {
1273
- matchResult = 9;
1430
+ matchResult = 10;
1274
1431
  typeReference_2 = glueType.fields[0];
1275
1432
  }
1276
1433
  else if (mapTypeNameToFableCoreAwareName(context, glueType.fields[0]) === "obj") {
1277
- matchResult = 10;
1434
+ matchResult = 11;
1278
1435
  typeReference_3 = glueType.fields[0];
1279
1436
  }
1280
1437
  else if (glueType.fields[0].Name === "Readonly") {
1281
1438
  if (!isEmpty(glueType.fields[0].TypeArguments)) {
1282
1439
  if (isEmpty(tail_1(glueType.fields[0].TypeArguments))) {
1283
1440
  if (glueType.fields[0].IsStandardLibrary) {
1284
- matchResult = 11;
1441
+ matchResult = 12;
1285
1442
  argument = head_1(glueType.fields[0].TypeArguments);
1286
1443
  }
1287
1444
  else {
1288
- matchResult = 12;
1445
+ matchResult = 13;
1289
1446
  typeReference_4 = glueType.fields[0];
1290
1447
  }
1291
1448
  }
1292
1449
  else {
1293
- matchResult = 12;
1450
+ matchResult = 13;
1294
1451
  typeReference_4 = glueType.fields[0];
1295
1452
  }
1296
1453
  }
1297
1454
  else {
1298
- matchResult = 12;
1455
+ matchResult = 13;
1299
1456
  typeReference_4 = glueType.fields[0];
1300
1457
  }
1301
1458
  }
1302
1459
  else {
1303
- matchResult = 12;
1460
+ matchResult = 13;
1304
1461
  typeReference_4 = glueType.fields[0];
1305
1462
  }
1306
1463
  break;
1307
1464
  }
1308
1465
  case 14: {
1309
- matchResult = 13;
1466
+ matchResult = 14;
1310
1467
  glueType_25 = glueType.fields[0];
1311
1468
  break;
1312
1469
  }
1313
1470
  case 12: {
1314
- matchResult = 14;
1471
+ matchResult = 15;
1315
1472
  classDeclaration = glueType.fields[0];
1316
1473
  break;
1317
1474
  }
1318
1475
  case 16: {
1319
- matchResult = 15;
1476
+ matchResult = 16;
1320
1477
  name = glueType.fields[0];
1321
1478
  break;
1322
1479
  }
1323
1480
  case 15: {
1324
- matchResult = 16;
1481
+ matchResult = 17;
1325
1482
  functionTypeInfo = glueType.fields[0];
1326
1483
  break;
1327
1484
  }
1328
1485
  case 1: {
1329
- matchResult = 17;
1486
+ matchResult = 18;
1330
1487
  interfaceInfo = glueType.fields[0];
1331
1488
  break;
1332
1489
  }
1333
1490
  case 22: {
1334
1491
  if (isEmpty(glueType.fields[0].Members)) {
1335
- matchResult = 18;
1492
+ matchResult = 19;
1336
1493
  }
1337
1494
  else {
1338
1495
  const activePatternResult = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1339
1496
  if (activePatternResult != null) {
1340
- matchResult = 19;
1497
+ matchResult = 20;
1341
1498
  name_1 = activePatternResult;
1342
1499
  }
1343
1500
  else {
1344
- matchResult = 20;
1501
+ matchResult = 21;
1345
1502
  typeLiteralInfo = glueType.fields[0];
1346
1503
  }
1347
1504
  }
@@ -1350,11 +1507,11 @@ function transformType(context_mut, glueType_mut) {
1350
1507
  case 25: {
1351
1508
  const activePatternResult_1 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1352
1509
  if (activePatternResult_1 != null) {
1353
- matchResult = 19;
1510
+ matchResult = 20;
1354
1511
  name_1 = activePatternResult_1;
1355
1512
  }
1356
1513
  else {
1357
- matchResult = 21;
1514
+ matchResult = 22;
1358
1515
  glueType_26 = glueType.fields[0];
1359
1516
  }
1360
1517
  break;
@@ -1362,11 +1519,11 @@ function transformType(context_mut, glueType_mut) {
1362
1519
  case 2: {
1363
1520
  const activePatternResult_2 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1364
1521
  if (activePatternResult_2 != null) {
1365
- matchResult = 19;
1522
+ matchResult = 20;
1366
1523
  name_1 = activePatternResult_2;
1367
1524
  }
1368
1525
  else {
1369
- matchResult = 22;
1526
+ matchResult = 23;
1370
1527
  info = glueType.fields[0];
1371
1528
  }
1372
1529
  break;
@@ -1374,11 +1531,11 @@ function transformType(context_mut, glueType_mut) {
1374
1531
  case 9: {
1375
1532
  const activePatternResult_3 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1376
1533
  if (activePatternResult_3 != null) {
1377
- matchResult = 19;
1534
+ matchResult = 20;
1378
1535
  name_1 = activePatternResult_3;
1379
1536
  }
1380
1537
  else {
1381
- matchResult = 23;
1538
+ matchResult = 24;
1382
1539
  innerGlueType = glueType.fields[0];
1383
1540
  }
1384
1541
  break;
@@ -1386,11 +1543,11 @@ function transformType(context_mut, glueType_mut) {
1386
1543
  case 19: {
1387
1544
  const activePatternResult_4 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1388
1545
  if (activePatternResult_4 != null) {
1389
- matchResult = 19;
1546
+ matchResult = 20;
1390
1547
  name_1 = activePatternResult_4;
1391
1548
  }
1392
1549
  else {
1393
- matchResult = 24;
1550
+ matchResult = 25;
1394
1551
  namedTupleType = glueType.fields[0];
1395
1552
  }
1396
1553
  break;
@@ -1398,22 +1555,22 @@ function transformType(context_mut, glueType_mut) {
1398
1555
  case 0: {
1399
1556
  const activePatternResult_5 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1400
1557
  if (activePatternResult_5 != null) {
1401
- matchResult = 19;
1558
+ matchResult = 20;
1402
1559
  name_1 = activePatternResult_5;
1403
1560
  }
1404
1561
  else {
1405
- matchResult = 25;
1562
+ matchResult = 26;
1406
1563
  }
1407
1564
  break;
1408
1565
  }
1409
1566
  case 8: {
1410
1567
  const activePatternResult_6 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1411
1568
  if (activePatternResult_6 != null) {
1412
- matchResult = 19;
1569
+ matchResult = 20;
1413
1570
  name_1 = activePatternResult_6;
1414
1571
  }
1415
1572
  else {
1416
- matchResult = 26;
1573
+ matchResult = 27;
1417
1574
  glueLiteral = glueType.fields[0];
1418
1575
  }
1419
1576
  break;
@@ -1421,15 +1578,15 @@ function transformType(context_mut, glueType_mut) {
1421
1578
  case 6: {
1422
1579
  const activePatternResult_7 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1423
1580
  if (activePatternResult_7 != null) {
1424
- matchResult = 19;
1581
+ matchResult = 20;
1425
1582
  name_1 = activePatternResult_7;
1426
1583
  }
1427
1584
  else if (!isEmpty(glueType.fields[0].TypeParameters)) {
1428
- matchResult = 27;
1585
+ matchResult = 28;
1429
1586
  functionDeclaration_1 = glueType.fields[0];
1430
1587
  }
1431
1588
  else {
1432
- matchResult = 28;
1589
+ matchResult = 29;
1433
1590
  functionDeclaration_2 = glueType.fields[0];
1434
1591
  }
1435
1592
  break;
@@ -1437,11 +1594,11 @@ function transformType(context_mut, glueType_mut) {
1437
1594
  case 21: {
1438
1595
  const activePatternResult_8 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1439
1596
  if (activePatternResult_8 != null) {
1440
- matchResult = 19;
1597
+ matchResult = 20;
1441
1598
  name_1 = activePatternResult_8;
1442
1599
  }
1443
1600
  else {
1444
- matchResult = 29;
1601
+ matchResult = 30;
1445
1602
  members = glueType.fields[1];
1446
1603
  references = glueType.fields[0];
1447
1604
  }
@@ -1450,11 +1607,11 @@ function transformType(context_mut, glueType_mut) {
1450
1607
  case 20: {
1451
1608
  const activePatternResult_9 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1452
1609
  if (activePatternResult_9 != null) {
1453
- matchResult = 19;
1610
+ matchResult = 20;
1454
1611
  name_1 = activePatternResult_9;
1455
1612
  }
1456
1613
  else {
1457
- matchResult = 30;
1614
+ matchResult = 31;
1458
1615
  members_1 = glueType.fields[0];
1459
1616
  }
1460
1617
  break;
@@ -1462,11 +1619,11 @@ function transformType(context_mut, glueType_mut) {
1462
1619
  case 27: {
1463
1620
  const activePatternResult_10 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1464
1621
  if (activePatternResult_10 != null) {
1465
- matchResult = 19;
1622
+ matchResult = 20;
1466
1623
  name_1 = activePatternResult_10;
1467
1624
  }
1468
1625
  else {
1469
- matchResult = 31;
1626
+ matchResult = 32;
1470
1627
  utilityType = glueType.fields[0];
1471
1628
  }
1472
1629
  break;
@@ -1474,11 +1631,11 @@ function transformType(context_mut, glueType_mut) {
1474
1631
  case 5: {
1475
1632
  const activePatternResult_11 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1476
1633
  if (activePatternResult_11 != null) {
1477
- matchResult = 19;
1634
+ matchResult = 20;
1478
1635
  name_1 = activePatternResult_11;
1479
1636
  }
1480
1637
  else {
1481
- matchResult = 32;
1638
+ matchResult = 33;
1482
1639
  typeAliasDeclaration = glueType.fields[0];
1483
1640
  }
1484
1641
  break;
@@ -1486,11 +1643,11 @@ function transformType(context_mut, glueType_mut) {
1486
1643
  case 28: {
1487
1644
  const activePatternResult_12 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1488
1645
  if (activePatternResult_12 != null) {
1489
- matchResult = 19;
1646
+ matchResult = 20;
1490
1647
  name_1 = activePatternResult_12;
1491
1648
  }
1492
1649
  else {
1493
- matchResult = 33;
1650
+ matchResult = 34;
1494
1651
  mappedType = glueType.fields[0];
1495
1652
  }
1496
1653
  break;
@@ -1498,66 +1655,66 @@ function transformType(context_mut, glueType_mut) {
1498
1655
  case 10: {
1499
1656
  const activePatternResult_13 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1500
1657
  if (activePatternResult_13 != null) {
1501
- matchResult = 19;
1658
+ matchResult = 20;
1502
1659
  name_1 = activePatternResult_13;
1503
1660
  }
1504
1661
  else {
1505
- matchResult = 34;
1662
+ matchResult = 35;
1506
1663
  }
1507
1664
  break;
1508
1665
  }
1509
1666
  case 11: {
1510
1667
  const activePatternResult_14 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1511
1668
  if (activePatternResult_14 != null) {
1512
- matchResult = 19;
1669
+ matchResult = 20;
1513
1670
  name_1 = activePatternResult_14;
1514
1671
  }
1515
1672
  else {
1516
- matchResult = 35;
1673
+ matchResult = 36;
1517
1674
  }
1518
1675
  break;
1519
1676
  }
1520
- case 33: {
1677
+ case 34: {
1521
1678
  const activePatternResult_15 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1522
1679
  if (activePatternResult_15 != null) {
1523
- matchResult = 19;
1680
+ matchResult = 20;
1524
1681
  name_1 = activePatternResult_15;
1525
1682
  }
1526
1683
  else {
1527
- matchResult = 36;
1684
+ matchResult = 37;
1528
1685
  }
1529
1686
  break;
1530
1687
  }
1531
- case 31: {
1688
+ case 32: {
1532
1689
  const activePatternResult_16 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1533
1690
  if (activePatternResult_16 != null) {
1534
- matchResult = 19;
1691
+ matchResult = 20;
1535
1692
  name_1 = activePatternResult_16;
1536
1693
  }
1537
1694
  else {
1538
- matchResult = 37;
1695
+ matchResult = 38;
1539
1696
  }
1540
1697
  break;
1541
1698
  }
1542
- case 32: {
1699
+ case 33: {
1543
1700
  const activePatternResult_17 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1544
1701
  if (activePatternResult_17 != null) {
1545
- matchResult = 19;
1702
+ matchResult = 20;
1546
1703
  name_1 = activePatternResult_17;
1547
1704
  }
1548
1705
  else {
1549
- matchResult = 37;
1706
+ matchResult = 38;
1550
1707
  }
1551
1708
  break;
1552
1709
  }
1553
1710
  case 4: {
1554
1711
  const activePatternResult_18 = $007CRememberedTypeLiteral$007C_$007C(context, glueType);
1555
1712
  if (activePatternResult_18 != null) {
1556
- matchResult = 19;
1713
+ matchResult = 20;
1557
1714
  name_1 = activePatternResult_18;
1558
1715
  }
1559
1716
  else {
1560
- matchResult = 37;
1717
+ matchResult = 38;
1561
1718
  }
1562
1719
  break;
1563
1720
  }
@@ -1567,45 +1724,47 @@ function transformType(context_mut, glueType_mut) {
1567
1724
  switch (matchResult) {
1568
1725
  case 0:
1569
1726
  return FSharpType.Object$;
1570
- case 1: {
1727
+ case 1:
1728
+ return transformClassConstructor(context, reference);
1729
+ case 2: {
1571
1730
  context_mut = context;
1572
1731
  glueType_mut = (new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(singleton(new GlueMember(/* ConstructSignature */ 7, [constructSignature])), undefined)]));
1573
1732
  continue transformType;
1574
1733
  }
1575
- case 2:
1576
- return new FSharpType(/* Primitive */ 8, [transformPrimitive(primitiveInfo)]);
1577
1734
  case 3:
1578
- return new FSharpType(/* Primitive */ 8, [FSharpPrimitive.String$]);
1735
+ return new FSharpType(/* Primitive */ 8, [transformPrimitive(primitiveInfo)]);
1579
1736
  case 4:
1580
- return new FSharpType(/* Option */ 3, [transformType(context, glueType_21)]);
1737
+ return new FSharpType(/* Primitive */ 8, [FSharpPrimitive.String$]);
1581
1738
  case 5:
1582
- return new FSharpType(/* ThisType */ 15, [new FSharpThisType(sanitizeTypeName(thisTypeInfo.Name), declaredTypeParameters_1(map((_arg) => _arg.Name, thisTypeInfo.TypeParameters)))]);
1739
+ return new FSharpType(/* Option */ 3, [transformType(context, glueType_21)]);
1583
1740
  case 6:
1584
- return transformTupleType(context, glueTypes);
1741
+ return new FSharpType(/* ThisType */ 15, [new FSharpThisType(sanitizeTypeName(thisTypeInfo.Name), declaredTypeParameters_1(map((_arg) => _arg.Name, thisTypeInfo.TypeParameters)))]);
1585
1742
  case 7:
1586
- return transformReadOnlyModifier(context, glueType_22);
1743
+ return transformTupleType(context, glueTypes);
1587
1744
  case 8:
1588
- return transformUnionType(context, cases);
1745
+ return transformReadOnlyModifier(context, glueType_22);
1589
1746
  case 9:
1590
- return FSharpType.Object$;
1747
+ return transformUnionType(context, cases);
1591
1748
  case 10:
1592
1749
  return FSharpType.Object$;
1593
- case 11: {
1750
+ case 11:
1751
+ return FSharpType.Object$;
1752
+ case 12: {
1594
1753
  context_mut = context;
1595
1754
  glueType_mut = argument;
1596
1755
  continue transformType;
1597
1756
  }
1598
- case 12:
1599
- return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(mapTypeNameToFableCoreAwareName(context, typeReference_4), typeReference_4.FullName, typeReference_4.ModulePath, (typeReference_4.IsStandardLibrary && FSharpSet__Contains(typedArrayNames, typeReference_4.Name)) ? empty() : ((typeReference_4.IsStandardLibrary && FSharpSet__Contains(iteratorNames, typeReference_4.Name)) ? map((glueType_23) => transformType(context, glueType_23), truncate(1, typeReference_4.TypeArguments)) : map((glueType_24) => transformType(context, glueType_24), typeReference_4.TypeArguments)), FSharpType.Discard)]);
1600
1757
  case 13:
1601
- return new FSharpType(/* ResizeArray */ 14, [transformType(TransformContext__PushScope_27AED5E3(context, "Item"), glueType_25)]);
1758
+ return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(mapTypeNameToFableCoreAwareName(context, typeReference_4), typeReference_4.FullName, typeReference_4.ModulePath, (typeReference_4.IsStandardLibrary && FSharpSet__Contains(typedArrayNames, typeReference_4.Name)) ? empty() : ((typeReference_4.IsStandardLibrary && FSharpSet__Contains(iteratorNames, typeReference_4.Name)) ? map((glueType_23) => transformType(context, glueType_23), truncate(1, typeReference_4.TypeArguments)) : map((glueType_24) => transformType(context, glueType_24), typeReference_4.TypeArguments)), FSharpType.Discard)]);
1602
1759
  case 14:
1603
- return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(classDeclaration.Name, classDeclaration.Name, empty(), empty(), FSharpType.Discard)]);
1760
+ return new FSharpType(/* ResizeArray */ 14, [transformType(TransformContext__PushScope_27AED5E3(context, "Item"), glueType_25)]);
1604
1761
  case 15:
1605
- return new FSharpType(/* TypeParameter */ 13, [name]);
1762
+ return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(classDeclaration.Name, classDeclaration.Name, empty(), empty(), FSharpType.Discard)]);
1606
1763
  case 16:
1764
+ return new FSharpType(/* TypeParameter */ 13, [name]);
1765
+ case 17:
1607
1766
  return transformFunctionType(context, functionTypeInfo);
1608
- case 17: {
1767
+ case 18: {
1609
1768
  const matchValue = tryTransformCallableInterface(context, interfaceInfo);
1610
1769
  if (matchValue == null) {
1611
1770
  return new FSharpType(/* Interface */ 5, [transformInterface(context, interfaceInfo)]);
@@ -1614,40 +1773,44 @@ function transformType(context_mut, glueType_mut) {
1614
1773
  return matchValue;
1615
1774
  }
1616
1775
  }
1617
- case 18:
1618
- return FSharpType.Object$;
1619
1776
  case 19:
1620
- return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(name_1, TransformContext__get_FullName(context), empty(), empty(), FSharpType.Discard)]);
1777
+ return FSharpType.Object$;
1621
1778
  case 20:
1779
+ return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(name_1, TransformContext__get_FullName(context), empty(), empty(), FSharpType.Discard)]);
1780
+ case 21:
1622
1781
  return transformTypeLiteral(context, typeLiteralInfo);
1623
- case 21: {
1782
+ case 22: {
1624
1783
  context_mut = context;
1625
1784
  glueType_mut = glueType_26;
1626
1785
  continue transformType;
1627
1786
  }
1628
- case 22: {
1787
+ case 23: {
1629
1788
  context_mut = context;
1630
1789
  glueType_mut = info.Type;
1631
1790
  continue transformType;
1632
1791
  }
1633
- case 23: {
1792
+ case 24: {
1634
1793
  const matchValue_1 = TypeAliasDeclaration_tryTransformKeyOf(TransformContext__get_CurrentScopeName(context), innerGlueType);
1635
1794
  if (matchValue_1 == null) {
1636
1795
  return FSharpType.Object$;
1637
1796
  }
1638
1797
  else {
1639
- TransformContext__ExposeType_Z1D58A540(context, matchValue_1);
1640
- return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), empty(), FSharpType.Discard)]);
1798
+ const name_2 = TransformContext__NewTypeName(context);
1799
+ const option_1 = TypeAliasDeclaration_tryTransformKeyOf(name_2, innerGlueType);
1800
+ if (option_1 != null) {
1801
+ TransformContext__ExposeType_Z1D58A540(context, option_1);
1802
+ }
1803
+ return referenceToExposed(context, name_2, empty());
1641
1804
  }
1642
1805
  }
1643
- case 24: {
1806
+ case 25: {
1644
1807
  context_mut = context;
1645
1808
  glueType_mut = namedTupleType.Type;
1646
1809
  continue transformType;
1647
1810
  }
1648
- case 25:
1649
- return FSharpType.Object$;
1650
1811
  case 26:
1812
+ return FSharpType.Object$;
1813
+ case 27:
1651
1814
  switch (glueLiteral.tag) {
1652
1815
  case 1:
1653
1816
  return new FSharpType(/* Primitive */ 8, [FSharpPrimitive.Int]);
@@ -1660,26 +1823,26 @@ function transformType(context_mut, glueType_mut) {
1660
1823
  default:
1661
1824
  return new FSharpType(/* Primitive */ 8, [FSharpPrimitive.String$]);
1662
1825
  }
1663
- case 27:
1664
- return FSharpType.Object$;
1665
1826
  case 28:
1666
- return new FSharpType(/* Function */ 16, [new FSharpFunctionType(requiredBeforeParamArray(map((parameter) => transformParameter(context, parameter), functionDeclaration_2.Parameters)), transformType(context, functionDeclaration_2.Type))]);
1827
+ return FSharpType.Object$;
1667
1828
  case 29:
1668
- return transformIntersectionOfReferences(context, references, members);
1829
+ return new FSharpType(/* Function */ 16, [new FSharpFunctionType(requiredBeforeParamArray(map((parameter) => transformParameter(context, parameter), functionDeclaration_2.Parameters)), transformType(context, functionDeclaration_2.Type))]);
1669
1830
  case 30:
1670
- return transformIntersectionType(context, members_1);
1831
+ return transformIntersectionOfReferences(context, references, members);
1671
1832
  case 31:
1672
- return UtilityType_transform(context, utilityType);
1833
+ return transformIntersectionType(context, members_1);
1673
1834
  case 32:
1674
- return new FSharpType(/* Mapped */ 7, [new FSharpMapped(typeAliasDeclaration.Name, empty())]);
1835
+ return UtilityType_transform(context, utilityType);
1675
1836
  case 33:
1676
- return transformMappedType(context, mappedType);
1837
+ return new FSharpType(/* Mapped */ 7, [new FSharpMapped(typeAliasDeclaration.Name, empty())]);
1677
1838
  case 34:
1678
- return FSharpType.Object$;
1839
+ return transformMappedType(context, mappedType);
1679
1840
  case 35:
1680
1841
  return FSharpType.Object$;
1681
1842
  case 36:
1682
1843
  return FSharpType.Object$;
1844
+ case 37:
1845
+ return FSharpType.Object$;
1683
1846
  default: {
1684
1847
  TransformContext__AddError_Z721C83C5(context, `Could not transform type: ${interpolate("%A%P()", [glueType])}`);
1685
1848
  return FSharpType.Discard;
@@ -1694,7 +1857,7 @@ function transformParameter(context, parameter) {
1694
1857
  const parameter_1 = new GlueParameter(parameter.Name, parameter.IsOptional, parameter.IsSpread, arrayAsInput(parameter.Type));
1695
1858
  let typ;
1696
1859
  const computedType = unwrapOptionIfAlreadyOptional(patternInput[1], parameter_1.Type, parameter_1.IsOptional);
1697
- 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);
1860
+ 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) : FSharpType.Object$) : FSharpType.Object$) : FSharpType.Object$) : ((computedType.tag === 19) ? computedType.fields[0].fields[0] : FSharpType.Object$))) : computedType);
1698
1861
  return new FSharpParameter(toList(delay(() => (parameter_1.IsSpread ? singleton_1(FSharpAttribute.ParamArray) : empty_1()))), patternInput[0], parameter_1.IsOptional, typ, undefined);
1699
1862
  }
1700
1863
 
@@ -2604,6 +2767,8 @@ function paramObjectParameters(context, members) {
2604
2767
  const info = _arg.fields[0];
2605
2768
  return new GlueMember(/* Property */ 1, [new GlueProperty(info.Name, info.Documentation, arrayAsInput(info.Type), info.IsStatic, info.IsOptional, info.Accessor, info.IsPrivate)]);
2606
2769
  }
2770
+ case 6:
2771
+ return methodAsProperty(_arg);
2607
2772
  default:
2608
2773
  return _arg;
2609
2774
  }
@@ -2764,13 +2929,64 @@ function paramObjectParameterSets(context, members) {
2764
2929
  }
2765
2930
  }
2766
2931
  }, parameters) : parameters;
2767
- return defaultArg(tryParameterCombinations(TransformContext__get_State(context).MaxOverloads, expandable), singleton(parameters));
2932
+ return defaultArg(tryParameterCombinations(min(TransformContext__get_State(context).MaxOverloads, ~~((TransformContext__get_State(context).MaxOverloads * 16) / max(1, length(parameters)))), expandable), singleton(parameters));
2768
2933
  }
2769
2934
 
2770
2935
  function paramObjectCreateMembers(context, returnType, members) {
2771
2936
  return map((parameters) => (new FSharpMember(/* Method */ 0, [new FSharpMemberInfo(ofArray([FSharpAttribute.ParamObject, FSharpAttribute.EmitSelf]), "Create", "Create", empty(), requiredBeforeParamArray(parameters), returnType, false, true, undefined, FSharpAccessibility.Public, empty(), FSharpMemberInfoBody.NativeOnly)])), paramObjectParameterSets(context, members));
2772
2937
  }
2773
2938
 
2939
+ function dictionaryCreateMembers(context, returnType, members) {
2940
+ let glueType, matchValue;
2941
+ let matchResult, valueType;
2942
+ if (!isEmpty(members)) {
2943
+ if (head_1(members).tag === 5) {
2944
+ if (!isEmpty(head_1(members).fields[0].Parameters)) {
2945
+ if (head_1(head_1(members).fields[0].Parameters).Type.tag === 3) {
2946
+ if (head_1(head_1(members).fields[0].Parameters).Type.fields[0].tag === 0) {
2947
+ if (isEmpty(tail_1(head_1(members).fields[0].Parameters))) {
2948
+ if (head_1(members).fields[0].IsReadOnly) {
2949
+ matchResult = 1;
2950
+ }
2951
+ else if (isEmpty(tail_1(members))) {
2952
+ matchResult = 0;
2953
+ valueType = head_1(members).fields[0].Type;
2954
+ }
2955
+ else {
2956
+ matchResult = 1;
2957
+ }
2958
+ }
2959
+ else {
2960
+ matchResult = 1;
2961
+ }
2962
+ }
2963
+ else {
2964
+ matchResult = 1;
2965
+ }
2966
+ }
2967
+ else {
2968
+ matchResult = 1;
2969
+ }
2970
+ }
2971
+ else {
2972
+ matchResult = 1;
2973
+ }
2974
+ }
2975
+ else {
2976
+ matchResult = 1;
2977
+ }
2978
+ }
2979
+ else {
2980
+ matchResult = 1;
2981
+ }
2982
+ switch (matchResult) {
2983
+ case 0:
2984
+ return singleton(new FSharpMember(/* Method */ 0, [new FSharpMemberInfo(singleton(new FSharpAttribute(/* Text */ 0, ["Emit(\"Object.fromEntries($0)\")"])), "Create", "Create", empty(), singleton(new FSharpParameter(empty(), "entries", false, new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference("seq", "", empty(), singleton(new FSharpType(/* Tuple */ 12, [ofArray([new FSharpType(/* Primitive */ 8, [FSharpPrimitive.String$]), transformType(TransformContext__PushScope_27AED5E3(context, "Item"), arrayAsInput((glueType = valueType, (glueType.tag === 7) ? ((matchValue = filter((y) => !equals(new GlueType(/* Primitive */ 3, [GluePrimitive.Undefined]), y), glueType.fields[0].fields[0]), !isEmpty(matchValue) ? (isEmpty(tail_1(matchValue)) ? head_1(matchValue) : (new GlueType(/* Union */ 7, [new GlueTypeUnion(matchValue)]))) : (new GlueType(/* Union */ 7, [new GlueTypeUnion(matchValue)])))) : glueType)))])])), FSharpType.Discard)]), undefined)), returnType, false, true, undefined, FSharpAccessibility.Public, empty(), FSharpMemberInfoBody.NativeOnly)]));
2985
+ default:
2986
+ return empty();
2987
+ }
2988
+ }
2989
+
2774
2990
  function transformParamObjectClass(context, name, documentation, members) {
2775
2991
  const xmlDocInfo = transformComment(documentation);
2776
2992
  const typeParameterNames = List_distinct(collect(memberTypeParameterNames, members), {
@@ -2798,7 +3014,7 @@ function transformParamObjectClass(context, name, documentation, members) {
2798
3014
  function arrayAsInput(glueType) {
2799
3015
  let matchResult, elementType, elementType_1, cases, glueType_2, glueType_3;
2800
3016
  switch (glueType.tag) {
2801
- case 30: {
3017
+ case 31: {
2802
3018
  if (glueType.fields[0].tag === 14) {
2803
3019
  matchResult = 0;
2804
3020
  elementType = glueType.fields[0].fields[0];
@@ -2894,6 +3110,28 @@ function transformCallbackReturnType(context, returnType) {
2894
3110
  }
2895
3111
  }
2896
3112
 
3113
+ function transformOwnCallbackReturnType(context, ownDefaults, returnType) {
3114
+ let matchResult, name_1;
3115
+ if (returnType.tag === 16) {
3116
+ if (FSharpMap__ContainsKey(ownDefaults, returnType.fields[0])) {
3117
+ matchResult = 0;
3118
+ name_1 = returnType.fields[0];
3119
+ }
3120
+ else {
3121
+ matchResult = 1;
3122
+ }
3123
+ }
3124
+ else {
3125
+ matchResult = 1;
3126
+ }
3127
+ switch (matchResult) {
3128
+ case 0:
3129
+ return transformType(context, arrayAsInput(FSharpMap__get_Item(ownDefaults, name_1)));
3130
+ default:
3131
+ return transformCallbackReturnType(context, GlueSubstitution_substitute(ownDefaults, returnType));
3132
+ }
3133
+ }
3134
+
2897
3135
  function tryTransformCallableInterface(context, info) {
2898
3136
  const isDeclaredOnce = length(filter((_arg) => {
2899
3137
  if (_arg.tag === 1) {
@@ -2934,7 +3172,7 @@ function tryTransformCallableInterface(context, info) {
2934
3172
  else if (head_1(matchValue).tag === 4) {
2935
3173
  if (isEmpty(tail_1(matchValue))) {
2936
3174
  if (isEmpty(matchValue_1)) {
2937
- if (isDeclaredOnce) {
3175
+ if (isDeclaredOnce && isEmpty(head_1(matchValue).fields[0].TypeParameters)) {
2938
3176
  matchResult = 0;
2939
3177
  callSignature_1 = head_1(matchValue).fields[0];
2940
3178
  }
@@ -2987,13 +3225,18 @@ function tryTransformCallableInterface(context, info) {
2987
3225
  }
2988
3226
 
2989
3227
  function transformInterface(context, info) {
2990
- let members_2, typeMemory_1, ownNames;
3228
+ let members_4, typeMemory_1, ownNames;
2991
3229
  let info_1;
2992
- const patternInput = withoutRedeclaredBases(TransformContext__get_TypeMemory(context), info.Members, info.HeritageClauses);
2993
- info_1 = (new GlueInterface(info.Documentation, info.FullName, info.Name, (members_2 = asMethods(TransformContext__get_TypeMemory(context), patternInput[1]), resolveMembers(TransformContext__get_State(context).Conditionals, members_2)), info.TypeParameters, patternInput[0]));
2994
- const patternInput_1 = sanitizeTypeNameAndPushScope(info_1.Name, context);
2995
- const name = patternInput_1[0];
2996
- const context_1 = patternInput_1[1];
3230
+ const thisType = new GlueThisType(info.Name, info.TypeParameters);
3231
+ const patternInput = withoutRedeclaredBases(TransformContext__get_TypeMemory(context), thisType, info.Members, info.HeritageClauses);
3232
+ const patternInput_1 = withoutConflictingInstantiations(TransformContext__get_TypeMemory(context), thisType, patternInput[1], patternInput[0]);
3233
+ const members_1 = patternInput_1[1];
3234
+ const heritageClauses_1 = patternInput_1[0];
3235
+ const members_2 = append(members_1, thisMembersOfBases(TransformContext__get_TypeMemory(context), thisType, members_1, heritageClauses_1));
3236
+ info_1 = (new GlueInterface(info.Documentation, info.FullName, info.Name, (members_4 = asMethods(TransformContext__get_TypeMemory(context), members_2), resolveMembers(TransformContext__get_State(context).Conditionals, members_4)), info.TypeParameters, heritageClauses_1));
3237
+ const patternInput_2 = sanitizeTypeNameAndPushScope(info_1.Name, context);
3238
+ const name = patternInput_2[0];
3239
+ const context_1 = patternInput_2[1];
2997
3240
  const xmlDocInfo = transformComment(info_1.Documentation);
2998
3241
  const membersComingFromPartial = concat_1(map((fullName) => {
2999
3242
  if (contains_1(fullName, TransformContext__get_State(context_1).PartialHeritageBeingExpanded, {
@@ -3030,7 +3273,7 @@ function transformInterface(context, info) {
3030
3273
  const typeReference = heritageClause.fields[0];
3031
3274
  if (typeReference.IsStandardLibrary && (typeReference.Name === "Partial")) {
3032
3275
  if (length(typeReference.TypeArguments) === 1) {
3033
- const matchValue = item(0, typeReference.TypeArguments);
3276
+ const matchValue = item_1(0, typeReference.TypeArguments);
3034
3277
  if (matchValue.tag === 13) {
3035
3278
  return matchValue.fields[0].FullName;
3036
3279
  }
@@ -3051,17 +3294,17 @@ function transformInterface(context, info) {
3051
3294
  }
3052
3295
  }, map((typ) => TransformContext__ExposeTypeAlias_1CE4A880(context_1, typ), info_1.HeritageClauses))));
3053
3296
  const membersComingFromOmit = collect((heritageClause_1) => {
3054
- let matchResult, members_3;
3297
+ let matchResult, members_5;
3055
3298
  if (heritageClause_1.tag === 27) {
3056
3299
  switch (heritageClause_1.fields[0].tag) {
3057
3300
  case 4: {
3058
3301
  matchResult = 0;
3059
- members_3 = heritageClause_1.fields[0].fields[0];
3302
+ members_5 = heritageClause_1.fields[0].fields[0];
3060
3303
  break;
3061
3304
  }
3062
3305
  case 5: {
3063
3306
  matchResult = 0;
3064
- members_3 = heritageClause_1.fields[0].fields[0];
3307
+ members_5 = heritageClause_1.fields[0].fields[0];
3065
3308
  break;
3066
3309
  }
3067
3310
  default:
@@ -3073,7 +3316,7 @@ function transformInterface(context, info) {
3073
3316
  }
3074
3317
  switch (matchResult) {
3075
3318
  case 0:
3076
- return TransformMembers_toFSharpMember(context_1, members_3);
3319
+ return TransformMembers_toFSharpMember(context_1, members_5);
3077
3320
  default:
3078
3321
  return empty();
3079
3322
  }
@@ -3209,7 +3452,7 @@ function transformInterface(context, info) {
3209
3452
  Equals: equals,
3210
3453
  GetHashCode: (x_2) => (safeHash(x_2) | 0),
3211
3454
  }), delay(() => {
3212
- let heritageClauses_1;
3455
+ let heritageClauses_2;
3213
3456
  const merged = collect((_arg_3) => {
3214
3457
  let matchResult_5, candidate_1;
3215
3458
  if (_arg_3.tag === 1) {
@@ -3231,8 +3474,8 @@ function transformInterface(context, info) {
3231
3474
  return empty();
3232
3475
  }
3233
3476
  }, TransformContext__get_TypeMemory(context_1));
3234
- heritageClauses_1 = (isEmpty(merged) ? info_1.HeritageClauses : merged);
3235
- if (!inheritsIterable(TransformContext__get_TypeMemory(context_1), heritageClauses_1)) {
3477
+ heritageClauses_2 = (isEmpty(merged) ? info_1.HeritageClauses : merged);
3478
+ if (!inheritsIterable(TransformContext__get_TypeMemory(context_1), heritageClauses_2)) {
3236
3479
  const matchValue_2 = TypeLiteral_tryFindIterableType(context_1, info_1.Members);
3237
3480
  if (matchValue_2 == null) {
3238
3481
  return empty_1();
@@ -3385,11 +3628,13 @@ function TypeParameterTransform_transformWith(withDefault, context, typeParamete
3385
3628
  return TransformResult_Create_403667D8(typeParameter.Name, default_);
3386
3629
  case 1: {
3387
3630
  const matchValue_1 = transformType(TransformContext__PushScope_27AED5E3(context, sanitizeTypeName(typeParameter.Name)), constraintType);
3388
- if (matchValue_1.tag === 11) {
3389
- return TransformResult_Create_403667D8(typeParameter.Name, default_, undefined, matchValue_1);
3390
- }
3391
- else {
3392
- return TransformResult_Create_403667D8(typeParameter.Name, default_, matchValue_1);
3631
+ switch (matchValue_1.tag) {
3632
+ case 11:
3633
+ return TransformResult_Create_403667D8(typeParameter.Name, default_, undefined, matchValue_1);
3634
+ case 18:
3635
+ return TransformResult_Create_403667D8(typeParameter.Name, default_);
3636
+ default:
3637
+ return TransformResult_Create_403667D8(typeParameter.Name, default_, matchValue_1);
3393
3638
  }
3394
3639
  }
3395
3640
  case 2:
@@ -3402,9 +3647,13 @@ function TypeParameterTransform_transformWith(withDefault, context, typeParamete
3402
3647
  matchResult_1 = 0;
3403
3648
  break;
3404
3649
  }
3650
+ case 18: {
3651
+ matchResult_1 = 1;
3652
+ break;
3653
+ }
3405
3654
  case 19:
3406
3655
  case 14: {
3407
- matchResult_1 = 2;
3656
+ matchResult_1 = 3;
3408
3657
  break;
3409
3658
  }
3410
3659
  case 11: {
@@ -3412,34 +3661,41 @@ function TypeParameterTransform_transformWith(withDefault, context, typeParamete
3412
3661
  matchResult_1 = 0;
3413
3662
  }
3414
3663
  else {
3415
- matchResult_1 = 2;
3664
+ matchResult_1 = 3;
3416
3665
  }
3417
3666
  break;
3418
3667
  }
3419
3668
  case 8: {
3420
- matchResult_1 = 1;
3421
- fsharpType_2 = matchValue_2;
3669
+ if (matchValue_2.fields[0].tag === 6) {
3670
+ matchResult_1 = 1;
3671
+ }
3672
+ else {
3673
+ matchResult_1 = 2;
3674
+ fsharpType_2 = matchValue_2;
3675
+ }
3422
3676
  break;
3423
3677
  }
3424
3678
  case 3: {
3425
- matchResult_1 = 1;
3679
+ matchResult_1 = 2;
3426
3680
  fsharpType_2 = matchValue_2;
3427
3681
  break;
3428
3682
  }
3429
3683
  case 1: {
3430
- matchResult_1 = 1;
3684
+ matchResult_1 = 2;
3431
3685
  fsharpType_2 = matchValue_2;
3432
3686
  break;
3433
3687
  }
3434
3688
  default:
3435
- matchResult_1 = 3;
3689
+ matchResult_1 = 4;
3436
3690
  }
3437
3691
  switch (matchResult_1) {
3438
3692
  case 0:
3439
3693
  return TransformResult_Create_403667D8(typeParameter.Name, default_);
3440
3694
  case 1:
3441
- return TransformResult_Create_403667D8(typeParameter.Name, default_, undefined, fsharpType_2);
3695
+ return TransformResult_Create_403667D8(typeParameter.Name, default_);
3442
3696
  case 2:
3697
+ return TransformResult_Create_403667D8(typeParameter.Name, default_, undefined, fsharpType_2);
3698
+ case 3:
3443
3699
  return TransformResult_Create_403667D8(typeParameter.Name, default_);
3444
3700
  default:
3445
3701
  return TransformResult_Create_403667D8(typeParameter.Name, default_);
@@ -3573,7 +3829,7 @@ function tryOptimizeUnionType(context, typeName, cases) {
3573
3829
  }
3574
3830
  }, aliasCases_1);
3575
3831
  if (forAll((option) => (option != null), resolved)) {
3576
- return collect(value_7, resolved);
3832
+ return collect(value_8, resolved);
3577
3833
  }
3578
3834
  else {
3579
3835
  return undefined;
@@ -3713,8 +3969,8 @@ function tryOptimizeUnionType(context, typeName, cases) {
3713
3969
  return singleton(case$);
3714
3970
  }
3715
3971
  }, cases_4) : cases_4)), forAll(isLiteral, withAliases) ? withAliases : flattenCasesWith(false, cases_5))));
3716
- const otherCases = patternInput[1];
3717
3972
  const flattenedCases = patternInput[0];
3973
+ const otherCases_1 = withoutAliasesOfSamePrimitive(context, patternInput[1]);
3718
3974
  const isStringEnumCompatible = (!isEmpty(flattenedCases) && exists((_arg_5) => {
3719
3975
  let matchResult_5;
3720
3976
  if (_arg_5.tag === 8) {
@@ -3808,7 +4064,7 @@ function tryOptimizeUnionType(context, typeName, cases) {
3808
4064
  const patternInput_1 = nextName(tupledArg[0]);
3809
4065
  const name_1 = patternInput_1[1];
3810
4066
  return [patternInput_1[0] + 1, cons(new FSharpUnionCase(/* Field */ 2, [name_1, transformType(TransformContext__PushScope_27AED5E3(TransformContext__PushScope_27AED5E3(context, "Cases"), name_1), caseType)]), tupledArg[1])];
3811
- }, [1, empty()], otherCases)[1]);
4067
+ }, [1, empty()], otherCases_1)[1]);
3812
4068
  };
3813
4069
  const literalCaseInfo = (literal_2) => {
3814
4070
  switch (literal_2.tag) {
@@ -3868,33 +4124,38 @@ function tryOptimizeUnionType(context, typeName, cases) {
3868
4124
  }), caseInfos)[0];
3869
4125
  let matchValue_3;
3870
4126
  const casesProperties = map((_arg_10) => {
3871
- if (_arg_10.tag === 22) {
3872
- const properties = map((_arg_11) => {
3873
- if (_arg_11.tag === 1) {
3874
- return _arg_11.fields[0];
4127
+ switch (_arg_10.tag) {
4128
+ case 22: {
4129
+ const properties = map((_arg_11) => {
4130
+ if (_arg_11.tag === 1) {
4131
+ return _arg_11.fields[0];
4132
+ }
4133
+ else {
4134
+ return undefined;
4135
+ }
4136
+ }, _arg_10.fields[0].Members);
4137
+ if (forAll((option_2) => (option_2 != null), properties)) {
4138
+ return choose((x_2) => x_2, properties);
3875
4139
  }
3876
4140
  else {
3877
4141
  return undefined;
3878
4142
  }
3879
- }, _arg_10.fields[0].Members);
3880
- if (forAll((option_2) => (option_2 != null), properties)) {
3881
- return choose((x_2) => x_2, properties);
3882
4143
  }
3883
- else {
4144
+ case 13:
4145
+ return tryAllProperties(TransformContext__get_TypeMemory(context), empty_3({
4146
+ Compare: (x_3, y_2) => (comparePrimitives(x_3, y_2) | 0),
4147
+ }), _arg_10.fields[0]);
4148
+ default:
3884
4149
  return undefined;
3885
- }
3886
- }
3887
- else {
3888
- return undefined;
3889
4150
  }
3890
- }, otherCases);
4151
+ }, otherCases_1);
3891
4152
  if ((isEmpty(flattenedCases) && (length(casesProperties) >= 2)) && forAll((option_3) => (option_3 != null), casesProperties)) {
3892
- const casesProperties_1 = choose((x_3) => x_3, casesProperties);
4153
+ const casesProperties_1 = choose((x_4) => x_4, casesProperties);
3893
4154
  matchValue_3 = tryPick((candidate_1) => {
3894
4155
  const tagValues = map((properties_1) => {
3895
- const option_5 = tryFind((property_1) => (property_1.Name === candidate_1.Name), properties_1);
3896
- if (option_5 != null) {
3897
- const property_2 = option_5;
4156
+ const option_7 = tryFind((property_1) => (property_1.Name === candidate_1.Name), properties_1);
4157
+ if (option_7 != null) {
4158
+ const property_2 = option_7;
3898
4159
  const matchValue_2 = property_2.Type;
3899
4160
  let matchResult_8, literal_6;
3900
4161
  if (matchValue_2.tag === 8) {
@@ -3938,20 +4199,70 @@ function tryOptimizeUnionType(context, typeName, cases) {
3938
4199
  }
3939
4200
  switch (matchResult_8) {
3940
4201
  case 0:
3941
- return literal_6;
3942
- default:
3943
- return undefined;
4202
+ return [literal_6, undefined];
4203
+ default: {
4204
+ let matchResult_9, typeReference_6;
4205
+ if (matchValue_2.tag === 13) {
4206
+ if (!property_2.IsOptional) {
4207
+ matchResult_9 = 0;
4208
+ typeReference_6 = matchValue_2.fields[0];
4209
+ }
4210
+ else {
4211
+ matchResult_9 = 1;
4212
+ }
4213
+ }
4214
+ else {
4215
+ matchResult_9 = 1;
4216
+ }
4217
+ switch (matchResult_9) {
4218
+ case 0: {
4219
+ const typeReference_4 = typeReference_6;
4220
+ const memberName = last(split(typeReference_4.FullName, ["."], undefined, 0));
4221
+ return tryPick((_arg_12) => {
4222
+ let enumMember_1;
4223
+ let matchResult_10, enumInfo_1;
4224
+ if (_arg_12.tag === 4) {
4225
+ if ((_arg_12.fields[0].Name === typeReference_4.Name) && (memberName !== typeReference_4.Name)) {
4226
+ matchResult_10 = 0;
4227
+ enumInfo_1 = _arg_12.fields[0];
4228
+ }
4229
+ else {
4230
+ matchResult_10 = 1;
4231
+ }
4232
+ }
4233
+ else {
4234
+ matchResult_10 = 1;
4235
+ }
4236
+ switch (matchResult_10) {
4237
+ case 0: {
4238
+ const option_5 = tryFind((enumMember) => (enumMember.Name === memberName), enumInfo_1.Members);
4239
+ if (option_5 != null) {
4240
+ return (enumMember_1 = option_5, [enumMember_1.Value, enumMember_1.Name]);
4241
+ }
4242
+ else {
4243
+ return undefined;
4244
+ }
4245
+ }
4246
+ default:
4247
+ return undefined;
4248
+ }
4249
+ }, TransformContext__get_TypeMemory(context));
4250
+ }
4251
+ default:
4252
+ return undefined;
4253
+ }
4254
+ }
3944
4255
  }
3945
4256
  }
3946
4257
  else {
3947
4258
  return undefined;
3948
4259
  }
3949
4260
  }, casesProperties_1);
3950
- if (forAll((option_6) => (option_6 != null), tagValues) && (length(List_distinct(tagValues, {
4261
+ if (forAll((option_8) => (option_8 != null), tagValues) && (length(List_distinct(tagValues, {
3951
4262
  Equals: equals,
3952
- GetHashCode: (x_4) => (structuralHash(x_4) | 0),
4263
+ GetHashCode: (x_5) => (structuralHash(x_5) | 0),
3953
4264
  })) === length(tagValues))) {
3954
- return [candidate_1.Name, zip(choose((x_5) => x_5, tagValues), casesProperties_1)];
4265
+ return [candidate_1.Name, zip(choose((x_6) => x_6, tagValues), casesProperties_1)];
3955
4266
  }
3956
4267
  else {
3957
4268
  return undefined;
@@ -3963,71 +4274,71 @@ function tryOptimizeUnionType(context, typeName, cases) {
3963
4274
  }
3964
4275
  if (matchValue_3 == null) {
3965
4276
  if (isStringEnumCompatible) {
3966
- const literalCases_1 = map((Item_2) => (new FSharpUnionCase(/* Named */ 0, [Item_2])), deduplicateCaseNames(List_distinct(map((_arg_13) => {
3967
- if (_arg_13.tag === 8) {
3968
- return literalCaseInfo(_arg_13.fields[0]);
4277
+ const literalCases_1 = map((Item_3) => (new FSharpUnionCase(/* Named */ 0, [Item_3])), deduplicateCaseNames(List_distinct(map((_arg_15) => {
4278
+ if (_arg_15.tag === 8) {
4279
+ return literalCaseInfo(_arg_15.fields[0]);
3969
4280
  }
3970
4281
  else {
3971
4282
  throw new Exception("Should not happen");
3972
4283
  }
3973
4284
  }, flattenedCases), {
3974
4285
  Equals: equals,
3975
- GetHashCode: (x_6) => (safeHash(x_6) | 0),
4286
+ GetHashCode: (x_7) => (safeHash(x_7) | 0),
3976
4287
  })));
3977
4288
  const fieldCases_1 = transformFieldCases(literalCases_1);
3978
4289
  return new FSharpType(/* Union */ 1, [new FSharpUnion(toList(delay(() => append_1(singleton_1(FSharpAttribute.RequireQualifiedAccess), delay(() => (isEmpty(fieldCases_1) ? singleton_1(new FSharpAttribute(/* StringEnum */ 12, [0])) : singleton_1(new FSharpAttribute(/* EraseWithCaseRules */ 7, [0]))))))), typeName, append(literalCases_1, fieldCases_1), false, empty(), empty(), empty())]);
3979
4290
  }
3980
- else if (isNumericOnly && !isEmpty(otherCases)) {
3981
- const literalCases_2 = List_distinct(map((value_3) => {
3982
- let matchResult_9, value_4;
3983
- if (value_3.tag === 8) {
3984
- if (value_3.fields[0].tag === 1) {
3985
- matchResult_9 = 0;
3986
- value_4 = value_3.fields[0].fields[0];
4291
+ else if (isNumericOnly && !isEmpty(otherCases_1)) {
4292
+ const literalCases_2 = List_distinct(map((value_4) => {
4293
+ let matchResult_11, value_5;
4294
+ if (value_4.tag === 8) {
4295
+ if (value_4.fields[0].tag === 1) {
4296
+ matchResult_11 = 0;
4297
+ value_5 = value_4.fields[0].fields[0];
3987
4298
  }
3988
4299
  else {
3989
- matchResult_9 = 1;
4300
+ matchResult_11 = 1;
3990
4301
  }
3991
4302
  }
3992
4303
  else {
3993
- matchResult_9 = 1;
4304
+ matchResult_11 = 1;
3994
4305
  }
3995
- switch (matchResult_9) {
4306
+ switch (matchResult_11) {
3996
4307
  case 0:
3997
- return new FSharpUnionCase(/* Named */ 0, [new FSharpUnionCaseNamed(singleton(new FSharpAttribute(/* CompiledValue */ 14, [new FSharpLiteral(/* Int */ 1, [value_4])])), `\`\`${value_4}\`\``)]);
4308
+ return new FSharpUnionCase(/* Named */ 0, [new FSharpUnionCaseNamed(singleton(new FSharpAttribute(/* CompiledValue */ 14, [new FSharpLiteral(/* Int */ 1, [value_5])])), `\`\`${value_5}\`\``)]);
3998
4309
  default:
3999
4310
  throw new Exception("Should not happen");
4000
4311
  }
4001
4312
  }, flattenedCases), {
4002
4313
  Equals: equals,
4003
- GetHashCode: (x_7) => (safeHash(x_7) | 0),
4314
+ GetHashCode: (x_8) => (safeHash(x_8) | 0),
4004
4315
  });
4005
4316
  return new FSharpType(/* Union */ 1, [new FSharpUnion(ofArray([FSharpAttribute.RequireQualifiedAccess, new FSharpAttribute(/* EraseWithCaseRules */ 7, [0])]), typeName, append(literalCases_2, transformFieldCases(literalCases_2)), false, empty(), empty(), empty())]);
4006
4317
  }
4007
4318
  else if (isNumericOnly) {
4008
- return new FSharpType(/* Enum */ 0, [new FSharpEnum(typeName, List_distinct(map((value_5) => {
4009
- let matchResult_10, value_6;
4010
- if (value_5.tag === 8) {
4011
- if (value_5.fields[0].tag === 1) {
4012
- matchResult_10 = 0;
4013
- value_6 = value_5.fields[0].fields[0];
4319
+ return new FSharpType(/* Enum */ 0, [new FSharpEnum(typeName, List_distinct(map((value_6) => {
4320
+ let matchResult_12, value_7;
4321
+ if (value_6.tag === 8) {
4322
+ if (value_6.fields[0].tag === 1) {
4323
+ matchResult_12 = 0;
4324
+ value_7 = value_6.fields[0].fields[0];
4014
4325
  }
4015
4326
  else {
4016
- matchResult_10 = 1;
4327
+ matchResult_12 = 1;
4017
4328
  }
4018
4329
  }
4019
4330
  else {
4020
- matchResult_10 = 1;
4331
+ matchResult_12 = 1;
4021
4332
  }
4022
- switch (matchResult_10) {
4333
+ switch (matchResult_12) {
4023
4334
  case 0:
4024
- return new FSharpEnumCase((value_6 < 0) ? (`_MINUS_${op_UnaryNegation_Int32(value_6)}`) : int32ToString(value_6), new FSharpLiteral(/* Int */ 1, [value_6]));
4335
+ return new FSharpEnumCase((value_7 < 0) ? (`_MINUS_${op_UnaryNegation_Int32(value_7)}`) : int32ToString(value_7), new FSharpLiteral(/* Int */ 1, [value_7]));
4025
4336
  default:
4026
4337
  throw new Exception("Should not happen");
4027
4338
  }
4028
4339
  }, flattenedCases), {
4029
4340
  Equals: equals,
4030
- GetHashCode: (x_8) => (safeHash(x_8) | 0),
4341
+ GetHashCode: (x_9) => (safeHash(x_9) | 0),
4031
4342
  }))]);
4032
4343
  }
4033
4344
  else {
@@ -4037,16 +4348,39 @@ function tryOptimizeUnionType(context, typeName, cases) {
4037
4348
  else {
4038
4349
  const taggedCases = matchValue_3[1];
4039
4350
  const tagName_1 = matchValue_3[0];
4040
- const cases_6 = map((tupledArg_1) => {
4041
- const caseInfo_2 = tupledArg_1[0];
4351
+ const cases_6 = map((tupledArg_2) => {
4352
+ const caseInfo_2 = tupledArg_2[0];
4042
4353
  const caseContext = TransformContext__PushScope_27AED5E3(TransformContext__PushScope_27AED5E3(context, "Cases"), trim(caseInfo_2.Name, "`"));
4043
4354
  return new FSharpUnionCase(/* NamedFields */ 3, [caseInfo_2, map((property_4) => {
4044
- let matchValue_4;
4355
+ let matchValue_5;
4045
4356
  const patternInput_2 = sanitizeNameAndPushScope(property_4.Name, caseContext);
4046
- return [patternInput_2[0], (matchValue_4 = transformType(patternInput_2[1], property_4.Type), (matchValue_4.tag === 3) ? matchValue_4 : (property_4.IsOptional ? (new FSharpType(/* Option */ 3, [matchValue_4])) : matchValue_4))];
4047
- }, filter((property_3) => (property_3.Name !== tagName_1), tupledArg_1[1][1]))]);
4048
- }, zip(deduplicateCaseNames(map((arg) => literalCaseInfo(arg[0]), taggedCases)), taggedCases));
4049
- return new FSharpType(/* Union */ 1, [new FSharpUnion(ofArray([FSharpAttribute.RequireQualifiedAccess, new FSharpAttribute(/* TypeScriptTaggedUnion */ 8, [removeSurroundingQuotes(tagName_1), 0])]), typeName, cases_6, false, empty(), empty(), empty())]);
4357
+ return [patternInput_2[0], (matchValue_5 = transformType(patternInput_2[1], property_4.Type), (matchValue_5.tag === 3) ? matchValue_5 : (property_4.IsOptional ? (new FSharpType(/* Option */ 3, [matchValue_5])) : matchValue_5))];
4358
+ }, filter((property_3) => (property_3.Name !== tagName_1), tupledArg_2[1][1]))]);
4359
+ }, zip(deduplicateCaseNames(map((arg) => {
4360
+ const tupledArg_1 = arg[0];
4361
+ const literal_7 = tupledArg_1[0];
4362
+ const enumMemberName = tupledArg_1[1];
4363
+ if (enumMemberName == null) {
4364
+ return literalCaseInfo(literal_7);
4365
+ }
4366
+ else if (literal_7.tag === 0) {
4367
+ const name_3 = enumMemberName;
4368
+ return new FSharpUnionCaseNamed(singleton(new FSharpAttribute(/* CompiledName */ 13, [removeSurroundingQuotes(literal_7.fields[0])])), sanitizeTypeName(name_3));
4369
+ }
4370
+ else {
4371
+ const name_4 = enumMemberName;
4372
+ return new FSharpUnionCaseNamed(literalCaseInfo(literal_7).Attributes, sanitizeTypeName(name_4));
4373
+ }
4374
+ }, taggedCases)), taggedCases));
4375
+ const interfaceCases = choose((_arg_14) => {
4376
+ if (_arg_14.tag === 13) {
4377
+ return transformType(context, _arg_14);
4378
+ }
4379
+ else {
4380
+ return undefined;
4381
+ }
4382
+ }, otherCases_1);
4383
+ return new FSharpType(/* Union */ 1, [new FSharpUnion(ofArray([FSharpAttribute.RequireQualifiedAccess, new FSharpAttribute(/* TypeScriptTaggedUnion */ 8, [removeSurroundingQuotes(tagName_1), 0])]), typeName, cases_6, false, empty(), empty(), (length(interfaceCases) === length(otherCases_1)) ? interfaceCases : empty())]);
4050
4384
  }
4051
4385
  }
4052
4386
 
@@ -4108,7 +4442,7 @@ function transformMappedTypeMembers(context, mappedType) {
4108
4442
  switch (matchValue.tag) {
4109
4443
  case 10: {
4110
4444
  switch (matchValue.fields[0].ObjectType.tag) {
4111
- case 30: {
4445
+ case 31: {
4112
4446
  if (matchValue.fields[0].ObjectType.fields[0].tag === 18) {
4113
4447
  matchResult = 0;
4114
4448
  glueTypes = matchValue.fields[0].ObjectType.fields[0].fields[0];
@@ -4219,7 +4553,7 @@ function aliasOf(scope, typ) {
4219
4553
  }
4220
4554
 
4221
4555
  function aliasInterfaceOf(scope, typeParameters, members, inheritance) {
4222
- return new FSharpType(/* Interface */ 5, [new FSharpInterface(ofArray([FSharpAttribute.AllowNullLiteral, FSharpAttribute.Interface]), scope.Name, empty(), scope.Declaration.Name, typeParameters, members, inheritance)]);
4556
+ return new FSharpType(/* Interface */ 5, [new FSharpInterface(ofArray([FSharpAttribute.AllowNullLiteral, FSharpAttribute.Interface]), scope.Name, scope.XmlDoc.XmlDoc, scope.Declaration.Name, typeParameters, members, inheritance)]);
4223
4557
  }
4224
4558
 
4225
4559
  function isSelfReferencingUnion(name, cases) {
@@ -4268,7 +4602,7 @@ function aliasOfUnion(scope, cases, unionType) {
4268
4602
  const isSelfReferencing = isSelfReferencingUnion(scope.Declaration.Name, cases_1);
4269
4603
  const erasedUnionOf = (others) => {
4270
4604
  const casesContext = TransformContext__PushScope_27AED5E3(context, "Cases");
4271
- const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(casesContext, `Case${index + 1}`), caseType), others), {
4605
+ const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(casesContext, `Case${index + 1}`), caseType), withoutAliasesOfSamePrimitive(context, others)), {
4272
4606
  Equals: equals,
4273
4607
  GetHashCode: (x) => (safeHash(x) | 0),
4274
4608
  });
@@ -4338,67 +4672,196 @@ function aliasOfUnion(scope, cases, unionType) {
4338
4672
  }
4339
4673
  }
4340
4674
 
4675
+ function tryAliasOfSelfReferencingArray(scope, glueType) {
4676
+ let cases_1;
4677
+ const elementCases = (glueType.tag === 14) ? ((glueType.fields[0].tag === 7) ? glueType.fields[0].fields[0].fields[0] : undefined) : ((glueType.tag === 31) ? ((glueType.fields[0].tag === 14) ? ((glueType.fields[0].fields[0].tag === 7) ? glueType.fields[0].fields[0].fields[0].fields[0] : undefined) : undefined) : ((glueType.tag === 13) ? ((glueType.fields[0].Name === "Array") ? (!isEmpty(glueType.fields[0].TypeArguments) ? ((head_1(glueType.fields[0].TypeArguments).tag === 7) ? (isEmpty(tail_1(glueType.fields[0].TypeArguments)) ? head_1(glueType.fields[0].TypeArguments).fields[0].fields[0] : undefined) : undefined) : undefined) : ((glueType.fields[0].Name === "ReadonlyArray") ? (!isEmpty(glueType.fields[0].TypeArguments) ? ((head_1(glueType.fields[0].TypeArguments).tag === 7) ? (isEmpty(tail_1(glueType.fields[0].TypeArguments)) ? head_1(glueType.fields[0].TypeArguments).fields[0].fields[0] : undefined) : undefined) : undefined) : undefined)) : undefined));
4678
+ let matchResult, cases_2;
4679
+ if (elementCases != null) {
4680
+ if ((cases_1 = elementCases, isEmpty(scope.TypeParameters.Value.TypeParameters) && isSelfReferencingUnion(scope.Declaration.Name, cases_1))) {
4681
+ matchResult = 0;
4682
+ cases_2 = elementCases;
4683
+ }
4684
+ else {
4685
+ matchResult = 1;
4686
+ }
4687
+ }
4688
+ else {
4689
+ matchResult = 1;
4690
+ }
4691
+ switch (matchResult) {
4692
+ case 0: {
4693
+ const context = scope.Context;
4694
+ const itemContext = TransformContext__PushScope_27AED5E3(context, "Item");
4695
+ const casesContext = TransformContext__PushScope_27AED5E3(itemContext, "Cases");
4696
+ TransformContext__ExposeType_Z1D58A540(itemContext, new FSharpType(/* Union */ 1, [erasedUnion("Item", empty(), List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(casesContext, `Case${index + 1}`), caseType), map(arrayAsInput, filter((arg) => !isNullish(arg), cases_2))), {
4697
+ Equals: equals,
4698
+ GetHashCode: (x) => (safeHash(x) | 0),
4699
+ }))]));
4700
+ const item = referenceToExposed(itemContext, "Item", empty());
4701
+ return aliasOf(scope, (glueType.tag === 14) ? (new FSharpType(/* ResizeArray */ 14, [item])) : ((TransformContext__ExposeReadonlyArray(context), new FSharpType(/* JSApi */ 19, [new FSharpJSApi(item)]))));
4702
+ }
4703
+ default:
4704
+ return undefined;
4705
+ }
4706
+ }
4707
+
4341
4708
  function aliasOfIndexedAccessType(scope, glueType) {
4709
+ let constraintInfo;
4342
4710
  const matchValue = glueType.IndexType;
4343
- let matchResult, interfaceInfo;
4711
+ const matchValue_1 = glueType.ObjectType;
4712
+ let matchResult, constraintInfo_1, indexed_1, interfaceInfo_3, name_1, valueName_1, fullName_2, interfaceInfo_4;
4344
4713
  if (matchValue.tag === 9) {
4345
4714
  if (matchValue.fields[0].tag === 1) {
4346
- matchResult = 0;
4347
- interfaceInfo = matchValue.fields[0].fields[0];
4715
+ switch (matchValue_1.tag) {
4716
+ case 28: {
4717
+ if (matchValue_1.fields[0].TypeParameter.Constraint != null) {
4718
+ if (matchValue_1.fields[0].TypeParameter.Constraint.tag === 9) {
4719
+ if (matchValue_1.fields[0].TypeParameter.Constraint.fields[0].tag === 1) {
4720
+ if (matchValue_1.fields[0].Type != null) {
4721
+ if (matchValue_1.fields[0].Type.tag === 16) {
4722
+ if ((constraintInfo = matchValue_1.fields[0].TypeParameter.Constraint.fields[0].fields[0], (matchValue_1.fields[0].TypeParameter.Name === matchValue_1.fields[0].Type.fields[0]) && (constraintInfo.FullName === matchValue.fields[0].fields[0].FullName))) {
4723
+ matchResult = 0;
4724
+ constraintInfo_1 = matchValue_1.fields[0].TypeParameter.Constraint.fields[0].fields[0];
4725
+ indexed_1 = matchValue.fields[0];
4726
+ interfaceInfo_3 = matchValue.fields[0].fields[0];
4727
+ name_1 = matchValue_1.fields[0].TypeParameter.Name;
4728
+ valueName_1 = matchValue_1.fields[0].Type.fields[0];
4729
+ }
4730
+ else {
4731
+ matchResult = 2;
4732
+ }
4733
+ }
4734
+ else {
4735
+ matchResult = 2;
4736
+ }
4737
+ }
4738
+ else {
4739
+ matchResult = 2;
4740
+ }
4741
+ }
4742
+ else {
4743
+ matchResult = 2;
4744
+ }
4745
+ }
4746
+ else {
4747
+ matchResult = 2;
4748
+ }
4749
+ }
4750
+ else {
4751
+ matchResult = 2;
4752
+ }
4753
+ break;
4754
+ }
4755
+ case 13: {
4756
+ if (matchValue_1.fields[0].FullName === matchValue.fields[0].fields[0].FullName) {
4757
+ matchResult = 1;
4758
+ fullName_2 = matchValue_1.fields[0].FullName;
4759
+ interfaceInfo_4 = matchValue.fields[0].fields[0];
4760
+ }
4761
+ else {
4762
+ matchResult = 2;
4763
+ }
4764
+ break;
4765
+ }
4766
+ case 1: {
4767
+ if (matchValue_1.fields[0].FullName === matchValue.fields[0].fields[0].FullName) {
4768
+ matchResult = 1;
4769
+ fullName_2 = matchValue_1.fields[0].FullName;
4770
+ interfaceInfo_4 = matchValue.fields[0].fields[0];
4771
+ }
4772
+ else {
4773
+ matchResult = 2;
4774
+ }
4775
+ break;
4776
+ }
4777
+ default:
4778
+ matchResult = 2;
4779
+ }
4348
4780
  }
4349
4781
  else {
4350
- matchResult = 1;
4782
+ matchResult = 2;
4351
4783
  }
4352
4784
  }
4353
4785
  else {
4354
- matchResult = 1;
4786
+ matchResult = 2;
4355
4787
  }
4356
4788
  switch (matchResult) {
4357
- case 0:
4358
- return aliasOf(scope, transformType(scope.Context, new GlueType(/* Union */ 7, [new GlueTypeUnion(List_distinct(collect((m) => {
4359
- let typ;
4789
+ case 0: {
4790
+ const matchValue_3 = TypeAliasDeclaration_transformKeyOf(scope.Context, scope.Declaration.Name, indexed_1);
4791
+ if (matchValue_3.tag === 10) {
4792
+ return aliasOf(scope, FSharpType.Object$);
4793
+ }
4794
+ else {
4795
+ return matchValue_3;
4796
+ }
4797
+ }
4798
+ case 1: {
4799
+ const _arg = List_distinct(collect((m) => {
4800
+ let typ_1;
4360
4801
  switch (m.tag) {
4361
4802
  case 1: {
4362
- typ = m.fields[0].Type;
4803
+ typ_1 = m.fields[0].Type;
4363
4804
  break;
4364
4805
  }
4365
4806
  case 2: {
4366
- typ = m.fields[0].Type;
4807
+ typ_1 = m.fields[0].Type;
4367
4808
  break;
4368
4809
  }
4369
4810
  case 3: {
4370
- typ = m.fields[0].ArgumentType;
4811
+ typ_1 = m.fields[0].ArgumentType;
4371
4812
  break;
4372
4813
  }
4373
4814
  case 4: {
4374
- typ = m.fields[0].Type;
4815
+ typ_1 = m.fields[0].Type;
4375
4816
  break;
4376
4817
  }
4377
4818
  case 7: {
4378
- typ = m.fields[0].Type;
4819
+ typ_1 = m.fields[0].Type;
4379
4820
  break;
4380
4821
  }
4381
4822
  case 6: {
4382
- typ = m.fields[0].Type;
4823
+ typ_1 = m.fields[0].Type;
4383
4824
  break;
4384
4825
  }
4385
4826
  case 5: {
4386
- typ = m.fields[0].Type;
4827
+ typ_1 = m.fields[0].Type;
4387
4828
  break;
4388
4829
  }
4389
4830
  default:
4390
- typ = m.fields[0].Type;
4831
+ typ_1 = m.fields[0].Type;
4391
4832
  }
4392
- if (typ.tag === 7) {
4393
- return typ.fields[0].fields[0];
4833
+ if (typ_1.tag === 7) {
4834
+ return typ_1.fields[0].fields[0];
4394
4835
  }
4395
4836
  else {
4396
- return singleton(typ);
4837
+ return singleton(typ_1);
4397
4838
  }
4398
- }, interfaceInfo.Members), {
4839
+ }, interfaceInfo_4.Members), {
4399
4840
  Equals: equals,
4400
4841
  GetHashCode: (x) => (safeHash(x) | 0),
4401
- }))])));
4842
+ });
4843
+ let matchResult_2, cases_1, cases_2;
4844
+ if (!isEmpty(_arg)) {
4845
+ if (!isEmpty(tail_1(_arg))) {
4846
+ matchResult_2 = 0;
4847
+ cases_1 = _arg;
4848
+ }
4849
+ else {
4850
+ matchResult_2 = 1;
4851
+ cases_2 = _arg;
4852
+ }
4853
+ }
4854
+ else {
4855
+ matchResult_2 = 1;
4856
+ cases_2 = _arg;
4857
+ }
4858
+ switch (matchResult_2) {
4859
+ case 0:
4860
+ return aliasOfUnion(scope, cases_1, new GlueType(/* Union */ 7, [new GlueTypeUnion(cases_1)]));
4861
+ default:
4862
+ return aliasOf(scope, transformType(scope.Context, new GlueType(/* Union */ 7, [new GlueTypeUnion(cases_2)])));
4863
+ }
4864
+ }
4402
4865
  default:
4403
4866
  return aliasOf(scope, FSharpType.Discard);
4404
4867
  }
@@ -4499,21 +4962,20 @@ function aliasOfFunctionType(scope, functionType) {
4499
4962
  const context = scope.Context;
4500
4963
  const ownDefaults = ownTypeParameterDefaults(functionType);
4501
4964
  const parameters = map((parameter) => GlueSubstitution_substituteParameter(ownDefaults, parameter), functionType.Parameters);
4502
- const returnType = GlueSubstitution_substitute(ownDefaults, functionType.Type);
4503
4965
  const declaredTypeParameters = scope.TypeParameters.Value.TypeParameters;
4504
- if (isLambdaSignature(parameters, empty(), declaredTypeParameters)) {
4505
- return aliasOf(scope, new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter_1) => transformParameter(context, parameter_1), parameters), transformCallbackReturnType(TransformContext__PushScope_27AED5E3(context, "ReturnType"), returnType))]));
4966
+ if (!exists((glueType) => !equals(replaceSelfReference(scope.Declaration.Name, glueType), glueType), cons(functionType.Type, map((_arg) => _arg.Type, parameters))) && isLambdaSignature(parameters, empty(), declaredTypeParameters)) {
4967
+ return aliasOf(scope, new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter_1) => transformParameter(context, parameter_1), parameters), transformOwnCallbackReturnType(TransformContext__PushScope_27AED5E3(context, "ReturnType"), ownDefaults, functionType.Type))]));
4506
4968
  }
4507
4969
  else {
4508
- return new FSharpType(/* Delegate */ 20, [new FSharpDelegate(scope.XmlDoc.XmlDoc, scope.Name, declaredTypeParameters, requiredBeforeParamArray(map((parameter_2) => transformParameter(context, parameter_2), parameters)), transformCallbackReturnType(TransformContext__PushScope_27AED5E3(context, "ReturnType"), returnType))]);
4970
+ return new FSharpType(/* Delegate */ 20, [new FSharpDelegate(scope.XmlDoc.XmlDoc, scope.Name, declaredTypeParameters, requiredBeforeParamArray(map((parameter_2) => transformParameter(context, parameter_2), parameters)), transformOwnCallbackReturnType(TransformContext__PushScope_27AED5E3(context, "ReturnType"), ownDefaults, functionType.Type))]);
4509
4971
  }
4510
4972
  }
4511
4973
 
4512
4974
  function aliasOfTypeLiteral(scope, typeLiteralInfo) {
4513
4975
  const context = scope.Context;
4514
4976
  const typeParameters = scope.TypeParameters.Value.TypeParameters;
4515
- const candidate = new GlueInterface(scope.Declaration.Documentation, scope.Declaration.FullName, scope.Declaration.Name, typeLiteralInfo.Members, scope.Declaration.TypeParameters, empty());
4516
- const creates = isCandidate(TransformContext__get_TypeMemory(context), candidate) ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(scope.Name, typeParameters)]), typeLiteralInfo.Members) : empty();
4977
+ const candidate = new GlueInterface(scope.Declaration.Documentation, scope.Declaration.FullName, scope.Declaration.Name, typeLiteralInfo.Members, isEmpty(collect(memberTypeParameterNames, typeLiteralInfo.Members)) ? empty() : scope.Declaration.TypeParameters, empty());
4978
+ const creates = isCandidate(TransformContext__get_TypeMemory(context), candidate) ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(scope.Name, typeParameters)]), typeLiteralInfo.Members) : dictionaryCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(scope.Name, typeParameters)]), typeLiteralInfo.Members);
4517
4979
  return aliasInterfaceOf(scope, typeParameters, append(TransformMembers_toFSharpMember(context, typeLiteralInfo.Members), creates), ofArray(toArray(TypeLiteral_tryFindIterableType(context, typeLiteralInfo.Members))));
4518
4980
  }
4519
4981
 
@@ -4565,317 +5027,273 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
4565
5027
  default:
4566
5028
  aliasType = replaceSelfReference(glueTypeAliasDeclaration.Name, glueType);
4567
5029
  }
4568
- let fsharpType;
4569
- let matchResult_1, cases_2, unionType, glueType_1, glueType_2, literalInfo, primitiveInfo, typeReference, glueType_3, utilityType, functionType, glueTypes, members_1, members_2, references, typeLiteralInfo, typeParameterInfo, mappedType, constructSignature, glueType_5, glueType_6;
4570
- switch (aliasType.tag) {
4571
- case 26: {
4572
- matchResult_1 = 5;
4573
- break;
4574
- }
4575
- case 24: {
4576
- matchResult_1 = 14;
4577
- break;
4578
- }
4579
- case 12:
4580
- case 31:
4581
- case 32:
4582
- case 33:
4583
- case 4:
4584
- case 1:
4585
- case 11:
4586
- case 5:
4587
- case 0:
4588
- case 6:
4589
- case 17:
4590
- case 2:
4591
- case 25:
4592
- case 19:
4593
- case 23: {
4594
- matchResult_1 = 20;
4595
- break;
4596
- }
4597
- case 9: {
4598
- matchResult_1 = 1;
4599
- glueType_1 = aliasType.fields[0];
4600
- break;
4601
- }
4602
- case 10: {
4603
- matchResult_1 = 2;
4604
- glueType_2 = aliasType.fields[0];
4605
- break;
4606
- }
4607
- case 8: {
4608
- matchResult_1 = 3;
4609
- literalInfo = aliasType.fields[0];
4610
- break;
4611
- }
4612
- case 3: {
4613
- matchResult_1 = 4;
4614
- primitiveInfo = aliasType.fields[0];
4615
- break;
4616
- }
4617
- case 13: {
4618
- matchResult_1 = 6;
4619
- typeReference = aliasType.fields[0];
4620
- break;
4621
- }
4622
- case 14: {
4623
- matchResult_1 = 7;
4624
- glueType_3 = aliasType.fields[0];
4625
- break;
4626
- }
4627
- case 27: {
4628
- matchResult_1 = 8;
4629
- utilityType = aliasType.fields[0];
4630
- break;
4631
- }
4632
- case 15: {
4633
- matchResult_1 = 9;
4634
- functionType = aliasType.fields[0];
4635
- break;
4636
- }
4637
- case 18: {
4638
- matchResult_1 = 10;
4639
- glueTypes = aliasType.fields[0];
4640
- break;
4641
- }
4642
- case 20: {
4643
- matchResult_1 = 11;
4644
- members_1 = aliasType.fields[0];
4645
- break;
4646
- }
4647
- case 21: {
4648
- matchResult_1 = 12;
4649
- members_2 = aliasType.fields[1];
4650
- references = aliasType.fields[0];
4651
- break;
4652
- }
4653
- case 22: {
4654
- matchResult_1 = 13;
4655
- typeLiteralInfo = aliasType.fields[0];
4656
- break;
4657
- }
4658
- case 16: {
4659
- matchResult_1 = 15;
4660
- typeParameterInfo = aliasType.fields[0];
4661
- break;
4662
- }
4663
- case 28: {
4664
- matchResult_1 = 16;
4665
- mappedType = aliasType.fields[0];
4666
- break;
4667
- }
4668
- case 29: {
4669
- matchResult_1 = 17;
4670
- constructSignature = aliasType.fields[0];
4671
- break;
4672
- }
4673
- case 30: {
4674
- if (aliasType.fields[0].tag === 14) {
4675
- matchResult_1 = 18;
4676
- glueType_5 = aliasType.fields[0];
4677
- }
4678
- else {
4679
- matchResult_1 = 19;
4680
- glueType_6 = aliasType.fields[0];
5030
+ let fsharpType_1;
5031
+ const matchValue_1 = tryAliasOfSelfReferencingArray(scope, glueTypeAliasDeclaration.Type);
5032
+ if (matchValue_1 == null) {
5033
+ const aliasType_1 = aliasType;
5034
+ let matchResult_1, cases_2, unionType, glueType_1, glueType_2, literalInfo, primitiveInfo, typeReference, glueType_3, utilityType, functionType, glueTypes, members_1, members_2, references, typeLiteralInfo, typeParameterInfo, mappedType, constructSignature, glueType_5, glueType_6;
5035
+ switch (aliasType_1.tag) {
5036
+ case 26: {
5037
+ matchResult_1 = 5;
5038
+ break;
4681
5039
  }
4682
- break;
4683
- }
4684
- default: {
4685
- matchResult_1 = 0;
4686
- cases_2 = aliasType.fields[0].fields[0];
4687
- unionType = aliasType;
4688
- }
4689
- }
4690
- switch (matchResult_1) {
4691
- case 0: {
4692
- fsharpType = aliasOfUnion(scope, cases_2, unionType);
4693
- break;
4694
- }
4695
- case 1: {
4696
- const matchValue_1 = TypeAliasDeclaration_transformKeyOf(context_1, glueTypeAliasDeclaration.Name, glueType_1);
4697
- fsharpType = ((matchValue_1.tag === 10) ? aliasOf(scope, FSharpType.Object$) : matchValue_1);
4698
- break;
4699
- }
4700
- case 2: {
4701
- fsharpType = aliasOfIndexedAccessType(scope, glueType_2);
4702
- break;
4703
- }
4704
- case 3: {
4705
- fsharpType = TypeAliasDeclaration_transformLiteral(scope.XmlDoc, typeAliasName, literalInfo);
4706
- break;
4707
- }
4708
- case 4: {
4709
- fsharpType = aliasOf(scope, new FSharpType(/* Primitive */ 8, [transformPrimitive(primitiveInfo)]));
4710
- break;
4711
- }
4712
- case 5: {
4713
- fsharpType = aliasOf(scope, new FSharpType(/* Primitive */ 8, [FSharpPrimitive.String$]));
4714
- break;
4715
- }
4716
- case 6: {
4717
- fsharpType = aliasOfTypeReference(scope, typeReference);
4718
- break;
4719
- }
4720
- case 7: {
4721
- fsharpType = aliasOf(scope, transformType(context_1, new GlueType(/* Array */ 14, [glueType_3])));
4722
- break;
4723
- }
4724
- case 8: {
4725
- fsharpType = aliasOfUtilityType(scope, utilityType);
4726
- break;
4727
- }
4728
- case 9: {
4729
- fsharpType = aliasOfFunctionType(scope, functionType);
4730
- break;
4731
- }
4732
- case 10: {
4733
- fsharpType = aliasOf(scope, transformTupleType(TransformContext__PushScope_27AED5E3(context_1, "Item"), glueTypes));
4734
- break;
4735
- }
4736
- case 11: {
4737
- fsharpType = aliasInterface(TransformMembers_toFSharpMember(context_1, members_1), empty());
4738
- break;
4739
- }
4740
- case 12: {
4741
- const matchValue_2 = inheritableBases(context_1, references);
4742
- fsharpType = (isEmpty(matchValue_2) ? aliasOf(scope, FSharpType.Object$) : aliasInterface(TransformMembers_toFSharpMember(context_1, members_2), map((glueType_4) => transformType(context_1, glueType_4), matchValue_2)));
4743
- break;
4744
- }
4745
- case 13: {
4746
- fsharpType = aliasOfTypeLiteral(scope, typeLiteralInfo);
4747
- break;
4748
- }
4749
- case 14: {
4750
- fsharpType = aliasOf(scope, FSharpType.Object$);
4751
- break;
4752
- }
4753
- case 15: {
4754
- fsharpType = aliasOf(scope, new FSharpType(/* TypeParameter */ 13, [typeParameterInfo]));
4755
- break;
4756
- }
4757
- case 16: {
4758
- fsharpType = aliasInterface(TransformMembers_toFSharpMember(context_1, transformMappedTypeMembers(context_1, mappedType)), empty());
4759
- break;
4760
- }
4761
- case 17: {
4762
- fsharpType = aliasOfConstructorType(scope, constructSignature);
4763
- break;
4764
- }
4765
- case 18: {
4766
- fsharpType = aliasOf(scope, transformReadOnlyModifier(context_1, glueType_5));
4767
- break;
4768
- }
4769
- case 19: {
4770
- fsharpType = aliasOf(scope, transformReadOnlyModifier(TransformContext__PushScope_27AED5E3(context_1, "Item"), glueType_6));
4771
- break;
4772
- }
4773
- default:
4774
- fsharpType = aliasOf(scope, FSharpType.Object$);
4775
- }
4776
- if (scope.TypeParameters.IsValueCreated) {
4777
- const typeParameters = scope.TypeParameters.Value.TypeParameters;
4778
- const defaultAliases = exposeSpecializedAlias(typeAliasName, empty(), empty(), reverse(typeParameters));
4779
- iterate((typ_8) => {
4780
- TransformContext__ExposeType_Z1D58A540(context_1, typ_8);
4781
- }, defaultAliases);
4782
- let option_1;
4783
- const typeParametersResult = scope.TypeParameters.Value;
4784
- option_1 = makeSealedTypeAlias(typeAliasName, aliasArities(typeParameters, defaultAliases), typeParametersResult);
4785
- if (option_1 != null) {
4786
- TransformContext__ExposeType_Z1D58A540(context_1, option_1);
4787
- }
4788
- }
4789
- return fsharpType;
4790
- }
4791
-
4792
- function ReExport_isExpressible(glueType_mut) {
4793
- ReExport_isExpressible:
4794
- while (true) {
4795
- const glueType = glueType_mut;
4796
- let matchResult, innerType;
4797
- switch (glueType.tag) {
4798
- case 13:
4799
- case 3:
4800
5040
  case 24: {
4801
- matchResult = 0;
5041
+ matchResult_1 = 14;
5042
+ break;
5043
+ }
5044
+ case 30: {
5045
+ matchResult_1 = 18;
5046
+ break;
5047
+ }
5048
+ case 12:
5049
+ case 32:
5050
+ case 33:
5051
+ case 34:
5052
+ case 4:
5053
+ case 1:
5054
+ case 11:
5055
+ case 5:
5056
+ case 0:
5057
+ case 6:
5058
+ case 17:
5059
+ case 2:
5060
+ case 25:
5061
+ case 19:
5062
+ case 23: {
5063
+ matchResult_1 = 21;
4802
5064
  break;
4803
5065
  }
4804
- case 7: {
4805
- matchResult = 2;
5066
+ case 9: {
5067
+ matchResult_1 = 1;
5068
+ glueType_1 = aliasType_1.fields[0];
4806
5069
  break;
4807
5070
  }
4808
- case 18: {
4809
- matchResult = 3;
5071
+ case 10: {
5072
+ matchResult_1 = 2;
5073
+ glueType_2 = aliasType_1.fields[0];
4810
5074
  break;
4811
5075
  }
4812
- case 30: {
4813
- matchResult = 1;
4814
- innerType = glueType.fields[0];
5076
+ case 8: {
5077
+ matchResult_1 = 3;
5078
+ literalInfo = aliasType_1.fields[0];
5079
+ break;
5080
+ }
5081
+ case 3: {
5082
+ matchResult_1 = 4;
5083
+ primitiveInfo = aliasType_1.fields[0];
5084
+ break;
5085
+ }
5086
+ case 13: {
5087
+ matchResult_1 = 6;
5088
+ typeReference = aliasType_1.fields[0];
4815
5089
  break;
4816
5090
  }
4817
5091
  case 14: {
4818
- matchResult = 1;
4819
- innerType = glueType.fields[0];
5092
+ matchResult_1 = 7;
5093
+ glueType_3 = aliasType_1.fields[0];
4820
5094
  break;
4821
5095
  }
4822
- case 23: {
4823
- matchResult = 1;
4824
- innerType = glueType.fields[0];
5096
+ case 27: {
5097
+ matchResult_1 = 8;
5098
+ utilityType = aliasType_1.fields[0];
4825
5099
  break;
4826
5100
  }
4827
- default:
4828
- matchResult = 4;
5101
+ case 15: {
5102
+ matchResult_1 = 9;
5103
+ functionType = aliasType_1.fields[0];
5104
+ break;
5105
+ }
5106
+ case 18: {
5107
+ matchResult_1 = 10;
5108
+ glueTypes = aliasType_1.fields[0];
5109
+ break;
5110
+ }
5111
+ case 20: {
5112
+ matchResult_1 = 11;
5113
+ members_1 = aliasType_1.fields[0];
5114
+ break;
5115
+ }
5116
+ case 21: {
5117
+ matchResult_1 = 12;
5118
+ members_2 = aliasType_1.fields[1];
5119
+ references = aliasType_1.fields[0];
5120
+ break;
5121
+ }
5122
+ case 22: {
5123
+ matchResult_1 = 13;
5124
+ typeLiteralInfo = aliasType_1.fields[0];
5125
+ break;
5126
+ }
5127
+ case 16: {
5128
+ matchResult_1 = 15;
5129
+ typeParameterInfo = aliasType_1.fields[0];
5130
+ break;
5131
+ }
5132
+ case 28: {
5133
+ matchResult_1 = 16;
5134
+ mappedType = aliasType_1.fields[0];
5135
+ break;
5136
+ }
5137
+ case 29: {
5138
+ matchResult_1 = 17;
5139
+ constructSignature = aliasType_1.fields[0];
5140
+ break;
5141
+ }
5142
+ case 31: {
5143
+ if (aliasType_1.fields[0].tag === 14) {
5144
+ matchResult_1 = 19;
5145
+ glueType_5 = aliasType_1.fields[0];
5146
+ }
5147
+ else {
5148
+ matchResult_1 = 20;
5149
+ glueType_6 = aliasType_1.fields[0];
5150
+ }
5151
+ break;
5152
+ }
5153
+ default: {
5154
+ matchResult_1 = 0;
5155
+ cases_2 = aliasType_1.fields[0].fields[0];
5156
+ unionType = aliasType_1;
5157
+ }
4829
5158
  }
4830
- switch (matchResult) {
4831
- case 0:
4832
- return true;
5159
+ switch (matchResult_1) {
5160
+ case 0: {
5161
+ fsharpType_1 = aliasOfUnion(scope, cases_2, unionType);
5162
+ break;
5163
+ }
4833
5164
  case 1: {
4834
- glueType_mut = innerType;
4835
- continue ReExport_isExpressible;
5165
+ const matchValue_3 = TypeAliasDeclaration_transformKeyOf(context_1, glueTypeAliasDeclaration.Name, glueType_1);
5166
+ fsharpType_1 = ((matchValue_3.tag === 10) ? aliasOf(scope, FSharpType.Object$) : matchValue_3);
5167
+ break;
5168
+ }
5169
+ case 2: {
5170
+ fsharpType_1 = aliasOfIndexedAccessType(scope, glueType_2);
5171
+ break;
5172
+ }
5173
+ case 3: {
5174
+ fsharpType_1 = TypeAliasDeclaration_transformLiteral(scope.XmlDoc, typeAliasName, literalInfo);
5175
+ break;
5176
+ }
5177
+ case 4: {
5178
+ fsharpType_1 = aliasOf(scope, new FSharpType(/* Primitive */ 8, [transformPrimitive(primitiveInfo)]));
5179
+ break;
5180
+ }
5181
+ case 5: {
5182
+ fsharpType_1 = aliasOf(scope, new FSharpType(/* Primitive */ 8, [FSharpPrimitive.String$]));
5183
+ break;
5184
+ }
5185
+ case 6: {
5186
+ fsharpType_1 = aliasOfTypeReference(scope, typeReference);
5187
+ break;
5188
+ }
5189
+ case 7: {
5190
+ fsharpType_1 = aliasOf(scope, transformType(context_1, new GlueType(/* Array */ 14, [glueType_3])));
5191
+ break;
5192
+ }
5193
+ case 8: {
5194
+ fsharpType_1 = aliasOfUtilityType(scope, utilityType);
5195
+ break;
5196
+ }
5197
+ case 9: {
5198
+ fsharpType_1 = aliasOfFunctionType(scope, functionType);
5199
+ break;
5200
+ }
5201
+ case 10: {
5202
+ fsharpType_1 = aliasOf(scope, transformTupleType(TransformContext__PushScope_27AED5E3(context_1, "Item"), glueTypes));
5203
+ break;
5204
+ }
5205
+ case 11: {
5206
+ fsharpType_1 = aliasInterface(TransformMembers_toFSharpMember(context_1, members_1), empty());
5207
+ break;
5208
+ }
5209
+ case 12: {
5210
+ const matchValue_4 = inheritableBases(context_1, references);
5211
+ fsharpType_1 = (isEmpty(matchValue_4) ? aliasOf(scope, FSharpType.Object$) : aliasInterface(TransformMembers_toFSharpMember(context_1, members_2), map((glueType_4) => transformType(context_1, glueType_4), matchValue_4)));
5212
+ break;
5213
+ }
5214
+ case 13: {
5215
+ fsharpType_1 = aliasOfTypeLiteral(scope, typeLiteralInfo);
5216
+ break;
5217
+ }
5218
+ case 14: {
5219
+ fsharpType_1 = aliasOf(scope, FSharpType.Object$);
5220
+ break;
5221
+ }
5222
+ case 15: {
5223
+ fsharpType_1 = aliasOf(scope, new FSharpType(/* TypeParameter */ 13, [typeParameterInfo]));
5224
+ break;
5225
+ }
5226
+ case 16: {
5227
+ fsharpType_1 = aliasInterface(TransformMembers_toFSharpMember(context_1, transformMappedTypeMembers(context_1, mappedType)), empty());
5228
+ break;
5229
+ }
5230
+ case 17: {
5231
+ fsharpType_1 = aliasOfConstructorType(scope, constructSignature);
5232
+ break;
5233
+ }
5234
+ case 18: {
5235
+ fsharpType_1 = aliasOf(scope, transformType(context_1, aliasType_1));
5236
+ break;
5237
+ }
5238
+ case 19: {
5239
+ fsharpType_1 = aliasOf(scope, transformReadOnlyModifier(context_1, glueType_5));
5240
+ break;
5241
+ }
5242
+ case 20: {
5243
+ fsharpType_1 = aliasOf(scope, transformReadOnlyModifier(TransformContext__PushScope_27AED5E3(context_1, "Item"), glueType_6));
5244
+ break;
4836
5245
  }
4837
- case 2:
4838
- return forAll(ReExport_isExpressible, glueType.fields[0].fields[0]);
4839
- case 3:
4840
- return forAll(ReExport_isExpressible, glueType.fields[0]);
4841
5246
  default:
4842
- return false;
5247
+ fsharpType_1 = aliasOf(scope, FSharpType.Object$);
5248
+ }
5249
+ }
5250
+ else {
5251
+ fsharpType_1 = matchValue_1;
5252
+ }
5253
+ if (scope.TypeParameters.IsValueCreated) {
5254
+ const typeParameters = scope.TypeParameters.Value.TypeParameters;
5255
+ const defaultAliases = exposeSpecializedAlias(typeAliasName, empty(), empty(), reverse(typeParameters));
5256
+ iterate((typ_9) => {
5257
+ TransformContext__ExposeType_Z1D58A540(context_1, typ_9);
5258
+ }, defaultAliases);
5259
+ let option_1;
5260
+ const typeParametersResult = scope.TypeParameters.Value;
5261
+ option_1 = makeSealedTypeAlias(typeAliasName, aliasArities(typeParameters, defaultAliases), typeParametersResult);
5262
+ if (option_1 != null) {
5263
+ TransformContext__ExposeType_Z1D58A540(context_1, option_1);
4843
5264
  }
4844
- break;
4845
5265
  }
5266
+ return fsharpType_1;
4846
5267
  }
4847
5268
 
4848
5269
  function ReExport_canForwardConstraints(typeParameters) {
4849
5270
  return forAll((typeParameter) => {
4850
5271
  const matchValue = typeParameter.Constraint;
4851
- let matchResult, constraintType;
5272
+ let matchResult;
4852
5273
  if (matchValue != null) {
4853
- switch (matchValue.tag) {
4854
- case 22:
4855
- case 20:
4856
- case 27:
4857
- case 28: {
4858
- matchResult = 0;
4859
- break;
4860
- }
4861
- default: {
4862
- matchResult = 1;
4863
- constraintType = matchValue;
4864
- }
5274
+ if (matchValue.tag === 9) {
5275
+ matchResult = 0;
5276
+ }
5277
+ else {
5278
+ matchResult = 1;
4865
5279
  }
4866
5280
  }
4867
5281
  else {
4868
- matchResult = 0;
5282
+ matchResult = 1;
4869
5283
  }
4870
5284
  switch (matchResult) {
4871
5285
  case 0:
4872
- return true;
5286
+ return false;
4873
5287
  default:
4874
- return ReExport_isExpressible(constraintType);
5288
+ return true;
4875
5289
  }
4876
5290
  }, typeParameters);
4877
5291
  }
4878
5292
 
5293
+ function ReExport_withoutConstraints(typeParameters) {
5294
+ return map((typeParameter) => (new GlueTypeParameter(typeParameter.Name, undefined, typeParameter.Default)), typeParameters);
5295
+ }
5296
+
4879
5297
  function transformReExport(context, reExport) {
4880
5298
  let declared;
4881
5299
  const matchValue = reExport.Declaration;
@@ -4913,7 +5331,7 @@ function transformReExport(context, reExport) {
4913
5331
  const typeParameters_1 = declared[1];
4914
5332
  const patternInput = sanitizeTypeNameAndPushScope(reExport.Name, context);
4915
5333
  const name = patternInput[0];
4916
- const typeParameters_2 = transformDeclarationTypeParameters(patternInput[1], typeParameters_1);
5334
+ const typeParameters_2 = transformDeclarationTypeParameters(patternInput[1], ReExport_withoutConstraints(typeParameters_1));
4917
5335
  return cons(new FSharpType(/* TypeAlias */ 9, [new FSharpTypeAlias(empty(), name, empty(), new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(sanitizeTypeName(originalName), originalName, reExport.ModulePath, map((_arg) => {
4918
5336
  if (_arg.tag === 0) {
4919
5337
  return _arg.fields[0];
@@ -4993,44 +5411,38 @@ function exposeSpecializedAlias(name_mut, acc_mut, tailedTypeParameters_mut, typ
4993
5411
  }
4994
5412
 
4995
5413
  function transformClassDeclaration(context, classDeclaration) {
4996
- let list_6, f2_1, context_2, members_3, members_2;
5414
+ let list_7, f2_1, context_2, members_4, members_3;
4997
5415
  const patternInput = sanitizeTypeNameAndPushScope(classDeclaration.Name, context);
4998
5416
  const name = patternInput[0];
4999
5417
  const context_1 = patternInput[1];
5418
+ if (TransformContext__get_State(context_1).ClassConstructors.has(classDeclaration.FullName)) {
5419
+ exposeClassConstructor(context_1, classDeclaration);
5420
+ }
5000
5421
  let classDeclaration_1;
5001
- const patternInput_1 = withoutRedeclaredBases(TransformContext__get_TypeMemory(context_1), classDeclaration.Members, classDeclaration.HeritageClauses);
5002
- classDeclaration_1 = (new GlueClassDeclaration(classDeclaration.Documentation, classDeclaration.FullName, classDeclaration.Name, classDeclaration.Constructors, patternInput_1[1], classDeclaration.TypeParameters, patternInput_1[0], classDeclaration.IsExported));
5422
+ const thisType = new GlueThisType(classDeclaration.Name, classDeclaration.TypeParameters);
5423
+ const patternInput_1 = withoutRedeclaredBases(TransformContext__get_TypeMemory(context_1), thisType, classDeclaration.Members, classDeclaration.HeritageClauses);
5424
+ const patternInput_2 = withoutConflictingInstantiations(TransformContext__get_TypeMemory(context_1), thisType, patternInput_1[1], patternInput_1[0]);
5425
+ const members_1 = patternInput_2[1];
5426
+ const heritageClauses_1 = patternInput_2[0];
5427
+ classDeclaration_1 = (new GlueClassDeclaration(classDeclaration.Documentation, classDeclaration.FullName, classDeclaration.Name, classDeclaration.Constructors, append(members_1, thisMembersOfBases(TransformContext__get_TypeMemory(context_1), thisType, members_1, heritageClauses_1)), classDeclaration.TypeParameters, heritageClauses_1, classDeclaration.IsExported));
5003
5428
  const typeParametersResult = transformDeclarationTypeParameters(context_1, classDeclaration_1.TypeParameters);
5004
- const patternInput_2 = partition((heritageClause_1) => {
5005
- if (heritageClause_1.tag === 13) {
5006
- const typeReference = heritageClause_1.fields[0];
5007
- if (typeReference.IsStandardLibrary) {
5008
- return typeReference.Name === "Error";
5009
- }
5010
- else {
5011
- return false;
5012
- }
5013
- }
5014
- else {
5015
- return false;
5016
- }
5017
- }, filter((arg) => !isSelfHeritage(classDeclaration_1.FullName, arg), classDeclaration_1.HeritageClauses));
5018
- const otherInheritance = patternInput_2[1];
5019
- const errorInheritance = patternInput_2[0];
5429
+ const patternInput_3 = partition(isErrorHeritage, filter((arg) => !isSelfHeritage(classDeclaration_1.FullName, arg), classDeclaration_1.HeritageClauses));
5430
+ const otherInheritance = patternInput_3[1];
5431
+ const errorInheritance = patternInput_3[0];
5020
5432
  const isErrorDerived = (visited, heritageClause_2) => {
5021
5433
  if (heritageClause_2.tag === 13) {
5022
- const typeReference_1 = heritageClause_2.fields[0];
5023
- if (typeReference_1.IsStandardLibrary && (typeReference_1.Name === "Error")) {
5434
+ const typeReference = heritageClause_2.fields[0];
5435
+ if (isErrorHeritage(heritageClause_2)) {
5024
5436
  return true;
5025
5437
  }
5026
- else if (!contains(typeReference_1.Name, visited, {
5438
+ else if (!contains(typeReference.Name, visited, {
5027
5439
  Equals: (x, y) => (x === y),
5028
5440
  GetHashCode: (x) => (stringHash(x) | 0),
5029
5441
  })) {
5030
5442
  return exists((_arg) => {
5031
5443
  let matchResult, info_1;
5032
5444
  if (_arg.tag === 12) {
5033
- if (_arg.fields[0].Name === typeReference_1.Name) {
5445
+ if (_arg.fields[0].Name === typeReference.Name) {
5034
5446
  matchResult = 0;
5035
5447
  info_1 = _arg.fields[0];
5036
5448
  }
@@ -5043,7 +5455,7 @@ function transformClassDeclaration(context, classDeclaration) {
5043
5455
  }
5044
5456
  switch (matchResult) {
5045
5457
  case 0:
5046
- return exists(curry2(isErrorDerived)(cons(typeReference_1.Name, visited)), info_1.HeritageClauses);
5458
+ return exists(curry2(isErrorDerived)(cons(typeReference.Name, visited)), info_1.HeritageClauses);
5047
5459
  default:
5048
5460
  return false;
5049
5461
  }
@@ -5058,14 +5470,14 @@ function transformClassDeclaration(context, classDeclaration) {
5058
5470
  }
5059
5471
  };
5060
5472
  const hasErrorInheritance = !isEmpty(errorInheritance) ? true : exists(curry2(isErrorDerived)(empty()), otherInheritance);
5061
- const inheritance = List_distinct(filter(isInheritableType, (list_6 = filter((_arg_1) => {
5473
+ const inheritance = List_distinct(filter(isInheritableType, (list_7 = filter((_arg_1) => {
5062
5474
  if (_arg_1.tag === 0) {
5063
5475
  return false;
5064
5476
  }
5065
5477
  else {
5066
5478
  return !isArrayHeritage(_arg_1);
5067
5479
  }
5068
- }, toList(delay(() => append_1(!isEmpty(errorInheritance) ? singleton_1(new GlueType(/* TypeReference */ 13, [new GlueTypeReference("Exception", "System.Exception", empty(), empty(), true)])) : empty_1(), delay(() => otherInheritance))))), map((f2_1 = ((context_2 = TransformContext__PushScope_27AED5E3(context_1, "Extends"), (glueType) => transformType(context_2, glueType))), (arg_1) => f2_1(TransformContext__ExposeTypeAlias_1CE4A880(context_1, arg_1))), list_6))), {
5480
+ }, toList(delay(() => append_1(!isEmpty(errorInheritance) ? singleton_1(new GlueType(/* TypeReference */ 13, [new GlueTypeReference("Exception", "System.Exception", empty(), empty(), true)])) : empty_1(), delay(() => (hasErrorInheritance ? filter(curry2(isErrorDerived)(empty()), otherInheritance) : otherInheritance)))))), map((f2_1 = ((context_2 = TransformContext__PushScope_27AED5E3(context_1, "Extends"), (glueType) => transformType(context_2, glueType))), (arg_1) => f2_1(TransformContext__ExposeTypeAlias_1CE4A880(context_1, arg_1))), list_7))), {
5069
5481
  Equals: equals,
5070
5482
  GetHashCode: (x_1) => (safeHash(x_1) | 0),
5071
5483
  });
@@ -5073,7 +5485,7 @@ function transformClassDeclaration(context, classDeclaration) {
5073
5485
  const defaultAliases = exposeSpecializedAlias(name, empty(), empty(), reverse(typeParametersResult.TypeParameters));
5074
5486
  specialiazedAlias = append(defaultAliases, ofArray(toArray(makeSealedTypeAlias(name, aliasArities(typeParametersResult.TypeParameters, defaultAliases), typeParametersResult))));
5075
5487
  const xmlDoc = transformComment(classDeclaration_1.Documentation);
5076
- return cons(new FSharpType(/* Interface */ 5, [new FSharpInterface(toList(delay(() => append_1(singleton_1(FSharpAttribute.AllowNullLiteral), delay(() => append_1(hasErrorInheritance ? append_1(singleton_1(FSharpAttribute.AbstractClass), delay(() => importAttribute(classDeclaration_1.Name, TransformContext__get_ImportSource(context_1)))) : singleton_1(FSharpAttribute.Interface), delay(() => xmlDoc.ObsoleteAttributes)))))), name, xmlDoc.XmlDoc, classDeclaration_1.Name, typeParametersResult.TypeParameters, TransformMembers_toFSharpMember(context_1, (members_3 = ((members_2 = withoutBaseClassProperties(TransformContext__get_TypeMemory(context_1), classDeclaration_1.HeritageClauses, classDeclaration_1.Members), asMethods(TransformContext__get_TypeMemory(context_1), members_2))), resolveMembers(TransformContext__get_State(context_1).Conditionals, members_3))), inheritance)]), specialiazedAlias);
5488
+ return cons(new FSharpType(/* Interface */ 5, [new FSharpInterface(toList(delay(() => append_1(singleton_1(FSharpAttribute.AllowNullLiteral), delay(() => append_1(hasErrorInheritance ? append_1(singleton_1(FSharpAttribute.AbstractClass), delay(() => importAttribute(classDeclaration_1.Name, TransformContext__get_ImportSource(context_1)))) : singleton_1(FSharpAttribute.Interface), delay(() => xmlDoc.ObsoleteAttributes)))))), name, xmlDoc.XmlDoc, classDeclaration_1.Name, typeParametersResult.TypeParameters, TransformMembers_toFSharpMember(context_1, (members_4 = ((members_3 = withoutBaseClassProperties(TransformContext__get_TypeMemory(context_1), classDeclaration_1.HeritageClauses, classDeclaration_1.Members), asMethods(TransformContext__get_TypeMemory(context_1), members_3))), resolveMembers(TransformContext__get_State(context_1).Conditionals, members_4))), inheritance)]), specialiazedAlias);
5077
5489
  }
5078
5490
 
5079
5491
  function keysMemberTransform(scope, memberName) {
@@ -5111,6 +5523,7 @@ function transformToFsharp(context, glueTypes) {
5111
5523
  let matchResult, interfaceInfo_1, interfaceInfo_2, enumInfo, typeAliasInfo, moduleInfo, fileModule, reExport, classInfo, exportedType;
5112
5524
  switch (_arg_1.tag) {
5113
5525
  case 29:
5526
+ case 30:
5114
5527
  case 28:
5115
5528
  case 15:
5116
5529
  case 16:
@@ -5132,8 +5545,8 @@ function transformToFsharp(context, glueTypes) {
5132
5545
  case 19:
5133
5546
  case 26:
5134
5547
  case 27:
5135
- case 30:
5136
- case 33:
5548
+ case 31:
5549
+ case 34:
5137
5550
  case 21:
5138
5551
  case 17: {
5139
5552
  matchResult = 9;
@@ -5154,12 +5567,12 @@ function transformToFsharp(context, glueTypes) {
5154
5567
  moduleInfo = _arg_1.fields[0];
5155
5568
  break;
5156
5569
  }
5157
- case 31: {
5570
+ case 32: {
5158
5571
  matchResult = 5;
5159
5572
  fileModule = _arg_1.fields[0];
5160
5573
  break;
5161
5574
  }
5162
- case 32: {
5575
+ case 33: {
5163
5576
  matchResult = 6;
5164
5577
  reExport = _arg_1.fields[0];
5165
5578
  break;
@@ -5195,7 +5608,7 @@ function transformToFsharp(context, glueTypes) {
5195
5608
  const matchValue = tryTransformCallableInterface(context, interfaceInfo_2);
5196
5609
  if (matchValue == null) {
5197
5610
  const fsharpInterface_1 = transformInterface(context, interfaceInfo_2);
5198
- return cons(new FSharpType(/* Interface */ 5, [fsharpInterface_1]), keysModuleOf(context, interfaceInfo_2, fsharpInterface_1));
5611
+ return cons(new FSharpType(/* Interface */ 5, [new FSharpInterface(fsharpInterface_1.Attributes, fsharpInterface_1.Name, fsharpInterface_1.XmlDoc, fsharpInterface_1.OriginalName, fsharpInterface_1.TypeParameters, append(fsharpInterface_1.Members, isEmpty(interfaceInfo_2.HeritageClauses) ? dictionaryCreateMembers(TransformContext__PushScope_27AED5E3(context, fsharpInterface_1.Name), new FSharpType(/* Mapped */ 7, [new FSharpMapped(fsharpInterface_1.Name, fsharpInterface_1.TypeParameters)]), interfaceInfo_2.Members) : empty()), fsharpInterface_1.Inheritance)]), keysModuleOf(context, interfaceInfo_2, fsharpInterface_1));
5199
5612
  }
5200
5613
  else {
5201
5614
  return singleton(matchValue);
@@ -5279,20 +5692,20 @@ function transformToFsharp(context, glueTypes) {
5279
5692
 
5280
5693
  function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource, isTopLevel, glueAst) {
5281
5694
  let exportEqualsNames, typeName, declaredNames;
5282
- const glueAst_2 = map((glueType_3) => {
5695
+ const glueAst_2 = map((glueType_5) => {
5283
5696
  let matchResult, info_5, name_3, info_6, name_4;
5284
- if (glueType_3.tag === 32) {
5285
- switch (glueType_3.fields[0].Declaration.tag) {
5697
+ if (glueType_5.tag === 33) {
5698
+ switch (glueType_5.fields[0].Declaration.tag) {
5286
5699
  case 6: {
5287
5700
  matchResult = 0;
5288
- info_5 = glueType_3.fields[0].Declaration.fields[0];
5289
- name_3 = glueType_3.fields[0].Name;
5701
+ info_5 = glueType_5.fields[0].Declaration.fields[0];
5702
+ name_3 = glueType_5.fields[0].Name;
5290
5703
  break;
5291
5704
  }
5292
5705
  case 2: {
5293
5706
  matchResult = 1;
5294
- info_6 = glueType_3.fields[0].Declaration.fields[0];
5295
- name_4 = glueType_3.fields[0].Name;
5707
+ info_6 = glueType_5.fields[0].Declaration.fields[0];
5708
+ name_4 = glueType_5.fields[0].Name;
5296
5709
  break;
5297
5710
  }
5298
5711
  default:
@@ -5308,23 +5721,45 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5308
5721
  case 1:
5309
5722
  return new GlueType(/* Variable */ 2, [new GlueVariable(info_6.Documentation, name_4, info_6.Type)]);
5310
5723
  default:
5311
- return glueType_3;
5724
+ return glueType_5;
5312
5725
  }
5313
- }, (exportEqualsNames = ofSeq_1(choose((_arg) => {
5314
- let matchResult_1, name;
5315
- if (_arg.tag === 25) {
5316
- if (_arg.fields[0].tag === 2) {
5726
+ }, collect((glueType_3) => {
5727
+ let matchResult_1, reExport, glueType_4;
5728
+ if (glueType_3.tag === 25) {
5729
+ if (glueType_3.fields[0].tag === 33) {
5317
5730
  matchResult_1 = 0;
5318
- name = _arg.fields[0].fields[0].Name;
5731
+ reExport = glueType_3.fields[0].fields[0];
5319
5732
  }
5320
5733
  else {
5321
5734
  matchResult_1 = 1;
5735
+ glueType_4 = glueType_3;
5322
5736
  }
5323
5737
  }
5324
5738
  else {
5325
5739
  matchResult_1 = 1;
5740
+ glueType_4 = glueType_3;
5326
5741
  }
5327
5742
  switch (matchResult_1) {
5743
+ case 0:
5744
+ return ofArray([new GlueType(/* ReExport */ 33, [reExport]), new GlueType(/* ExportDefault */ 25, [new GlueType(/* Variable */ 2, [new GlueVariable(empty(), reExport.Name, new GlueType(/* Primitive */ 3, [GluePrimitive.Any]))])])]);
5745
+ default:
5746
+ return singleton(glueType_4);
5747
+ }
5748
+ }, (exportEqualsNames = ofSeq_1(choose((_arg) => {
5749
+ let matchResult_2, name;
5750
+ if (_arg.tag === 25) {
5751
+ if (_arg.fields[0].tag === 2) {
5752
+ matchResult_2 = 0;
5753
+ name = _arg.fields[0].fields[0].Name;
5754
+ }
5755
+ else {
5756
+ matchResult_2 = 1;
5757
+ }
5758
+ }
5759
+ else {
5760
+ matchResult_2 = 1;
5761
+ }
5762
+ switch (matchResult_2) {
5328
5763
  case 0:
5329
5764
  return replace(name, "export=", "");
5330
5765
  default:
@@ -5344,30 +5779,30 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5344
5779
  return undefined;
5345
5780
  }
5346
5781
  }), (declaredNames = ofSeq_1(choose((_arg_1) => {
5347
- let matchResult_2, info_3, info_4, glueType_1;
5782
+ let matchResult_3, info_3, info_4, glueType_1;
5348
5783
  switch (_arg_1.tag) {
5349
5784
  case 12: {
5350
- matchResult_2 = 0;
5785
+ matchResult_3 = 0;
5351
5786
  info_3 = _arg_1.fields[0];
5352
5787
  break;
5353
5788
  }
5354
5789
  case 25: {
5355
5790
  if (_arg_1.fields[0].tag === 12) {
5356
- matchResult_2 = 1;
5791
+ matchResult_3 = 1;
5357
5792
  info_4 = _arg_1.fields[0].fields[0];
5358
5793
  }
5359
5794
  else {
5360
- matchResult_2 = 2;
5795
+ matchResult_3 = 2;
5361
5796
  glueType_1 = _arg_1;
5362
5797
  }
5363
5798
  break;
5364
5799
  }
5365
5800
  default: {
5366
- matchResult_2 = 2;
5801
+ matchResult_3 = 2;
5367
5802
  glueType_1 = _arg_1;
5368
5803
  }
5369
5804
  }
5370
- switch (matchResult_2) {
5805
+ switch (matchResult_3) {
5371
5806
  case 0:
5372
5807
  return info_3.Name;
5373
5808
  case 1:
@@ -5378,40 +5813,40 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5378
5813
  }, glueAst), {
5379
5814
  Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
5380
5815
  }), append(glueAst, collect((_arg_2) => {
5381
- let matchResult_3, moduleInfo_1;
5816
+ let matchResult_4, moduleInfo_1;
5382
5817
  if (_arg_2.tag === 11) {
5383
5818
  if (FSharpSet__Contains(exportEqualsNames, _arg_2.fields[0].Name)) {
5384
- matchResult_3 = 0;
5819
+ matchResult_4 = 0;
5385
5820
  moduleInfo_1 = _arg_2.fields[0];
5386
5821
  }
5387
5822
  else {
5388
- matchResult_3 = 1;
5823
+ matchResult_4 = 1;
5389
5824
  }
5390
5825
  }
5391
5826
  else {
5392
- matchResult_3 = 1;
5827
+ matchResult_4 = 1;
5393
5828
  }
5394
- switch (matchResult_3) {
5829
+ switch (matchResult_4) {
5395
5830
  case 0: {
5396
5831
  const modulePath = singleton(sanitizeTypeName(removeSurroundingQuotes(moduleInfo_1.Name) + (moduleInfo_1.IsTopLevel ? "_" : "")));
5397
5832
  return choose((glueType_2) => {
5398
5833
  const matchValue = typeName(glueType_2);
5399
- let matchResult_4, name_2;
5834
+ let matchResult_5, name_2;
5400
5835
  if (matchValue != null) {
5401
5836
  if (!FSharpSet__Contains(declaredNames, matchValue)) {
5402
- matchResult_4 = 0;
5837
+ matchResult_5 = 0;
5403
5838
  name_2 = matchValue;
5404
5839
  }
5405
5840
  else {
5406
- matchResult_4 = 1;
5841
+ matchResult_5 = 1;
5407
5842
  }
5408
5843
  }
5409
5844
  else {
5410
- matchResult_4 = 1;
5845
+ matchResult_5 = 1;
5411
5846
  }
5412
- switch (matchResult_4) {
5847
+ switch (matchResult_5) {
5413
5848
  case 0:
5414
- return new GlueType(/* ReExport */ 32, [new GlueReExport(name_2, glueType_2, modulePath)]);
5849
+ return new GlueType(/* ReExport */ 33, [new GlueReExport(name_2, glueType_2, modulePath)]);
5415
5850
  default:
5416
5851
  return undefined;
5417
5852
  }
@@ -5420,41 +5855,41 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5420
5855
  default:
5421
5856
  return empty();
5422
5857
  }
5423
- }, glueAst))))));
5424
- const reExportedClasses = choose((glueType_4) => {
5425
- let matchResult_5, info_8, name_6;
5426
- if (glueType_4.tag === 32) {
5427
- if (glueType_4.fields[0].Declaration.tag === 12) {
5428
- if (ReExport_canForwardConstraints(glueType_4.fields[0].Declaration.fields[0].TypeParameters)) {
5429
- matchResult_5 = 0;
5430
- info_8 = glueType_4.fields[0].Declaration.fields[0];
5431
- name_6 = glueType_4.fields[0].Name;
5858
+ }, glueAst)))))));
5859
+ const reExportedClasses = choose((glueType_6) => {
5860
+ let matchResult_6, info_8, name_6;
5861
+ if (glueType_6.tag === 33) {
5862
+ if (glueType_6.fields[0].Declaration.tag === 12) {
5863
+ if (ReExport_canForwardConstraints(glueType_6.fields[0].Declaration.fields[0].TypeParameters)) {
5864
+ matchResult_6 = 0;
5865
+ info_8 = glueType_6.fields[0].Declaration.fields[0];
5866
+ name_6 = glueType_6.fields[0].Name;
5432
5867
  }
5433
5868
  else {
5434
- matchResult_5 = 1;
5869
+ matchResult_6 = 1;
5435
5870
  }
5436
5871
  }
5437
5872
  else {
5438
- matchResult_5 = 1;
5873
+ matchResult_6 = 1;
5439
5874
  }
5440
5875
  }
5441
5876
  else {
5442
- matchResult_5 = 1;
5877
+ matchResult_6 = 1;
5443
5878
  }
5444
- switch (matchResult_5) {
5879
+ switch (matchResult_6) {
5445
5880
  case 0:
5446
5881
  return new GlueType(/* ClassDeclaration */ 12, [new GlueClassDeclaration(info_8.Documentation, info_8.FullName, name_6, info_8.Constructors, info_8.Members, info_8.TypeParameters, info_8.HeritageClauses, info_8.IsExported)]);
5447
5882
  default:
5448
5883
  return undefined;
5449
5884
  }
5450
5885
  }, glueAst_2);
5451
- const patternInput = partition((glueType_5) => {
5452
- switch (glueType_5.tag) {
5886
+ const patternInput = partition((glueType_7) => {
5887
+ switch (glueType_7.tag) {
5453
5888
  case 2:
5454
5889
  case 6:
5455
5890
  return true;
5456
5891
  case 25: {
5457
- const exportedType = glueType_5.fields[0];
5892
+ const exportedType = glueType_7.fields[0];
5458
5893
  switch (exportedType.tag) {
5459
5894
  case 2:
5460
5895
  case 6:
@@ -5474,28 +5909,28 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5474
5909
  return false;
5475
5910
  }
5476
5911
  else {
5477
- return exists((glueType_6) => {
5478
- switch (glueType_6.tag) {
5912
+ return exists((glueType_8) => {
5913
+ switch (glueType_8.tag) {
5479
5914
  case 12:
5480
5915
  case 2:
5481
5916
  case 6:
5482
5917
  return true;
5483
5918
  case 11:
5484
- return applyModuleDeclaration(glueType_6.fields[0]);
5919
+ return applyModuleDeclaration(glueType_8.fields[0]);
5485
5920
  default:
5486
5921
  return false;
5487
5922
  }
5488
5923
  }, info_9.Types);
5489
5924
  }
5490
5925
  };
5491
- classes = filter((glueType_7) => {
5492
- switch (glueType_7.tag) {
5926
+ classes = filter((glueType_9) => {
5927
+ switch (glueType_9.tag) {
5493
5928
  case 12:
5494
5929
  return true;
5495
5930
  case 2:
5496
5931
  return true;
5497
5932
  case 11: {
5498
- const info_11 = glueType_7.fields[0];
5933
+ const info_11 = glueType_9.fields[0];
5499
5934
  if (!info_11.IsGlobal && info_11.IsExported) {
5500
5935
  return applyModuleDeclaration(info_11);
5501
5936
  }
@@ -5504,7 +5939,7 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5504
5939
  }
5505
5940
  }
5506
5941
  case 25:
5507
- if (glueType_7.fields[0].tag === 12) {
5942
+ if (glueType_9.fields[0].tag === 12) {
5508
5943
  return true;
5509
5944
  }
5510
5945
  else {
@@ -5518,27 +5953,27 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5518
5953
  const rootTransformContext = TransformContext_$ctor_Z1635F75A(reporter, "", typeMemory, state, typeLiteralsMemory, importSource);
5519
5954
  let typeTestAttributes;
5520
5955
  const classDeclarations = choose((_arg_3) => {
5521
- let matchResult_6, info_12;
5956
+ let matchResult_7, info_12;
5522
5957
  switch (_arg_3.tag) {
5523
5958
  case 12: {
5524
- matchResult_6 = 0;
5959
+ matchResult_7 = 0;
5525
5960
  info_12 = _arg_3.fields[0];
5526
5961
  break;
5527
5962
  }
5528
5963
  case 25: {
5529
5964
  if (_arg_3.fields[0].tag === 12) {
5530
- matchResult_6 = 0;
5965
+ matchResult_7 = 0;
5531
5966
  info_12 = _arg_3.fields[0].fields[0];
5532
5967
  }
5533
5968
  else {
5534
- matchResult_6 = 1;
5969
+ matchResult_7 = 1;
5535
5970
  }
5536
5971
  break;
5537
5972
  }
5538
5973
  default:
5539
- matchResult_6 = 1;
5974
+ matchResult_7 = 1;
5540
5975
  }
5541
- switch (matchResult_6) {
5976
+ switch (matchResult_7) {
5542
5977
  case 0:
5543
5978
  return info_12;
5544
5979
  default:
@@ -5546,32 +5981,32 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5546
5981
  }
5547
5982
  }, glueAst_2);
5548
5983
  const defaultExported = ofSeq_1(choose((_arg_4) => {
5549
- let matchResult_7, info_14, name_8;
5984
+ let matchResult_8, info_14, name_8;
5550
5985
  if (_arg_4.tag === 25) {
5551
5986
  switch (_arg_4.fields[0].tag) {
5552
5987
  case 12: {
5553
- matchResult_7 = 0;
5988
+ matchResult_8 = 0;
5554
5989
  info_14 = _arg_4.fields[0].fields[0];
5555
5990
  break;
5556
5991
  }
5557
5992
  case 2: {
5558
5993
  if (exists((info_13) => (info_13.Name === _arg_4.fields[0].fields[0].Name), classDeclarations)) {
5559
- matchResult_7 = 1;
5994
+ matchResult_8 = 1;
5560
5995
  name_8 = _arg_4.fields[0].fields[0].Name;
5561
5996
  }
5562
5997
  else {
5563
- matchResult_7 = 2;
5998
+ matchResult_8 = 2;
5564
5999
  }
5565
6000
  break;
5566
6001
  }
5567
6002
  default:
5568
- matchResult_7 = 2;
6003
+ matchResult_8 = 2;
5569
6004
  }
5570
6005
  }
5571
6006
  else {
5572
- matchResult_7 = 2;
6007
+ matchResult_8 = 2;
5573
6008
  }
5574
- switch (matchResult_7) {
6009
+ switch (matchResult_8) {
5575
6010
  case 0:
5576
6011
  return info_14.Name;
5577
6012
  case 1:
@@ -5593,11 +6028,11 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5593
6028
  Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
5594
6029
  });
5595
6030
  const constructorVariables = ofSeq_1(choose((_arg_6) => {
5596
- let matchResult_8, name_10, members_1, name_11;
6031
+ let matchResult_9, name_10, members_1, name_11;
5597
6032
  if (_arg_6.tag === 2) {
5598
6033
  switch (_arg_6.fields[0].Type.tag) {
5599
6034
  case 29: {
5600
- matchResult_8 = 0;
6035
+ matchResult_9 = 0;
5601
6036
  name_10 = _arg_6.fields[0].Name;
5602
6037
  break;
5603
6038
  }
@@ -5610,23 +6045,23 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5610
6045
  return false;
5611
6046
  }
5612
6047
  }, _arg_6.fields[0].Type.fields[0].Members)) {
5613
- matchResult_8 = 1;
6048
+ matchResult_9 = 1;
5614
6049
  members_1 = _arg_6.fields[0].Type.fields[0].Members;
5615
6050
  name_11 = _arg_6.fields[0].Name;
5616
6051
  }
5617
6052
  else {
5618
- matchResult_8 = 2;
6053
+ matchResult_9 = 2;
5619
6054
  }
5620
6055
  break;
5621
6056
  }
5622
6057
  default:
5623
- matchResult_8 = 2;
6058
+ matchResult_9 = 2;
5624
6059
  }
5625
6060
  }
5626
6061
  else {
5627
- matchResult_8 = 2;
6062
+ matchResult_9 = 2;
5628
6063
  }
5629
- switch (matchResult_8) {
6064
+ switch (matchResult_9) {
5630
6065
  case 0:
5631
6066
  return name_10;
5632
6067
  case 1:
@@ -5639,7 +6074,7 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5639
6074
  });
5640
6075
  typeTestAttributes = ((name_12) => (!isTopLevel ? empty() : (FSharpSet__Contains(defaultExported, name_12) ? importDefaultAttribute(name_12, importSource) : ((FSharpSet__Contains(classes_1, name_12) ? true : FSharpSet__Contains(constructorVariables, name_12)) ? importAttribute(name_12, importSource) : empty()))));
5641
6076
  const rest_1 = map((_arg_9) => {
5642
- let matchResult_9, info_17, fsharpType;
6077
+ let matchResult_10, info_17, fsharpType;
5643
6078
  if (_arg_9.tag === 5) {
5644
6079
  if (!exists((_arg_8) => {
5645
6080
  switch (_arg_8.tag) {
@@ -5652,19 +6087,19 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5652
6087
  return false;
5653
6088
  }
5654
6089
  }, _arg_9.fields[0].Attributes)) {
5655
- matchResult_9 = 0;
6090
+ matchResult_10 = 0;
5656
6091
  info_17 = _arg_9.fields[0];
5657
6092
  }
5658
6093
  else {
5659
- matchResult_9 = 1;
6094
+ matchResult_10 = 1;
5660
6095
  fsharpType = _arg_9;
5661
6096
  }
5662
6097
  }
5663
6098
  else {
5664
- matchResult_9 = 1;
6099
+ matchResult_10 = 1;
5665
6100
  fsharpType = _arg_9;
5666
6101
  }
5667
- switch (matchResult_9) {
6102
+ switch (matchResult_10) {
5668
6103
  case 0: {
5669
6104
  const matchValue_1 = typeTestAttributes(info_17.OriginalName);
5670
6105
  if (isEmpty(matchValue_1)) {
@@ -5684,21 +6119,21 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
5684
6119
  }
5685
6120
  else {
5686
6121
  const matchValue_2 = transformExports(new Transforms(transformType, transformParameter, transformTypeParameters, TransformMembers_withDefaultedTypeParameterOverloadsOfFunction, TransformMembers_withDictionaryParameterOverloadsOfFunction), rootTransformContext, isTopLevel, exports_1);
5687
- let matchResult_10, exportsType;
6122
+ let matchResult_11, exportsType;
5688
6123
  if (matchValue_2.tag === 5) {
5689
6124
  if (isEmpty(matchValue_2.fields[0].Members)) {
5690
- matchResult_10 = 0;
6125
+ matchResult_11 = 0;
5691
6126
  }
5692
6127
  else {
5693
- matchResult_10 = 1;
6128
+ matchResult_11 = 1;
5694
6129
  exportsType = matchValue_2;
5695
6130
  }
5696
6131
  }
5697
6132
  else {
5698
- matchResult_10 = 1;
6133
+ matchResult_11 = 1;
5699
6134
  exportsType = matchValue_2;
5700
6135
  }
5701
- switch (matchResult_10) {
6136
+ switch (matchResult_11) {
5702
6137
  case 0: {
5703
6138
  exportsType_1 = undefined;
5704
6139
  break;