@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,14 +1,16 @@
1
1
 
2
- import { isFromEsLib, typeLiteralId, readTypeArguments, entityNameText, getFullNameOrEmpty, defaultTypeArguments, identifierText, isTupleType, resolveAlias, symbolAtLocation, withInProgress, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
2
+ import { isFromEsLib, typeLiteralId, readTypeArguments, getFullNameOrEmpty, defaultTypeArguments, isTupleType, resolveAlias, symbolAtLocation, entityNameText, identifierText, withInProgress, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
3
3
  import { Report_readerError_Z19516DCE } from "./Report.js";
4
4
  import { item as item_4, contains, filter as filter_1, append, collect, map, ofArray, isEmpty, choose, singleton, empty } from "../../fable_modules/fable-library-js.5.21.0/List.js";
5
5
  import { GlueReadonly, GlueRecord, GlueUtilityType, GlueInterface, GlueSubstitution_substituteMember, GlueSubstitution_mentionedTypeParameters, GlueTypeLiteral, GluePrimitive, GlueTypeUnion, GlueType, GlueLiteral } from "../GlueAST.js";
6
- import { contains as contains_1, singleton as singleton_1, choose as choose_1, ofList as ofList_1, empty as empty_1, exists, filter, forAll, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
6
+ import { contains as contains_1, singleton as singleton_1, choose as choose_1, ofList as ofList_1, empty as empty_1, tryHead, exists, map as map_1, filter, forAll, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
7
7
  import { toArray, defaultArg, value as value_6 } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
8
8
  import { readInstantiatedMember, readPropertyWithoutDeclaration } from "./MemberTypes.js";
9
9
  import { List_distinct } from "../../fable_modules/fable-library-js.5.21.0/Seq2.js";
10
- import { comparePrimitives, stringHash, safeHash, equals } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
10
+ import { stringHash, comparePrimitives, safeHash, equals } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
11
11
  import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.21.0/FSharp.Core.js";
12
+ import { FSharpSet__Contains, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
13
+ import { ts } from "@ts-morph/bootstrap";
12
14
  import { readTypeUsingFlags } from "./Deferred.js";
13
15
  import { FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, ofList } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
14
16
  import { item as item_5 } from "../../fable_modules/fable-library-js.5.21.0/Array.js";
@@ -187,6 +189,68 @@ function readMembers(reader, contextNode, typ) {
187
189
  });
188
190
  }
189
191
 
192
+ export function tryParameterFreeMappedAlias(declaration) {
193
+ let typeParameters;
194
+ if (Operators_IsNull(declaration) ? true : (declaration.kind !== 266)) {
195
+ return undefined;
196
+ }
197
+ else {
198
+ const alias = declaration;
199
+ const matchValue = alias.typeParameters;
200
+ let matchResult, typeParameters_1;
201
+ if (matchValue != null) {
202
+ if ((typeParameters = matchValue, (~~typeParameters.length > 0) && (alias.type.kind === 201))) {
203
+ matchResult = 0;
204
+ typeParameters_1 = matchValue;
205
+ }
206
+ else {
207
+ matchResult = 1;
208
+ }
209
+ }
210
+ else {
211
+ matchResult = 1;
212
+ }
213
+ switch (matchResult) {
214
+ case 0: {
215
+ const names = ofSeq(map_1((parameter) => identifierText(parameter.name), typeParameters_1), {
216
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
217
+ });
218
+ const usesParameter = (node) => {
219
+ if ((node.kind === 170) && (identifierText(node.name) === "this")) {
220
+ return false;
221
+ }
222
+ else if ((node.kind === 184) && FSharpSet__Contains(names, entityNameText(node.typeName))) {
223
+ return true;
224
+ }
225
+ else {
226
+ return defaultArg(ts.forEachChild(node, ((child) => (usesParameter(child) ? true : undefined))), false);
227
+ }
228
+ };
229
+ if (usesParameter(alias.type)) {
230
+ return undefined;
231
+ }
232
+ else {
233
+ return alias;
234
+ }
235
+ }
236
+ default:
237
+ return undefined;
238
+ }
239
+ }
240
+ }
241
+
242
+ export function readParameterFreeMappedAlias(reader, alias) {
243
+ let members;
244
+ const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(alias.type);
245
+ members = readMembers(reader, alias.type, typ);
246
+ if (isEmpty(members)) {
247
+ return undefined;
248
+ }
249
+ else {
250
+ return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(members, undefined)]);
251
+ }
252
+ }
253
+
190
254
  /**
191
255
  * When a generic type reference is applied with concrete type arguments
192
256
  * (e.g. a custom utility type like <c>Picked<User, "id"></c>), the
@@ -196,7 +260,7 @@ function readMembers(reader, contextNode, typ) {
196
260
  * reference to the (generic) utility.
197
261
  */
198
262
  export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
199
- let matchValue, typeArguments, option_5, option_3, option, binder, checker, option_1, symbol_2, typNode;
263
+ let matchValue, typeArguments, option_12, option_10, option_7, binder_4, checker_1, option_8, symbol_4, typNode;
200
264
  if (!((matchValue = typeReferenceNode.typeArguments, (matchValue == null) ? false : ((typeArguments = matchValue, ~~typeArguments.length > 0))))) {
201
265
  return undefined;
202
266
  }
@@ -229,20 +293,39 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
229
293
  const matchValue_4 = symbol.flags;
230
294
  isTypeAliasApplication = ($007CHasSymbolFlags$007C_$007C(524288, matchValue_4) != null);
231
295
  }
232
- const isObjectLiteralAlias = defaultArg((option_5 = ((option_3 = ((option = symbolAtLocation(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeReferenceNode.typeName), (binder = ((checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol_1) => resolveAlias(checker, symbol_1))), (option_1 = option, (option_1 != null) ? binder(option_1) : undefined)))), (option_3 != null) ? ((symbol_2 = option_3, symbol_2.declarations)) : undefined)), (option_5 != null) ? exists((declaration_1) => {
233
- if (declaration_1.kind === 266) {
234
- return declaration_1.type.kind === 188;
296
+ const isObjectLiteralAlias = (depth, typeName) => {
297
+ let option_5, option_3, option, binder, checker, option_1, symbol_2;
298
+ if (depth < 8) {
299
+ return defaultArg((option_5 = ((option_3 = ((option = symbolAtLocation(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeName), (binder = ((checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol_1) => resolveAlias(checker, symbol_1))), (option_1 = option, (option_1 != null) ? binder(option_1) : undefined)))), (option_3 != null) ? ((symbol_2 = option_3, symbol_2.declarations)) : undefined)), (option_5 != null) ? exists((declaration_1) => {
300
+ if (declaration_1.kind === 266) {
301
+ const body = declaration_1.type;
302
+ const matchValue_5 = body.kind;
303
+ switch (matchValue_5) {
304
+ case 184:
305
+ return isObjectLiteralAlias(depth + 1, body.typeName);
306
+ case 188:
307
+ return true;
308
+ default:
309
+ return false;
310
+ }
311
+ }
312
+ else {
313
+ return false;
314
+ }
315
+ }, option_5) : undefined), false);
235
316
  }
236
317
  else {
237
318
  return false;
238
319
  }
239
- }, option_5) : undefined), false);
320
+ };
321
+ const isObjectLiteralAlias_1 = isObjectLiteralAlias(0, typeReferenceNode.typeName);
322
+ const isParameterFreeMappedAlias = defaultArg((option_12 = ((option_10 = ((option_7 = symbolAtLocation(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeReferenceNode.typeName), (binder_4 = ((checker_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol_3) => resolveAlias(checker_1, symbol_3))), (option_8 = option_7, (option_8 != null) ? binder_4(option_8) : undefined)))), (option_10 != null) ? ((symbol_4 = option_10, symbol_4.declarations)) : undefined)), (option_12 != null) ? exists((declaration_2) => (tryParameterFreeMappedAlias(declaration_2) != null), option_12) : undefined), false);
240
323
  const isInProgress = exists((inProgress) => (inProgress === typ), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
241
324
  let isGenericMapped;
242
- const matchValue_5 = typ.flags;
243
- isGenericMapped = (($007CHasTypeFlags$007C_$007C(1048576, matchValue_5) != null) && (((typ.objectFlags & 32) !== 0) && exists((argument) => {
244
- const matchValue_6 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(argument).flags;
245
- if ($007CHasTypeFlags$007C_$007C(524288, matchValue_6) != null) {
325
+ const matchValue_6 = typ.flags;
326
+ isGenericMapped = (($007CHasTypeFlags$007C_$007C(1048576, matchValue_6) != null) && (((typ.objectFlags & 32) !== 0) && exists((argument) => {
327
+ const matchValue_7 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(argument).flags;
328
+ if ($007CHasTypeFlags$007C_$007C(524288, matchValue_7) != null) {
246
329
  return true;
247
330
  }
248
331
  else {
@@ -250,9 +333,9 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
250
333
  }
251
334
  }, value_6(typeReferenceNode.typeArguments))));
252
335
  const isArrayLike = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().isArrayLikeType(typ);
253
- const matchValue_7 = typ.flags;
336
+ const matchValue_8 = typ.flags;
254
337
  let matchResult;
255
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
338
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_8) != null) {
256
339
  if ((isTupleType(typ) ? true : (isArrayLike && !isNamedDeclaration)) && !isInProgress) {
257
340
  matchResult = 0;
258
341
  }
@@ -265,9 +348,9 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
265
348
  }
266
349
  switch (matchResult) {
267
350
  case 0: {
268
- const option_8 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
269
- if (option_8 != null) {
270
- return (typNode = option_8, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
351
+ const option_15 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
352
+ if (option_15 != null) {
353
+ return (typNode = option_15, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
271
354
  }
272
355
  else {
273
356
  return undefined;
@@ -275,8 +358,8 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
275
358
  }
276
359
  default: {
277
360
  let matchResult_1;
278
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
279
- if (((!isNamedDeclaration && !isObjectLiteralAlias) && !isInProgress) && !isGenericMapped) {
361
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_8) != null) {
362
+ if ((((!isNamedDeclaration && !isObjectLiteralAlias_1) && !isParameterFreeMappedAlias) && !isInProgress) && !isGenericMapped) {
280
363
  matchResult_1 = 0;
281
364
  }
282
365
  else {
@@ -298,15 +381,15 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
298
381
  }
299
382
  default: {
300
383
  let matchResult_2;
301
- if ($007CHasTypeFlags$007C_$007C(32, matchValue_7) != null) {
384
+ if ($007CHasTypeFlags$007C_$007C(32, matchValue_8) != null) {
302
385
  if (isTypeAliasApplication) {
303
386
  matchResult_2 = 0;
304
387
  }
305
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
388
+ else if ($007CHasTypeFlags$007C_$007C(64, matchValue_8) != null) {
306
389
  if (isTypeAliasApplication) {
307
390
  matchResult_2 = 0;
308
391
  }
309
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
392
+ else if ($007CHasTypeFlags$007C_$007C(256, matchValue_8) != null) {
310
393
  if (isTypeAliasApplication) {
311
394
  matchResult_2 = 0;
312
395
  }
@@ -318,7 +401,7 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
318
401
  matchResult_2 = 1;
319
402
  }
320
403
  }
321
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
404
+ else if ($007CHasTypeFlags$007C_$007C(256, matchValue_8) != null) {
322
405
  if (isTypeAliasApplication) {
323
406
  matchResult_2 = 0;
324
407
  }
@@ -330,11 +413,11 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
330
413
  matchResult_2 = 1;
331
414
  }
332
415
  }
333
- else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
416
+ else if ($007CHasTypeFlags$007C_$007C(64, matchValue_8) != null) {
334
417
  if (isTypeAliasApplication) {
335
418
  matchResult_2 = 0;
336
419
  }
337
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
420
+ else if ($007CHasTypeFlags$007C_$007C(256, matchValue_8) != null) {
338
421
  if (isTypeAliasApplication) {
339
422
  matchResult_2 = 0;
340
423
  }
@@ -346,7 +429,7 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
346
429
  matchResult_2 = 1;
347
430
  }
348
431
  }
349
- else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
432
+ else if ($007CHasTypeFlags$007C_$007C(256, matchValue_8) != null) {
350
433
  if (isTypeAliasApplication) {
351
434
  matchResult_2 = 0;
352
435
  }
@@ -478,7 +561,7 @@ function withoutForeignTypeParameters(reader, bound, members) {
478
561
  export function readPartial(reader, typeReferenceNode) {
479
562
  const baseType = baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
480
563
  if (exists((typ) => (typ === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials)) {
481
- const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 383);
564
+ const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 460);
482
565
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
483
566
  void (objectArg.push(item));
484
567
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -531,7 +614,7 @@ export function readPartial(reader, typeReferenceNode) {
531
614
  }
532
615
  default:
533
616
  if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
534
- const item_1 = Report_readerError_Z19516DCE("partial inner type", "Was not able to resolve the inner type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 425);
617
+ const item_1 = Report_readerError_Z19516DCE("partial inner type", "Was not able to resolve the inner type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 502);
535
618
  const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
536
619
  void (objectArg_1.push(item_1));
537
620
  members = empty();
@@ -608,6 +691,65 @@ export function readThisParameterType(reader, typeReferenceNode) {
608
691
  }
609
692
  }
610
693
 
694
+ export function tryReadInstanceType(reader, typeReferenceNode) {
695
+ let constraintNode, typNode, signature, typNode_1;
696
+ const argument = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(value_6(typeReferenceNode.typeArguments)[0]);
697
+ if (typeReferenceNode.pos < 0) {
698
+ return undefined;
699
+ }
700
+ else {
701
+ const matchValue = argument.flags;
702
+ if ($007CHasTypeFlags$007C_$007C(524288, matchValue) != null) {
703
+ let option_9;
704
+ let option_7;
705
+ let option_5;
706
+ let option_3;
707
+ const option_1 = argument.getSymbol();
708
+ if (option_1 != null) {
709
+ const symbol = option_1;
710
+ option_3 = symbol.declarations;
711
+ }
712
+ else {
713
+ option_3 = undefined;
714
+ }
715
+ option_5 = ((option_3 != null) ? tryHead(option_3) : undefined);
716
+ if (option_5 != null) {
717
+ const declaration = option_5;
718
+ option_7 = declaration.constraint;
719
+ }
720
+ else {
721
+ option_7 = undefined;
722
+ }
723
+ option_9 = ((option_7 != null) ? (((constraintNode = option_7, constraintNode.kind === 187)) ? option_7 : undefined) : undefined);
724
+ if (option_9 != null) {
725
+ return (typNode = option_9, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
726
+ }
727
+ else {
728
+ return undefined;
729
+ }
730
+ }
731
+ else {
732
+ let option_15;
733
+ let option_13;
734
+ const option_11 = tryHead(argument.getConstructSignatures());
735
+ option_13 = ((option_11 != null) ? ((signature = option_11, signature.getReturnType())) : undefined);
736
+ if (option_13 != null) {
737
+ const instance = option_13;
738
+ option_15 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(instance, undefined, typeNodeBuilderFlags);
739
+ }
740
+ else {
741
+ option_15 = undefined;
742
+ }
743
+ if (option_15 != null) {
744
+ return (typNode_1 = option_15, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode_1));
745
+ }
746
+ else {
747
+ return undefined;
748
+ }
749
+ }
750
+ }
751
+ }
752
+
611
753
  export function readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
612
754
  let option_1, matchValue_4, item_1, objectArg_2, objectArg_3;
613
755
  let keysToOmitType;
@@ -626,6 +768,9 @@ export function readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
626
768
  else if ($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) {
627
769
  matchResult = 0;
628
770
  }
771
+ else if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
772
+ matchResult = 0;
773
+ }
629
774
  else {
630
775
  matchResult = 1;
631
776
  }
@@ -638,15 +783,15 @@ export function readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
638
783
  hasUnboundKeys = false;
639
784
  }
640
785
  const tryReadValueOfKeys = (typ) => {
641
- const activePatternResult_3 = Type_StringLiteral_$007CString$007COther$007C(typ);
642
- if (activePatternResult_3.tag === 1) {
643
- const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 544);
786
+ const activePatternResult_4 = Type_StringLiteral_$007CString$007COther$007C(typ);
787
+ if (activePatternResult_4.tag === 1) {
788
+ const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 650);
644
789
  const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
645
790
  void (objectArg_1.push(item));
646
791
  return undefined;
647
792
  }
648
793
  else {
649
- return activePatternResult_3.fields[0];
794
+ return activePatternResult_4.fields[0];
650
795
  }
651
796
  };
652
797
  let keysToOmit;
@@ -705,7 +850,7 @@ export function readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
705
850
  const filteredProperties = toList(filter((prop) => (keepListedKeys === contains_1(prop.name, keysToOmit, {
706
851
  Equals: (x, y) => (x === y),
707
852
  GetHashCode: (x) => (stringHash(x) | 0),
708
- })), (matchValue_4 = baseType.flags, ($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? ((literalMembers != null) ? [] : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 579), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType))))) : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 579), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType)))))));
853
+ })), (matchValue_4 = baseType.flags, ($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? ((literalMembers != null) ? [] : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 685), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType))))) : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 685), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType)))))));
709
854
  const isInProgress = exists((inProgress) => (inProgress === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
710
855
  const members_1 = isInProgress ? empty() : withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions, baseType, () => collect((property) => readPropertyMembers(reader, typeReferenceNode, property), filteredProperties));
711
856
  const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
@@ -827,7 +972,7 @@ export function readReadonly(reader, typeReferenceNode) {
827
972
  }, unionType.types))])])]);
828
973
  }
829
974
  catch (matchValue_2) {
830
- const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 715);
975
+ const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 821);
831
976
  const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
832
977
  void (objectArg.push(item));
833
978
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
@@ -2,7 +2,7 @@
2
2
  import { orElse, defaultArg, some } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
3
3
  import { GlueTypeParameter, GlueAccessor, GlueLiteral, GlueType, GluePrimitive } from "../GlueAST.js";
4
4
  import { tryParse } from "../../fable_modules/fable-library-js.5.21.0/Int32.js";
5
- import { FSharpRef } from "../../fable_modules/fable-library-js.5.21.0/Types.js";
5
+ import { toString, FSharpRef } from "../../fable_modules/fable-library-js.5.21.0/Types.js";
6
6
  import { tryParse as tryParse_1 } from "../../fable_modules/fable-library-js.5.21.0/Double.js";
7
7
  import { equals, comparePrimitives, stringHash, defaultOf } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
8
8
  import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.21.0/FSharp.Core.js";
@@ -10,13 +10,13 @@ import { withoutDeclarationExtension, normalizePath } from "../Utils/String.js";
10
10
  import { class_type } from "../../fable_modules/fable-library-js.5.21.0/Reflection.js";
11
11
  import { tryPick, map as map_2, last, iterate, toList, tryHead, exists } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
12
12
  import { PackageContext__ModulePath_Z7E147617, PackageContext__NestedAmbientModuleSegments_32BC514A, PackageContext__IsExternalLibFile_Z721C83C5, PackageContext__IsEntryFile_Z721C83C5, ambientSpecifier, PackageContext__IsExternal_Z721C83C5, PackageContext__TryFindExternalModulePath_Z721C83C5, PackageContext__TryFindPackage_Z721C83C5 } from "./Types.js";
13
- import { tail, append, cons, tryHead as tryHead_1, exists as exists_1, tryFind, isEmpty, filter, head, tryItem, mapIndexed, choose, ofArray, contains, collect as collect_1, empty, map as map_1 } from "../../fable_modules/fable-library-js.5.21.0/List.js";
13
+ import { tail, cons, tryHead as tryHead_1, exists as exists_1, tryFind, isEmpty, head, tryItem, mapIndexed, choose, append, fold, ofArray, contains, filter, collect as collect_1, empty, map as map_1 } from "../../fable_modules/fable-library-js.5.21.0/List.js";
14
14
  import { item as item_1 } from "../../fable_modules/fable-library-js.5.21.0/Array.js";
15
- import { contains as contains_1, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
16
- import { ofList, empty as empty_1 } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
15
+ import { contains as contains_1, empty as empty_1, add, FSharpSet__Contains, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
16
+ import { ts } from "@ts-morph/bootstrap";
17
+ import { ofList, empty as empty_2 } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
17
18
  import { substring, split } from "../../fable_modules/fable-library-js.5.21.0/String.js";
18
19
  import { sanitizeTypeName, removeSurroundingQuotes } from "../Utils/Naming.js";
19
- import { ts } from "@ts-morph/bootstrap";
20
20
  import { FSharpChoice$3, FSharpChoice$2 } from "../../fable_modules/fable-library-js.5.21.0/Choice.js";
21
21
 
22
22
  export function $007CHasTypeFlags$007C_$007C(flag, flags) {
@@ -174,7 +174,7 @@ export function tryReadLiteral(checker, expression) {
174
174
  break;
175
175
  }
176
176
  default:
177
- if (expression.pos < 0) {
177
+ if ((expression.pos < 0) ? true : Operators_IsNull(expression.getSourceFile())) {
178
178
  matchResult = 4;
179
179
  }
180
180
  else {
@@ -232,11 +232,63 @@ export function moduleExportNameText(name) {
232
232
  * Nodes synthesized by <c>typeToTypeNode</c> have no source text
233
233
  */
234
234
  export function identifierText(node) {
235
- if (Operators_IsNull(node.text)) {
236
- return node.getText();
235
+ if (!Operators_IsNull(node.text)) {
236
+ return node.text;
237
237
  }
238
238
  else {
239
- return node.text;
239
+ let matchValue_1;
240
+ if (node.kind === 168) {
241
+ const expression = node.expression;
242
+ const matchValue = expression.kind;
243
+ switch (matchValue) {
244
+ case 9:
245
+ case 11:
246
+ case 15: {
247
+ matchValue_1 = toString(expression.text);
248
+ break;
249
+ }
250
+ default:
251
+ matchValue_1 = undefined;
252
+ }
253
+ }
254
+ else {
255
+ matchValue_1 = undefined;
256
+ }
257
+ if (matchValue_1 == null) {
258
+ return node.getText();
259
+ }
260
+ else {
261
+ return matchValue_1;
262
+ }
263
+ }
264
+ }
265
+
266
+ /**
267
+ * `[Events.MEDIA_ATTACHING]` with `MEDIA_ATTACHING = "hlsMediaAttaching"` is the member `hlsMediaAttaching`
268
+ */
269
+ export function memberNameText(checker, node) {
270
+ if ((node.kind === 168) && (node.pos >= 0)) {
271
+ const typ = checker.getTypeAtLocation(node.expression);
272
+ const matchValue = typ.flags;
273
+ let matchResult;
274
+ if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
275
+ matchResult = 0;
276
+ }
277
+ else if ($007CHasTypeFlags$007C_$007C(2048, matchValue) != null) {
278
+ matchResult = 0;
279
+ }
280
+ else {
281
+ matchResult = 1;
282
+ }
283
+ switch (matchResult) {
284
+ case 0:
285
+ return toString(typ.value);
286
+ default:
287
+ return identifierText(node);
288
+ }
289
+ }
290
+ else {
291
+ return identifierText(node);
240
292
  }
241
293
  }
242
294
 
@@ -598,18 +650,66 @@ function readExternalBase(reader, clauseType) {
598
650
  }
599
651
  }
600
652
 
601
- export function readHeritageClauses(reader, heritageClauses) {
653
+ function tryModuleExports(reader, clauseType) {
654
+ let declarations;
655
+ const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeAtLocation(clauseType);
656
+ if (Operators_IsNull(typ) ? true : Operators_IsNull(typ.symbol)) {
657
+ return undefined;
658
+ }
659
+ else {
660
+ const matchValue = typ.symbol.declarations;
661
+ let matchResult, declarations_1;
662
+ if (matchValue != null) {
663
+ if ((declarations = matchValue, (declarations.length > 0) && ((item_1(0, declarations).kind === 308) ? true : (item_1(0, declarations).kind === 268)))) {
664
+ matchResult = 0;
665
+ declarations_1 = matchValue;
666
+ }
667
+ else {
668
+ matchResult = 1;
669
+ }
670
+ }
671
+ else {
672
+ matchResult = 1;
673
+ }
674
+ switch (matchResult) {
675
+ case 0:
676
+ return collect_1((property) => {
677
+ let option_1;
678
+ return map_1((declaration_1) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_1), filter((declaration) => {
679
+ if (declaration.kind === 263) {
680
+ return true;
681
+ }
682
+ else {
683
+ return declaration.kind === 261;
684
+ }
685
+ }, defaultArg((option_1 = property.declarations, (option_1 != null) ? toList(option_1) : undefined), empty())));
686
+ }, toList(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getPropertiesOfType(typ)));
687
+ default:
688
+ return undefined;
689
+ }
690
+ }
691
+ }
692
+
693
+ function clauseTypes(heritageClauses) {
602
694
  if (heritageClauses == null) {
603
695
  return empty();
604
696
  }
605
697
  else {
606
- return collect_1((clause) => map_1((clauseType) => {
607
- readExternalBase(reader, clauseType);
608
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](clauseType);
609
- }, toList(clause.types)), toList(heritageClauses));
698
+ return collect_1((clause) => toList(clause.types), toList(heritageClauses));
610
699
  }
611
700
  }
612
701
 
702
+ export function readHeritageClauses(reader, heritageClauses) {
703
+ return map_1((clauseType_1) => {
704
+ readExternalBase(reader, clauseType_1);
705
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](clauseType_1);
706
+ }, filter((clauseType) => (tryModuleExports(reader, clauseType) == null), clauseTypes(heritageClauses)));
707
+ }
708
+
709
+ export function readModuleHeritageMembers(reader, heritageClauses) {
710
+ return collect_1((arg) => defaultArg(tryModuleExports(reader, arg), empty()), clauseTypes(heritageClauses));
711
+ }
712
+
613
713
  function libDeclaration(symbolOpt) {
614
714
  let option_3;
615
715
  const option_1 = symbolOpt;
@@ -697,7 +797,7 @@ export function isFromEsLib(symbolOpt) {
697
797
  }
698
798
  }
699
799
 
700
- export const knownExternalTypeNames = ofSeq(["Date", "Promise", "Array", "ReadonlyArray", "Boolean", "Function", "Error", "RegExp", "Iterable", "IterableIterator", "IteratorObject", "ArrayIterator", "MapIterator", "SetIterator", "StringIterator", "Uint8Array", "Int8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array"], {
800
+ export const knownExternalTypeNames = ofSeq(["Date", "Promise", "Array", "ReadonlyArray", "Boolean", "Function", "Error", "RegExp", "Iterable", "IterableIterator", "IteratorObject", "ArrayIterator", "MapIterator", "SetIterator", "StringIterator", "Uint8Array", "Int8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "ArrayBuffer", "ArrayBufferView", "DataView", "Map", "Set", "WeakMap", "WeakSet", "Number", "String", "BigInt", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "ArrayBufferLike", "ArrayLike", "ConcatArray", "Generator", "Iterator", "IteratorResult", "IteratorReturnResult", "IteratorYieldResult", "PromiseLike", "PropertyDescriptor", "PropertyDescriptorMap", "PropertyKey", "ProxyHandler", "ReadonlyMap", "ReadonlySet", "ReadonlySetLike", "SharedArrayBuffer", "TemplateStringsArray", "TypedPropertyDescriptor", "ErrorOptions"], {
701
801
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
702
802
  });
703
803
 
@@ -717,6 +817,75 @@ export function resolveAlias(checker, symbol) {
717
817
  }
718
818
  }
719
819
 
820
+ function mentionsThisNode(node) {
821
+ if (node.kind === 198) {
822
+ return true;
823
+ }
824
+ else {
825
+ return defaultArg(ts.forEachChild(node, ((child) => (mentionsThisNode(child) ? true : undefined))), false);
826
+ }
827
+ }
828
+
829
+ function nestsThisNode(typeNode) {
830
+ if (typeNode == null) {
831
+ return false;
832
+ }
833
+ else {
834
+ const typeNode_1 = typeNode;
835
+ if (typeNode_1.kind !== 198) {
836
+ return mentionsThisNode(typeNode_1);
837
+ }
838
+ else {
839
+ return false;
840
+ }
841
+ }
842
+ }
843
+
844
+ export function readInheritedNestedThisMethods(reader, heritageClauses, declaredNames) {
845
+ const key = (declaration) => (`${declaration.getSourceFile().fileName}:${declaration.pos}`);
846
+ const collect = (visited, taken, clauses) => {
847
+ const bases = collect_1((clauseType) => {
848
+ let option_5, option_3, option, binder, checker, option_1, symbol_1;
849
+ return filter((declaration_1) => {
850
+ if (((declaration_1.kind === 264) ? true : (declaration_1.kind === 265)) && Operators_IsNull(declaration_1.typeParameters)) {
851
+ return !FSharpSet__Contains(visited, key(declaration_1));
852
+ }
853
+ else {
854
+ return false;
855
+ }
856
+ }, defaultArg((option_5 = ((option_3 = ((option = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(clauseType.expression), (binder = ((checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol) => resolveAlias(checker, symbol))), (option_1 = option, (option_1 != null) ? binder(option_1) : undefined)))), (option_3 != null) ? ((symbol_1 = option_3, symbol_1.declarations)) : undefined)), (option_5 != null) ? toList(option_5) : undefined), empty()));
857
+ }, clauseTypes(clauses));
858
+ const ownMethods = collect_1((declaration_2) => filter((element_1) => !FSharpSet__Contains(taken, identifierText(element_1.name)), filter((element) => {
859
+ const matchValue = element.kind;
860
+ switch (matchValue) {
861
+ case 174:
862
+ case 175: {
863
+ const signature = element;
864
+ if (!ModifierUtil_HasModifier_742AC9D(element.modifiers, 126)) {
865
+ if (nestsThisNode(signature.type)) {
866
+ return true;
867
+ }
868
+ else {
869
+ return exists((parameter) => nestsThisNode(parameter.type), signature.parameters);
870
+ }
871
+ }
872
+ else {
873
+ return false;
874
+ }
875
+ }
876
+ default:
877
+ return false;
878
+ }
879
+ }, toList(declaration_2.members))), bases);
880
+ const taken_2 = fold((taken_1, element_2) => add(identifierText(element_2.name), taken_1), taken, ownMethods);
881
+ const visited_2 = fold((visited_1, declaration_3) => add(key(declaration_3), visited_1), visited, bases);
882
+ return append(map_1((element_3) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](element_3), ownMethods), collect_1((declaration_4) => collect(visited_2, taken_2, declaration_4.heritageClauses), bases));
883
+ };
884
+ return collect(empty_1({
885
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
886
+ }), declaredNames, heritageClauses);
887
+ }
888
+
720
889
  /**
721
890
  * `type X` beside `export { x as X }` is one symbol flagged both `TypeAlias` and `Alias`
722
891
  */
@@ -736,7 +905,7 @@ export function resolveValueAlias(checker, symbol) {
736
905
  export function defaultTypeArguments(reader, typeNode) {
737
906
  let option_16, option_7, option_5, option_3, option, binder, checker, option_1, symbol_1, declaration;
738
907
  if (typeNode.kind !== 184) {
739
- return empty_1({
908
+ return empty_2({
740
909
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
741
910
  });
742
911
  }
@@ -759,7 +928,7 @@ export function defaultTypeArguments(reader, typeNode) {
759
928
  return [identifierText(typeParameter.name), argument];
760
929
  }, toList(option_16))), {
761
930
  Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
762
- }) : undefined), empty_1({
931
+ }) : undefined), empty_2({
763
932
  Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
764
933
  }));
765
934
  }