@glutinum/cli 1.0.0-beta.11 → 1.0.0-beta.12
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.
|
@@ -1011,6 +1011,18 @@ function printUnion(printer, unionInfo) {
|
|
|
1011
1011
|
Equals: (x, y) => (x === y),
|
|
1012
1012
|
GetHashCode: (x) => (stringHash(x) | 0),
|
|
1013
1013
|
}));
|
|
1014
|
+
iterate((_arg_2) => {
|
|
1015
|
+
if (_arg_2.tag === 2) {
|
|
1016
|
+
const caseName = _arg_2.fields[0];
|
|
1017
|
+
Printer__get_NewLine(printer);
|
|
1018
|
+
Printer__Write_Z721C83C5(printer, concat("/// Unchecked, the value as <c>", caseName, "</c> whatever case it holds"));
|
|
1019
|
+
Printer__get_NewLine(printer);
|
|
1020
|
+
Printer__Write_Z721C83C5(printer, "[<Emit(\"$0\")>]");
|
|
1021
|
+
Printer__get_NewLine(printer);
|
|
1022
|
+
Printer__Write_Z721C83C5(printer, `member _.As${caseName}: ${printType(_arg_2.fields[1])} = nativeOnly`);
|
|
1023
|
+
Printer__get_NewLine(printer);
|
|
1024
|
+
}
|
|
1025
|
+
}, unionInfo.Cases);
|
|
1014
1026
|
}
|
|
1015
1027
|
Printer__get_Unindent(printer);
|
|
1016
1028
|
}
|
|
@@ -8,15 +8,16 @@ import { SealedTypeInfo, TransformDeclarationTypeParametersResult, TransformType
|
|
|
8
8
|
import { FSharpModule, FSharpSingleErasedCaseUnion, FSharpJSApi, FSharpEnum, FSharpEnumCase, FSharpLiteral, FSharpUnionCaseNamed, FSharpClass, FSharpConstructor, FSharpExplicitField, FSharpMemberInfoBody, FSharpAccessibility, FSharpStaticMemberInfo, FSharpMember, FSharpMemberInfo, FSharpAccessor, FSharpParameter, FSharpThisType, FSharpPrimitive, FSharpTypeAlias, FSharpDelegate, FSharpFunctionType, FSharpTypeReference, FSharpUnion, FSharpUnionCase, FSharpTypeParameter, FSharpMapped, FSharpInterface, FSharpAttribute, FSharpType, FSharpType_$reflection } from "./FsharpAST.js";
|
|
9
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 { value as value_7,
|
|
12
|
-
import { zip, mapFold, tryPick, item, concat as concat_1, reverse, iterate, cons, foldBack, fold, sortBy, tryFind, ofSeq,
|
|
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";
|
|
13
13
|
import { aliasArities, membersNameUndeclaredTypeParameters, mentionsTypeParameter, ownTypeParameterDefaults, typeParameterNames as typeParameterNames_2, unconstrained, memberTypeParameterNames, typeArguments, declaredTypeParameters as declaredTypeParameters_1 } from "./Transformer/TypeParameters.js";
|
|
14
14
|
import { List_groupBy, List_distinct } from "../fable_modules/fable-library-js.5.21.0/Seq2.js";
|
|
15
|
-
import { uncurry2, curry2, Lazy,
|
|
16
|
-
import { replace,
|
|
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
|
+
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";
|
|
18
|
-
import {
|
|
18
|
+
import { contains as contains_1, last } from "../fable_modules/fable-library-js.5.21.0/Array.js";
|
|
19
19
|
import { removeSurroundingQuotes, sanitizeTypeNameWithResult, sanitizeTypeName } from "./Utils/Naming.js";
|
|
20
|
+
import { FSharpMap__TryFind, exists as exists_1, empty as empty_2, ofList as ofList_1, FSharpMap__ContainsKey, FSharpMap__get_Item, map as map_1 } from "../fable_modules/fable-library-js.5.21.0/Map.js";
|
|
20
21
|
import { map as map_2, append as append_1, empty as empty_1, singleton as singleton_1, delay, toList } from "../fable_modules/fable-library-js.5.21.0/Seq.js";
|
|
21
22
|
import { capitalizeFirstLetter } from "./Utils/String.js";
|
|
22
23
|
import { addToSet } from "../fable_modules/fable-library-js.5.21.0/MapUtil.js";
|
|
@@ -25,7 +26,6 @@ import { isMap, keysModule, isMapNamed, expandMembers as expandMembers_1 } from
|
|
|
25
26
|
import { defaultMaxOverloads, isNullish, tryCases, expandMembers as expandMembers_2 } from "./Transformer/UnionOverloads.js";
|
|
26
27
|
import { applyWith as applyWith_1, disambiguateOverloads, aliasesOf, parametersSignature, Aliases_get_Empty, distinctBySignature } from "./Merge.js";
|
|
27
28
|
import { min } from "../fable_modules/fable-library-js.5.21.0/Double.js";
|
|
28
|
-
import { contains as contains_1 } from "../fable_modules/fable-library-js.5.21.0/Array.js";
|
|
29
29
|
import { inheritsIterable, asMethods, tryCallableHeritage } from "./Transformer/CallableProperties.js";
|
|
30
30
|
import { withoutBaseClassProperties, withoutBasesOfBases, isInheritableType, isSelfHeritage, isArrayHeritage, isErrorHeritage, withoutRedeclaredBases } from "./Transformer/Heritage.js";
|
|
31
31
|
import { isCandidate, tryResolveMembers } from "./Transformer/ParamObjectCandidate.js";
|
|
@@ -714,8 +714,226 @@ function $007CRememberedTypeLiteral$007C_$007C(context, glueType) {
|
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
716
|
|
|
717
|
+
function caseNameOf(typ) {
|
|
718
|
+
let name_6;
|
|
719
|
+
const lastSegment = (name) => trim(last(split(name, ["."], undefined, 0)), "`");
|
|
720
|
+
let option_7;
|
|
721
|
+
let matchResult, elementType, typeReference, mappedInfo, name_2, elementType_1, innerType;
|
|
722
|
+
switch (typ.tag) {
|
|
723
|
+
case 8: {
|
|
724
|
+
switch (typ.fields[0].tag) {
|
|
725
|
+
case 1: {
|
|
726
|
+
matchResult = 1;
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
case 2: {
|
|
730
|
+
matchResult = 2;
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
case 5: {
|
|
734
|
+
matchResult = 3;
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
case 3: {
|
|
738
|
+
matchResult = 4;
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
case 4: {
|
|
742
|
+
matchResult = 5;
|
|
743
|
+
break;
|
|
744
|
+
}
|
|
745
|
+
case 7: {
|
|
746
|
+
matchResult = 6;
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
case 6: {
|
|
750
|
+
matchResult = 7;
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
default:
|
|
754
|
+
matchResult = 0;
|
|
755
|
+
}
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
758
|
+
case 18: {
|
|
759
|
+
matchResult = 8;
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
case 11: {
|
|
763
|
+
switch (typ.fields[0].Name) {
|
|
764
|
+
case "ResizeArray": {
|
|
765
|
+
if (!isEmpty(typ.fields[0].TypeArguments)) {
|
|
766
|
+
if (isEmpty(tail_1(typ.fields[0].TypeArguments))) {
|
|
767
|
+
matchResult = 9;
|
|
768
|
+
elementType = head_1(typ.fields[0].TypeArguments);
|
|
769
|
+
}
|
|
770
|
+
else {
|
|
771
|
+
matchResult = 10;
|
|
772
|
+
typeReference = typ.fields[0];
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
matchResult = 10;
|
|
777
|
+
typeReference = typ.fields[0];
|
|
778
|
+
}
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
781
|
+
case "ReadonlyArray": {
|
|
782
|
+
if (!isEmpty(typ.fields[0].TypeArguments)) {
|
|
783
|
+
if (isEmpty(tail_1(typ.fields[0].TypeArguments))) {
|
|
784
|
+
matchResult = 9;
|
|
785
|
+
elementType = head_1(typ.fields[0].TypeArguments);
|
|
786
|
+
}
|
|
787
|
+
else {
|
|
788
|
+
matchResult = 10;
|
|
789
|
+
typeReference = typ.fields[0];
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
else {
|
|
793
|
+
matchResult = 10;
|
|
794
|
+
typeReference = typ.fields[0];
|
|
795
|
+
}
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
default: {
|
|
799
|
+
matchResult = 10;
|
|
800
|
+
typeReference = typ.fields[0];
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
case 7: {
|
|
806
|
+
matchResult = 11;
|
|
807
|
+
mappedInfo = typ.fields[0];
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
case 13: {
|
|
811
|
+
matchResult = 12;
|
|
812
|
+
name_2 = typ.fields[0];
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
case 14: {
|
|
816
|
+
matchResult = 13;
|
|
817
|
+
elementType_1 = typ.fields[0];
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
case 19: {
|
|
821
|
+
matchResult = 13;
|
|
822
|
+
elementType_1 = typ.fields[0].fields[0];
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
case 3: {
|
|
826
|
+
matchResult = 14;
|
|
827
|
+
innerType = typ.fields[0];
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
830
|
+
case 16: {
|
|
831
|
+
matchResult = 15;
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
case 12: {
|
|
835
|
+
matchResult = 16;
|
|
836
|
+
break;
|
|
837
|
+
}
|
|
838
|
+
default:
|
|
839
|
+
matchResult = 17;
|
|
840
|
+
}
|
|
841
|
+
switch (matchResult) {
|
|
842
|
+
case 0: {
|
|
843
|
+
option_7 = "String";
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
846
|
+
case 1: {
|
|
847
|
+
option_7 = "Int";
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
850
|
+
case 2: {
|
|
851
|
+
option_7 = "Float";
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
case 3: {
|
|
855
|
+
option_7 = "Number";
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
case 4: {
|
|
859
|
+
option_7 = "Bool";
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
case 5: {
|
|
863
|
+
option_7 = "Unit";
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
case 6: {
|
|
867
|
+
option_7 = "BigInt";
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
case 7: {
|
|
871
|
+
option_7 = undefined;
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
case 8: {
|
|
875
|
+
option_7 = "Obj";
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
case 9: {
|
|
879
|
+
const option_1 = caseNameOf(elementType);
|
|
880
|
+
option_7 = ((option_1 != null) ? (option_1 + "Array") : undefined);
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
case 10: {
|
|
884
|
+
option_7 = lastSegment(typeReference.Name);
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
case 11: {
|
|
888
|
+
option_7 = lastSegment(mappedInfo.Name);
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
case 12: {
|
|
892
|
+
option_7 = trimStart(name_2, "\'");
|
|
893
|
+
break;
|
|
894
|
+
}
|
|
895
|
+
case 13: {
|
|
896
|
+
const option_3 = caseNameOf(elementType_1);
|
|
897
|
+
option_7 = ((option_3 != null) ? (option_3 + "Array") : undefined);
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
900
|
+
case 14: {
|
|
901
|
+
const option_5 = caseNameOf(innerType);
|
|
902
|
+
option_7 = ((option_5 != null) ? (option_5 + "Option") : undefined);
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
case 15: {
|
|
906
|
+
option_7 = "Function";
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
case 16: {
|
|
910
|
+
option_7 = "Tuple";
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
913
|
+
default:
|
|
914
|
+
option_7 = undefined;
|
|
915
|
+
}
|
|
916
|
+
if (option_7 != null) {
|
|
917
|
+
return (name_6 = sanitizeTypeName(option_7), name_6[0].toUpperCase() + substring(name_6, 1));
|
|
918
|
+
}
|
|
919
|
+
else {
|
|
920
|
+
return undefined;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
717
924
|
function erasedUnion(name, typeParameters, caseTypes) {
|
|
718
|
-
|
|
925
|
+
const names = map(caseNameOf, caseTypes);
|
|
926
|
+
return new FSharpUnion(ofArray([FSharpAttribute.RequireQualifiedAccess, FSharpAttribute.Erase]), name, map2((caseName, caseType) => (new FSharpUnionCase(/* Field */ 2, [caseName, caseType])), ((forAll((option) => (option != null), names) && (length(List_distinct(names, {
|
|
927
|
+
Equals: equals,
|
|
928
|
+
GetHashCode: (x) => (structuralHash(x) | 0),
|
|
929
|
+
})) === length(names))) && forAll((name_1) => {
|
|
930
|
+
if (!equals(name_1, "Tag")) {
|
|
931
|
+
return !equals(name_1, "Tags");
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
}, names)) ? map(value_7, names) : mapIndexed((index, _arg) => (`Case${index + 1}`), caseTypes), caseTypes), false, typeParameters, empty());
|
|
719
937
|
}
|
|
720
938
|
|
|
721
939
|
function referenceToExposed(context, name, typeParameterNames) {
|
|
@@ -4065,41 +4283,47 @@ function aliasOfUnion(scope, cases, unionType) {
|
|
|
4065
4283
|
const matchValue = tryOptimizeUnionType(context, scope.Name, cases_1);
|
|
4066
4284
|
if (matchValue == null) {
|
|
4067
4285
|
const matchValue_1 = partition(isNullable, cases_1);
|
|
4068
|
-
let matchResult_1, single,
|
|
4069
|
-
if (
|
|
4070
|
-
if (
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
single = head_1(matchValue_1[1]);
|
|
4074
|
-
}
|
|
4075
|
-
else if (length(matchValue_1[1]) > 9) {
|
|
4076
|
-
matchResult_1 = 1;
|
|
4077
|
-
others_4 = matchValue_1[1];
|
|
4078
|
-
}
|
|
4079
|
-
else {
|
|
4080
|
-
matchResult_1 = 2;
|
|
4081
|
-
}
|
|
4286
|
+
let matchResult_1, single, others_5, others_6;
|
|
4287
|
+
if (isEmpty(matchValue_1[0])) {
|
|
4288
|
+
if (length(matchValue_1[1]) > 1) {
|
|
4289
|
+
matchResult_1 = 1;
|
|
4290
|
+
others_5 = matchValue_1[1];
|
|
4082
4291
|
}
|
|
4083
4292
|
else if (length(matchValue_1[1]) > 9) {
|
|
4084
|
-
matchResult_1 =
|
|
4085
|
-
|
|
4293
|
+
matchResult_1 = 2;
|
|
4294
|
+
others_6 = matchValue_1[1];
|
|
4086
4295
|
}
|
|
4087
4296
|
else {
|
|
4297
|
+
matchResult_1 = 3;
|
|
4298
|
+
}
|
|
4299
|
+
}
|
|
4300
|
+
else if (!isEmpty(matchValue_1[1])) {
|
|
4301
|
+
if (isEmpty(tail_1(matchValue_1[1]))) {
|
|
4302
|
+
matchResult_1 = 0;
|
|
4303
|
+
single = head_1(matchValue_1[1]);
|
|
4304
|
+
}
|
|
4305
|
+
else if (length(matchValue_1[1]) > 9) {
|
|
4088
4306
|
matchResult_1 = 2;
|
|
4307
|
+
others_6 = matchValue_1[1];
|
|
4308
|
+
}
|
|
4309
|
+
else {
|
|
4310
|
+
matchResult_1 = 3;
|
|
4089
4311
|
}
|
|
4090
4312
|
}
|
|
4091
4313
|
else if (length(matchValue_1[1]) > 9) {
|
|
4092
|
-
matchResult_1 =
|
|
4093
|
-
|
|
4314
|
+
matchResult_1 = 2;
|
|
4315
|
+
others_6 = matchValue_1[1];
|
|
4094
4316
|
}
|
|
4095
4317
|
else {
|
|
4096
|
-
matchResult_1 =
|
|
4318
|
+
matchResult_1 = 3;
|
|
4097
4319
|
}
|
|
4098
4320
|
switch (matchResult_1) {
|
|
4099
4321
|
case 0:
|
|
4100
4322
|
return aliasOf(scope, new FSharpType(/* Option */ 3, [transformType(TransformContext__PushScope_27AED5E3(context, "Value"), single)]));
|
|
4101
4323
|
case 1:
|
|
4102
|
-
return erasedUnionOf(
|
|
4324
|
+
return erasedUnionOf(others_5);
|
|
4325
|
+
case 2:
|
|
4326
|
+
return erasedUnionOf(others_6);
|
|
4103
4327
|
default:
|
|
4104
4328
|
return aliasOf(scope, transformType(context, unionType));
|
|
4105
4329
|
}
|