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

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 +480 -205
  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 +4 -4
  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 +244 -29
  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 +114 -31
  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 +1062 -629
  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 +275 -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,12 +1,13 @@
1
1
 
2
- import { ofList as ofList_1, empty as empty_1, FSharpSet__Add, FSharpSet__Contains, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
3
- import { equals, comparePrimitives } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
4
- import { exists, take, forAll2, length, forAll, indexed as indexed_1, fold, head, tail, map, singleton, filter, empty, choose, append, collect, tryPick, isEmpty } from "../../fable_modules/fable-library-js.5.21.0/List.js";
5
- import { defaultArg } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
2
+ import { ofList, add, empty as empty_1, FSharpSet__Add, FSharpSet__Contains, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
3
+ import { equals, stringHash, comparePrimitives } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
4
+ import { exists, take, forAll2, length, indexed as indexed_1, fold, forAll, head, tail, map, singleton, filter, empty, choose, append, collect as collect_1, tryPick, ofArray, contains, isEmpty } from "../../fable_modules/fable-library-js.5.21.0/List.js";
5
+ import { value as value_1, defaultArg } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
6
6
  import { Record } from "../../fable_modules/fable-library-js.5.21.0/Types.js";
7
7
  import { GlueSubstitution_substitute, GlueSubstitution_substituteMember, GlueSubstitution_ofTypeArguments, GlueSubstitution_substituteParameter, GluePrimitive, GlueTypeReference, GlueTypeUnion, GlueType, GlueFunctionType, GlueParameter, GlueType_$reflection, GlueMember_$reflection, GlueTypeParameter_$reflection } from "../GlueAST.js";
8
8
  import { record_type, list_type } from "../../fable_modules/fable-library-js.5.21.0/Reflection.js";
9
- import { ofList } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
9
+ import { List_distinctBy } from "../../fable_modules/fable-library-js.5.21.0/Seq2.js";
10
+ import { add as add_1, ofList as ofList_1 } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
10
11
  import { max } from "../../fable_modules/fable-library-js.5.21.0/Double.js";
11
12
 
12
13
  const primitiveNames = ofSeq(["string", "float", "int", "bool", "obj", "unit", "bigint"], {
@@ -54,7 +55,10 @@ export function isErrorHeritage(heritageClause) {
54
55
  if (heritageClause.tag === 13) {
55
56
  const typeReference = heritageClause.fields[0];
56
57
  if (typeReference.IsStandardLibrary) {
57
- return typeReference.Name === "Error";
58
+ return contains(typeReference.Name, ofArray(["Error", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError"]), {
59
+ Equals: (x, y) => (x === y),
60
+ GetHashCode: (x) => (stringHash(x) | 0),
61
+ });
58
62
  }
59
63
  else {
60
64
  return false;
@@ -102,7 +106,7 @@ export function withoutBaseClassProperties(typeMemory, heritageClauses, members)
102
106
  moduleDeclaration = glueType.fields[0];
103
107
  break;
104
108
  }
105
- case 31: {
109
+ case 32: {
106
110
  matchResult = 2;
107
111
  fileModule = glueType.fields[0];
108
112
  break;
@@ -121,7 +125,7 @@ export function withoutBaseClassProperties(typeMemory, heritageClauses, members)
121
125
  return undefined;
122
126
  }
123
127
  }, glueTypes);
124
- const baseProperties = (visited, heritageClauses_1) => collect((heritageClause) => {
128
+ const baseProperties = (visited, heritageClauses_1) => collect_1((heritageClause) => {
125
129
  let option_1, baseClass;
126
130
  let matchResult_1, typeReference_1;
127
131
  if (heritageClause.tag === 13) {
@@ -179,7 +183,7 @@ function BaseDeclaration_$reflection() {
179
183
  }
180
184
 
181
185
  function declarations(glueTypes) {
182
- return collect((glueType) => {
186
+ return collect_1((glueType) => {
183
187
  switch (glueType.tag) {
184
188
  case 12: {
185
189
  const info = glueType.fields[0];
@@ -191,7 +195,7 @@ function declarations(glueTypes) {
191
195
  }
192
196
  case 11:
193
197
  return declarations(glueType.fields[0].Types);
194
- case 31:
198
+ case 32:
195
199
  return declarations(glueType.fields[0].Types);
196
200
  default:
197
201
  return empty();
@@ -204,13 +208,62 @@ function tryFindBase(typeMemory, typeReference) {
204
208
  const candidates = declarations(typeMemory);
205
209
  const found = map((tupledArg_2) => tupledArg_2[2], (typeReference.FullName !== "") ? filter((tupledArg) => (tupledArg[0] === typeReference.FullName), candidates) : ((matchValue = filter((tupledArg_1) => (tupledArg_1[1] === typeReference.Name), candidates), !isEmpty(matchValue) ? (isEmpty(tail(matchValue)) ? singleton(head(matchValue)) : empty()) : empty())));
206
210
  if (!isEmpty(found)) {
207
- return new BaseDeclaration(head(found).TypeParameters, collect((_arg_6) => _arg_6.Members, found), collect((_arg_7) => _arg_7.HeritageClauses, found));
211
+ return new BaseDeclaration(head(found).TypeParameters, collect_1((_arg_6) => _arg_6.Members, found), collect_1((_arg_7) => _arg_7.HeritageClauses, found));
208
212
  }
209
213
  else {
210
214
  return undefined;
211
215
  }
212
216
  }
213
217
 
218
+ export function tryAllProperties(typeMemory, visited, typeReference) {
219
+ if (!isEmpty(typeReference.TypeArguments) ? true : FSharpSet__Contains(visited, typeReference.FullName)) {
220
+ return undefined;
221
+ }
222
+ else {
223
+ let option_6;
224
+ const option_1 = tryFindBase(typeMemory, typeReference);
225
+ option_6 = ((option_1 != null) ? (isEmpty(option_1.TypeParameters) ? option_1 : undefined) : undefined);
226
+ if (option_6 != null) {
227
+ const declaration_1 = option_6;
228
+ const own = map((_arg) => {
229
+ if (_arg.tag === 1) {
230
+ return _arg.fields[0];
231
+ }
232
+ else {
233
+ return undefined;
234
+ }
235
+ }, declaration_1.Members);
236
+ const bases = map((_arg_1) => {
237
+ if (_arg_1.tag === 13) {
238
+ return tryAllProperties(typeMemory, add(typeReference.FullName, visited), _arg_1.fields[0]);
239
+ }
240
+ else {
241
+ return undefined;
242
+ }
243
+ }, declaration_1.HeritageClauses);
244
+ if (forAll((option_2) => (option_2 != null), own) && forAll((option_3) => (option_3 != null), bases)) {
245
+ const own_1 = List_distinctBy((_arg_2) => _arg_2.Name, choose((x) => x, own), {
246
+ Equals: (x_1, y) => (x_1 === y),
247
+ GetHashCode: (x_1) => (stringHash(x_1) | 0),
248
+ });
249
+ const ownNames = ofList(map((_arg_3) => _arg_3.Name, own_1), {
250
+ Compare: (x_2, y_1) => (comparePrimitives(x_2, y_1) | 0),
251
+ });
252
+ return append(List_distinctBy((_arg_4) => _arg_4.Name, filter((property_1) => !FSharpSet__Contains(ownNames, property_1.Name), collect_1(value_1, bases)), {
253
+ Equals: (x_3, y_2) => (x_3 === y_2),
254
+ GetHashCode: (x_3) => (stringHash(x_3) | 0),
255
+ }), own_1);
256
+ }
257
+ else {
258
+ return undefined;
259
+ }
260
+ }
261
+ else {
262
+ return undefined;
263
+ }
264
+ }
265
+ }
266
+
214
267
  /**
215
268
  * F# rejects an interface inherited twice with different type arguments (FS3360)
216
269
  */
@@ -327,8 +380,8 @@ function comparable(glueType) {
327
380
  return new GlueType(/* Union */ 7, [new GlueTypeUnion(map(comparable, glueType.fields[0].fields[0]))]);
328
381
  case 14:
329
382
  return new GlueType(/* Array */ 14, [comparable(glueType.fields[0])]);
330
- case 30:
331
- return new GlueType(/* ReadOnly */ 30, [comparable(glueType.fields[0])]);
383
+ case 31:
384
+ return new GlueType(/* ReadOnly */ 31, [comparable(glueType.fields[0])]);
332
385
  case 23:
333
386
  return new GlueType(/* OptionalType */ 23, [comparable(glueType.fields[0])]);
334
387
  case 18:
@@ -343,7 +396,7 @@ function comparable(glueType) {
343
396
  }
344
397
 
345
398
  function shape(typeParameters, parameters) {
346
- const substitutions = ofList(map((typeParameter) => [typeParameter.Name, defaultArg(typeParameter.Constraint, new GlueType(/* Primitive */ 3, [GluePrimitive.Any]))], typeParameters), {
399
+ const substitutions = ofList_1(map((typeParameter) => [typeParameter.Name, defaultArg(typeParameter.Constraint, new GlueType(/* Primitive */ 3, [GluePrimitive.Any]))], typeParameters), {
347
400
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
348
401
  });
349
402
  return map((parameter_1) => [comparable(parameter_1.Type), parameter_1.IsOptional, parameter_1.IsSpread], map((parameter) => GlueSubstitution_substituteParameter(substitutions, parameter), parameters));
@@ -432,8 +485,9 @@ function isSameKind(a, b) {
432
485
  * `class RecordService extends CrudService { getOne(id, options?: RecordOptions) }` has one
433
486
  * `getOne` in TypeScript, the subclass takes the base heritage and the members it does not redeclare
434
487
  */
435
- export function withoutRedeclaredBases(typeMemory, members, heritageClauses) {
488
+ export function withoutRedeclaredBases(typeMemory, thisType, members, heritageClauses) {
436
489
  const resolve = (visited, members_1, heritageClauses_1) => fold((tupledArg, heritageClause) => {
490
+ let substitutions_1;
437
491
  const members_2 = tupledArg[0];
438
492
  const kept = tupledArg[1];
439
493
  if (heritageClause.tag === 13) {
@@ -456,9 +510,9 @@ export function withoutRedeclaredBases(typeMemory, members, heritageClauses) {
456
510
  switch (matchResult) {
457
511
  case 0: {
458
512
  const substitutions = GlueSubstitution_ofTypeArguments(baseDeclaration_1.TypeParameters, typeReference.TypeArguments);
459
- const baseMembers = map((glueMember) => GlueSubstitution_substituteMember(substitutions, glueMember), baseDeclaration_1.Members);
513
+ const baseMembers = map((substitutions_1 = add_1("this", new GlueType(/* ThisType */ 17, [thisType]), substitutions), (glueMember) => GlueSubstitution_substituteMember(substitutions_1, glueMember)), baseDeclaration_1.Members);
460
514
  if (hasCollision(members_2, baseMembers)) {
461
- const names = ofList_1(choose(memberName, members_2), {
515
+ const names = ofList(choose(memberName, members_2), {
462
516
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
463
517
  });
464
518
  const copied = filter((baseMember) => {
@@ -492,3 +546,207 @@ export function withoutRedeclaredBases(typeMemory, members, heritageClauses) {
492
546
  return [patternInput_1[1], patternInput_1[0]];
493
547
  }
494
548
 
549
+ function mentionsThis(glueType_mut) {
550
+ mentionsThis:
551
+ while (true) {
552
+ const glueType = glueType_mut;
553
+ let matchResult, innerType;
554
+ switch (glueType.tag) {
555
+ case 17: {
556
+ matchResult = 0;
557
+ break;
558
+ }
559
+ case 13: {
560
+ matchResult = 1;
561
+ break;
562
+ }
563
+ case 7: {
564
+ matchResult = 2;
565
+ break;
566
+ }
567
+ case 14: {
568
+ matchResult = 3;
569
+ innerType = glueType.fields[0];
570
+ break;
571
+ }
572
+ case 31: {
573
+ matchResult = 3;
574
+ innerType = glueType.fields[0];
575
+ break;
576
+ }
577
+ case 23: {
578
+ matchResult = 3;
579
+ innerType = glueType.fields[0];
580
+ break;
581
+ }
582
+ case 18: {
583
+ matchResult = 4;
584
+ break;
585
+ }
586
+ case 15: {
587
+ matchResult = 5;
588
+ break;
589
+ }
590
+ default:
591
+ matchResult = 6;
592
+ }
593
+ switch (matchResult) {
594
+ case 0:
595
+ return true;
596
+ case 1:
597
+ return exists(mentionsThis, glueType.fields[0].TypeArguments);
598
+ case 2:
599
+ return exists(mentionsThis, glueType.fields[0].fields[0]);
600
+ case 3: {
601
+ glueType_mut = innerType;
602
+ continue mentionsThis;
603
+ }
604
+ case 4:
605
+ return exists(mentionsThis, glueType.fields[0]);
606
+ case 5: {
607
+ const functionType = glueType.fields[0];
608
+ if (mentionsThis(functionType.Type)) {
609
+ return true;
610
+ }
611
+ else {
612
+ return exists((parameter) => mentionsThis(parameter.Type), functionType.Parameters);
613
+ }
614
+ }
615
+ default:
616
+ return false;
617
+ }
618
+ break;
619
+ }
620
+ }
621
+
622
+ function nestsThis(glueType) {
623
+ let matchResult, glueType_1;
624
+ switch (glueType.tag) {
625
+ case 17: {
626
+ matchResult = 0;
627
+ break;
628
+ }
629
+ case 23: {
630
+ if (glueType.fields[0].tag === 17) {
631
+ matchResult = 0;
632
+ }
633
+ else {
634
+ matchResult = 1;
635
+ glueType_1 = glueType;
636
+ }
637
+ break;
638
+ }
639
+ default: {
640
+ matchResult = 1;
641
+ glueType_1 = glueType;
642
+ }
643
+ }
644
+ switch (matchResult) {
645
+ case 0:
646
+ return false;
647
+ default:
648
+ return mentionsThis(glueType_1);
649
+ }
650
+ }
651
+
652
+ function nestsThisInSignature(glueMember) {
653
+ const inSignature = (returnType, parameters) => {
654
+ if (nestsThis(returnType)) {
655
+ return true;
656
+ }
657
+ else {
658
+ return exists((parameter) => nestsThis(parameter.Type), parameters);
659
+ }
660
+ };
661
+ let matchResult, info_1, info_2;
662
+ switch (glueMember.tag) {
663
+ case 0: {
664
+ if (!glueMember.fields[0].IsStatic) {
665
+ matchResult = 0;
666
+ info_1 = glueMember.fields[0];
667
+ }
668
+ else {
669
+ matchResult = 2;
670
+ }
671
+ break;
672
+ }
673
+ case 6: {
674
+ matchResult = 1;
675
+ info_2 = glueMember.fields[0];
676
+ break;
677
+ }
678
+ default:
679
+ matchResult = 2;
680
+ }
681
+ switch (matchResult) {
682
+ case 0:
683
+ return inSignature(info_1.Type, info_1.Parameters);
684
+ case 1:
685
+ return inSignature(info_2.Type, info_2.Parameters);
686
+ default:
687
+ return false;
688
+ }
689
+ }
690
+
691
+ export function thisMembersOfBases(typeMemory, thisType, members, heritageClauses) {
692
+ const collect = (visited, heritageClauses_1) => collect_1((_arg) => {
693
+ if (_arg.tag === 13) {
694
+ const typeReference = _arg.fields[0];
695
+ const key = (typeReference.FullName !== "") ? typeReference.FullName : typeReference.Name;
696
+ const matchValue = tryFindBase(typeMemory, typeReference);
697
+ let matchResult, baseDeclaration_1;
698
+ if (matchValue != null) {
699
+ if (!FSharpSet__Contains(visited, key)) {
700
+ matchResult = 0;
701
+ baseDeclaration_1 = matchValue;
702
+ }
703
+ else {
704
+ matchResult = 1;
705
+ }
706
+ }
707
+ else {
708
+ matchResult = 1;
709
+ }
710
+ switch (matchResult) {
711
+ case 0: {
712
+ const substitutions = GlueSubstitution_ofTypeArguments(baseDeclaration_1.TypeParameters, typeReference.TypeArguments);
713
+ const withThis = add_1("this", new GlueType(/* ThisType */ 17, [thisType]), substitutions);
714
+ const ownMembers = map((glueMember_1) => GlueSubstitution_substituteMember(withThis, glueMember_1), filter(nestsThisInSignature, baseDeclaration_1.Members));
715
+ const baseClauses = map((glueType) => GlueSubstitution_substitute(substitutions, glueType), baseDeclaration_1.HeritageClauses);
716
+ return append(singleton(ownMembers), collect(FSharpSet__Add(visited, key), baseClauses));
717
+ }
718
+ default:
719
+ return empty();
720
+ }
721
+ }
722
+ else {
723
+ return empty();
724
+ }
725
+ }, heritageClauses_1);
726
+ return fold((tupledArg, levelMembers) => {
727
+ const taken = tupledArg[0];
728
+ const added = filter((glueMember_3) => {
729
+ const matchValue_1 = memberName(glueMember_3);
730
+ if (matchValue_1 == null) {
731
+ return false;
732
+ }
733
+ else {
734
+ return !FSharpSet__Contains(taken, matchValue_1);
735
+ }
736
+ }, levelMembers);
737
+ return [fold((taken_1, glueMember_4) => {
738
+ const matchValue_2 = memberName(glueMember_4);
739
+ if (matchValue_2 == null) {
740
+ return taken_1;
741
+ }
742
+ else {
743
+ return add(matchValue_2, taken_1);
744
+ }
745
+ }, taken, added), append(tupledArg[1], added)];
746
+ }, [ofList(choose(memberName, members), {
747
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
748
+ }), empty()], collect(empty_1({
749
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
750
+ }), heritageClauses))[1];
751
+ }
752
+
@@ -169,7 +169,7 @@ export function create(typeMemory) {
169
169
  info_7 = glueType.fields[0];
170
170
  break;
171
171
  }
172
- case 31: {
172
+ case 32: {
173
173
  matchResult_1 = 6;
174
174
  info_8 = glueType.fields[0];
175
175
  break;
@@ -231,7 +231,7 @@ export function create(typeMemory) {
231
231
  iterate(collectDeclared, glueType_1.fields[0].Types);
232
232
  break;
233
233
  }
234
- case 31: {
234
+ case 32: {
235
235
  iterate(collectDeclared, glueType_1.fields[0].Types);
236
236
  break;
237
237
  }
@@ -349,7 +349,7 @@ function substitute(state, name, map, glueType) {
349
349
  elementType = glueType.fields[0];
350
350
  break;
351
351
  }
352
- case 30: {
352
+ case 31: {
353
353
  matchResult = 6;
354
354
  innerType = glueType.fields[0];
355
355
  break;
@@ -386,7 +386,7 @@ function substitute(state, name, map, glueType) {
386
386
  case 5:
387
387
  return new GlueType(/* Array */ 14, [substitute_1(elementType)]);
388
388
  case 6:
389
- return new GlueType(/* ReadOnly */ 30, [substitute_1(innerType)]);
389
+ return new GlueType(/* ReadOnly */ 31, [substitute_1(innerType)]);
390
390
  case 7:
391
391
  return new GlueType(/* OptionalType */ 23, [substitute_1(innerType_1)]);
392
392
  case 8:
@@ -1,14 +1,14 @@
1
1
 
2
2
  import { substring } from "../../fable_modules/fable-library-js.5.21.0/String.js";
3
- import { length, collect, filter, choose, empty, append, forAll, exists, tail, head, isEmpty, map, fold, tryPick } from "../../fable_modules/fable-library-js.5.21.0/List.js";
3
+ import { collect, length, contains as contains_1, filter, choose, empty, append, forAll, exists, tail, head, isEmpty, map, fold, tryPick } from "../../fable_modules/fable-library-js.5.21.0/List.js";
4
4
  import { FSharpSet__Contains, empty as empty_1, ofList, add, contains } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
5
- import { safeHash, equals, comparePrimitives, curry2 } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
6
- import { GluePrimitive, GlueSubstitution_substituteMember, GlueTypeUnion, GlueTypeReference, GlueType, GlueSubstitution_substitute, GlueSubstitution_ofTypeArguments, GlueMember, GlueProperty } from "../GlueAST.js";
5
+ import { Lazy, stringHash, safeHash, equals, comparePrimitives, curry2 } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
6
+ import { GluePrimitive, GlueAccessor, GlueFunctionType, GlueTypeParameter, GlueSubstitution_substituteMember, GlueTypeUnion, GlueTypeReference, GlueType, GlueSubstitution_substitute, GlueSubstitution_ofTypeArguments, GlueMember, GlueProperty } from "../GlueAST.js";
7
7
  import { List_distinct, List_distinctBy } from "../../fable_modules/fable-library-js.5.21.0/Seq2.js";
8
8
  import { FSharpChoice$2 } from "../../fable_modules/fable-library-js.5.21.0/Choice.js";
9
- import { isUnionCaseName } from "./Utils.js";
10
9
  import { memberTypeParameterNames } from "./TypeParameters.js";
11
10
  import { defaultArg } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
11
+ import { isUnionCaseName } from "./Utils.js";
12
12
 
13
13
  function containerOf(fullName) {
14
14
  let unquoted;
@@ -241,7 +241,7 @@ export function tryResolveMembers(typeMemory, info) {
241
241
  innerType_1 = glueType_3.fields[0];
242
242
  break;
243
243
  }
244
- case 30: {
244
+ case 31: {
245
245
  matchResult_4 = 2;
246
246
  innerType_1 = glueType_3.fields[0];
247
247
  break;
@@ -381,27 +381,88 @@ export function tryResolveMembers(typeMemory, info) {
381
381
  }), info);
382
382
  }
383
383
 
384
+ export function methodAsProperty(glueMember) {
385
+ let matchResult, info_1, glueMember_1;
386
+ if (glueMember.tag === 6) {
387
+ if (isEmpty(glueMember.fields[0].TypeParameters)) {
388
+ matchResult = 0;
389
+ info_1 = glueMember.fields[0];
390
+ }
391
+ else {
392
+ matchResult = 1;
393
+ glueMember_1 = glueMember;
394
+ }
395
+ }
396
+ else {
397
+ matchResult = 1;
398
+ glueMember_1 = glueMember;
399
+ }
400
+ switch (matchResult) {
401
+ case 0:
402
+ return new GlueMember(/* Property */ 1, [new GlueProperty(info_1.Name, info_1.Documentation, new GlueType(/* FunctionType */ 15, [new GlueFunctionType(empty(), info_1.Type, map((name) => (new GlueTypeParameter(name, undefined, undefined)), List_distinct(memberTypeParameterNames(glueMember), {
403
+ Equals: (x, y) => (x === y),
404
+ GetHashCode: (x) => (stringHash(x) | 0),
405
+ })), empty(), info_1.Parameters)]), false, info_1.IsOptional, GlueAccessor.ReadWrite, false)]);
406
+ default:
407
+ return glueMember_1;
408
+ }
409
+ }
410
+
384
411
  export function isCandidate(typeMemory, info) {
385
412
  const members = tryResolveMembers(typeMemory, info);
413
+ const inherits = (heritageClauses) => exists((_arg) => {
414
+ if (_arg.tag === 13) {
415
+ return _arg.fields[0].FullName === info.FullName;
416
+ }
417
+ else {
418
+ return false;
419
+ }
420
+ }, heritageClauses);
421
+ const isPlatformObject = new Lazy(() => (exists((_arg_1) => {
422
+ switch (_arg_1.tag) {
423
+ case 2:
424
+ return _arg_1.fields[0].Name === info.Name;
425
+ case 12: {
426
+ const classInfo = _arg_1.fields[0];
427
+ if (classInfo.Name === info.Name) {
428
+ return true;
429
+ }
430
+ else {
431
+ return inherits(classInfo.HeritageClauses);
432
+ }
433
+ }
434
+ case 1:
435
+ return inherits(_arg_1.fields[0].HeritageClauses);
436
+ default:
437
+ return false;
438
+ }
439
+ }, typeMemory) ? true : exists((_arg_2) => {
440
+ if (_arg_2.tag === 1) {
441
+ return !equals(_arg_2.fields[0].Accessor, GlueAccessor.ReadWrite);
442
+ }
443
+ else {
444
+ return false;
445
+ }
446
+ }, defaultArg(members, info.Members))));
386
447
  let hasOnlyProperties;
387
448
  if (members == null) {
388
449
  hasOnlyProperties = false;
389
450
  }
390
451
  else {
391
- const members_1 = members;
392
- hasOnlyProperties = (exists((_arg) => {
393
- if (_arg.tag === 1) {
452
+ const members_2 = members;
453
+ hasOnlyProperties = (exists((_arg_4) => {
454
+ if (_arg_4.tag === 1) {
394
455
  return true;
395
456
  }
396
457
  else {
397
458
  return false;
398
459
  }
399
- }, members_1) && forAll((_arg_1) => {
400
- switch (_arg_1.tag) {
460
+ }, members_2) && forAll((_arg_5) => {
461
+ switch (_arg_5.tag) {
401
462
  case 1:
402
- return !isUnionCaseName(_arg_1.fields[0].Name);
463
+ return !isUnionCaseName(_arg_5.fields[0].Name);
403
464
  case 5: {
404
- const indexSignature = _arg_1.fields[0];
465
+ const indexSignature = _arg_5.fields[0];
405
466
  if (!indexSignature.IsReadOnly) {
406
467
  return forAll((parameter) => equals(parameter.Type, new GlueType(/* Primitive */ 3, [GluePrimitive.String$])), indexSignature.Parameters);
407
468
  }
@@ -409,14 +470,39 @@ export function isCandidate(typeMemory, info) {
409
470
  return false;
410
471
  }
411
472
  }
473
+ case 6: {
474
+ const info_1 = _arg_5.fields[0];
475
+ if (!isUnionCaseName(info_1.Name)) {
476
+ const signature = info_1;
477
+ if ((((!isPlatformObject.Value && contains_1(new GlueMember(/* MethodSignature */ 6, [signature]), info.Members, {
478
+ Equals: equals,
479
+ GetHashCode: (x) => (safeHash(x) | 0),
480
+ })) && isEmpty(signature.TypeParameters)) && !signature.Name.startsWith("[")) && !(signature.Type.tag === 17)) {
481
+ return length(filter((_arg_3) => {
482
+ if (_arg_3.tag === 6) {
483
+ return _arg_3.fields[0].Name === signature.Name;
484
+ }
485
+ else {
486
+ return false;
487
+ }
488
+ }, members_2)) === 1;
489
+ }
490
+ else {
491
+ return false;
492
+ }
493
+ }
494
+ else {
495
+ return false;
496
+ }
497
+ }
412
498
  default:
413
499
  return false;
414
500
  }
415
- }, members_1));
501
+ }, members_2));
416
502
  }
417
503
  let typeParametersAreInferable;
418
504
  const mentioned = ofList(collect(memberTypeParameterNames, defaultArg(members, info.Members)), {
419
- Compare: (x, y) => (comparePrimitives(x, y) | 0),
505
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
420
506
  });
421
507
  typeParametersAreInferable = forAll((typeParameter) => {
422
508
  if (FSharpSet__Contains(mentioned, typeParameter.Name)) {
@@ -426,12 +512,12 @@ export function isCandidate(typeMemory, info) {
426
512
  return typeParameter.Default != null;
427
513
  }
428
514
  }, info.TypeParameters);
429
- const isDeclaredOnce = length(List_distinct(choose((_arg_2) => {
515
+ const isDeclaredOnce = length(List_distinct(choose((_arg_6) => {
430
516
  let matchResult, candidate_1;
431
- if (_arg_2.tag === 1) {
432
- if (_arg_2.fields[0].FullName === info.FullName) {
517
+ if (_arg_6.tag === 1) {
518
+ if (_arg_6.fields[0].FullName === info.FullName) {
433
519
  matchResult = 0;
434
- candidate_1 = _arg_2.fields[0];
520
+ candidate_1 = _arg_6.fields[0];
435
521
  }
436
522
  else {
437
523
  matchResult = 1;
@@ -448,7 +534,7 @@ export function isCandidate(typeMemory, info) {
448
534
  }
449
535
  }, typeMemory), {
450
536
  Equals: equals,
451
- GetHashCode: (x_1) => (safeHash(x_1) | 0),
537
+ GetHashCode: (x_2) => (safeHash(x_2) | 0),
452
538
  })) <= 1;
453
539
  if (hasOnlyProperties && typeParametersAreInferable) {
454
540
  return isDeclaredOnce;
@@ -48,7 +48,7 @@ export function typeParameterNames(glueType_mut) {
48
48
  glueType_2 = glueType.fields[0];
49
49
  break;
50
50
  }
51
- case 30: {
51
+ case 31: {
52
52
  matchResult = 2;
53
53
  glueType_2 = glueType.fields[0];
54
54
  break;
@@ -194,7 +194,7 @@ export function mentionsTypeParameter(name, glueType) {
194
194
  glueType_2 = glueType.fields[0];
195
195
  break;
196
196
  }
197
- case 30: {
197
+ case 31: {
198
198
  matchResult = 3;
199
199
  glueType_2 = glueType.fields[0];
200
200
  break;
@@ -8,7 +8,7 @@ import { concat } from "../../fable_modules/fable-library-js.5.21.0/String.js";
8
8
  import { empty as empty_1, singleton, append, delay, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
9
9
  import { toArray } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
10
10
 
11
- export const typedArrayNames = ofSeq(["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "BigInt64Array", "BigUint64Array"], {
11
+ export const typedArrayNames = ofSeq(["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "BigInt64Array", "BigUint64Array", "DataView", "ArrayBufferView"], {
12
12
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
13
13
  });
14
14
 
@@ -155,8 +155,8 @@ export function replaceSelfReference(name, glueType) {
155
155
  return new GlueType(/* Union */ 7, [new GlueTypeUnion(map(replace, glueType.fields[0].fields[0]))]);
156
156
  case 14:
157
157
  return new GlueType(/* Array */ 14, [replace(glueType.fields[0])]);
158
- case 30:
159
- return new GlueType(/* ReadOnly */ 30, [replace(glueType.fields[0])]);
158
+ case 31:
159
+ return new GlueType(/* ReadOnly */ 31, [replace(glueType.fields[0])]);
160
160
  case 23:
161
161
  return new GlueType(/* OptionalType */ 23, [replace(glueType.fields[0])]);
162
162
  case 18: