@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,12 +1,15 @@
1
1
 
2
- import { filter, map, choose, partition } from "../../fable_modules/fable-library-js.5.21.0/List.js";
3
- import { toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
4
- import { GlueType, GlueClassDeclaration, GlueConstructor } from "../GlueAST.js";
5
- import { isExportAssignmentTarget, isExportedDeclaration, readHeritageClauses, getFullNameOrEmpty, isDefaultInExportList, ModifierUtil_HasModifier_742AC9D } from "./Utils.js";
6
- import { singleton } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
2
+ import { singleton, append, filter, map, choose, partition } from "../../fable_modules/fable-library-js.5.21.0/List.js";
3
+ import { choose as choose_1, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
4
+ import { GlueClassDeclaration, GlueSubstitution_substituteMember, GlueType, GlueThisType, GlueConstructor } from "../GlueAST.js";
5
+ import { isExportAssignmentTarget, isExportedDeclaration, readHeritageClauses, getFullNameOrEmpty, isDefaultInExportList, readInheritedNestedThisMethods, identifierText, ModifierUtil_HasModifier_742AC9D } from "./Utils.js";
6
+ import { singleton as singleton_1, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
7
+ import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.21.0/FSharp.Core.js";
7
8
  import { comparePrimitives } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
9
+ import { ofList } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
8
10
 
9
11
  export function readClassDeclaration(reader, classDeclaration) {
12
+ let list_4, substitutions;
10
13
  const name = classDeclaration.name;
11
14
  const patternInput = partition((m) => {
12
15
  if (m.kind === 177) {
@@ -26,11 +29,25 @@ export function readClassDeclaration(reader, classDeclaration) {
26
29
  }
27
30
  }, patternInput[0]);
28
31
  const members_2 = map((declaration) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration), filter((classElement) => !ModifierUtil_HasModifier_742AC9D(classElement.modifiers, 124), patternInput[1]));
29
- const isDefaultExport = ModifierUtil_HasModifier_742AC9D(classDeclaration.modifiers, 90) ? true : isDefaultInExportList(classDeclaration, name.getText());
30
- const classDeclaration_1 = new GlueType(/* ClassDeclaration */ 12, [new GlueClassDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](classDeclaration), getFullNameOrEmpty(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), classDeclaration), name.getText(), constructors_1, members_2, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](classDeclaration.typeParameters), readHeritageClauses(reader, classDeclaration.heritageClauses), (isDefaultExport ? true : isExportedDeclaration(classDeclaration, singleton(name.getText(), {
32
+ let members_3;
33
+ const declaredNames = ofSeq(choose_1((element) => {
34
+ if (Operators_IsNull(element.name)) {
35
+ return undefined;
36
+ }
37
+ else {
38
+ return identifierText(element.name);
39
+ }
40
+ }, classDeclaration.members), {
31
41
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
32
- }))) ? true : isExportAssignmentTarget(classDeclaration, singleton(name.getText(), {
42
+ });
43
+ members_3 = append(members_2, (list_4 = readInheritedNestedThisMethods(reader, classDeclaration.heritageClauses, declaredNames), map((substitutions = ofList(singleton(["this", new GlueType(/* ThisType */ 17, [new GlueThisType(name.getText(), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](classDeclaration.typeParameters))])]), {
33
44
  Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
45
+ }), (glueMember) => GlueSubstitution_substituteMember(substitutions, glueMember)), list_4)));
46
+ const isDefaultExport = ModifierUtil_HasModifier_742AC9D(classDeclaration.modifiers, 90) ? true : isDefaultInExportList(classDeclaration, name.getText());
47
+ const classDeclaration_1 = new GlueType(/* ClassDeclaration */ 12, [new GlueClassDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](classDeclaration), getFullNameOrEmpty(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), classDeclaration), name.getText(), constructors_1, members_3, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](classDeclaration.typeParameters), readHeritageClauses(reader, classDeclaration.heritageClauses), (isDefaultExport ? true : isExportedDeclaration(classDeclaration, singleton_1(name.getText(), {
48
+ Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
49
+ }))) ? true : isExportAssignmentTarget(classDeclaration, singleton_1(name.getText(), {
50
+ Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
34
51
  })))]);
35
52
  if (isDefaultExport) {
36
53
  return new GlueType(/* ExportDefault */ 25, [classDeclaration_1]);
@@ -37,7 +37,7 @@ export function readConditionalType(reader, typeNode) {
37
37
  }), (trueType = branch(conditionalTypeNode.trueType), (falseType = branch(conditionalTypeNode.falseType), equals(trueType, falseType) ? trueType : (new GlueType(/* Union */ 7, [new GlueTypeUnion(ofArray([trueType, falseType]))])))))) : tryResolveDeferred(reader, typeNode);
38
38
  if (resolved == null) {
39
39
  const warningsCount = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length | 0;
40
- const inferred = List_distinctBy((_arg) => _arg.Name, map((inferTypeNode) => (new GlueTypeParameter(inferTypeNode.typeParameter.name.getText(), inferredConstraint(reader, inferTypeNode), undefined)), inferTypeNodes(conditionalTypeNode.extendsType)), {
40
+ const inferred = List_distinctBy((_arg) => _arg.Name, map((inferTypeNode) => (new GlueTypeParameter(inferTypeNode.typeParameter.name.text, inferredConstraint(reader, inferTypeNode), undefined)), inferTypeNodes(conditionalTypeNode.extendsType)), {
41
41
  Equals: (x, y) => (x === y),
42
42
  GetHashCode: (x) => (stringHash(x) | 0),
43
43
  });
@@ -47,7 +47,7 @@ export function readConditionalType(reader, typeNode) {
47
47
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
48
48
  }
49
49
  else {
50
- return new GlueType(/* ConditionalType */ 33, [conditionalType]);
50
+ return new GlueType(/* ConditionalType */ 34, [conditionalType]);
51
51
  }
52
52
  }
53
53
  else {
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.21.0/FSharp.Core.js";
3
3
  import { Exception, defaultOf } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
4
- import { resolveAlias, readMemberTypeParameters, isPrivateMember, ModifierUtil_GetAccessor_2944DA29, ModifierUtil_HasModifier_742AC9D, identifierText, ModifierUtil_GetAccessor_Z1CCFC6BA } from "./Utils.js";
4
+ import { identifierText, resolveAlias, readMemberTypeParameters, isPrivateMember, ModifierUtil_GetAccessor_2944DA29, ModifierUtil_HasModifier_742AC9D, typeNodeBuilderFlags, ModifierUtil_GetAccessor_Z1CCFC6BA, memberNameText } from "./Utils.js";
5
5
  import { GlueAccessor, GlueType, GluePrimitive, GlueIndexSignature, GlueConstructSignature, GlueCallSignature, GlueSetAccessor, GlueGetAccessor, GlueMethod, GlueMethodSignature, GlueMember, GlueProperty } from "../GlueAST.js";
6
6
  import { defaultArg } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
7
7
  import { exists } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
@@ -16,38 +16,38 @@ import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Ext
16
16
  * `K extends keyof Map` keeps the map, `Map[K]` is resolved through it
17
17
  */
18
18
  export function readDeclaration(reader, declaration) {
19
- let name_1, matchValue_1, Name_1, Documentation_2, Type_1, IsOptional_1, Documentation_1, option_1, matchValue_2, matchValue_5, typeNode, declarations, target_2, matchValue_4;
19
+ let name_1, matchValue_1, Name_1, Documentation_2, Type_1, matchValue_3, matchValue_4, typNode, typ, type, objectArg, IsOptional_1, Documentation_1, option_1, matchValue_2, matchValue_8, typeNode_1, declarations, target_2, matchValue_7;
20
20
  const matchValue = declaration.kind;
21
21
  switch (matchValue) {
22
22
  case 172: {
23
23
  const propertySignature = declaration;
24
24
  const name = propertySignature.name;
25
- return new GlueMember(/* Property */ 1, [new GlueProperty((name_1 = propertySignature.name, !Operators_IsNull(name_1.text) ? name_1.text : ((name_1.pos < 0) ? ((matchValue_1 = name_1.escapedText, (matchValue_1 === defaultOf()) ? "computed" : matchValue_1)) : (name_1.getText()))), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](propertySignature.type), false, propertySignature.questionToken != null, ModifierUtil_GetAccessor_Z1CCFC6BA(propertySignature.modifiers), false)]);
25
+ return new GlueMember(/* Property */ 1, [new GlueProperty((name_1 = propertySignature.name, !Operators_IsNull(name_1.text) ? name_1.text : ((name_1.pos < 0) ? ((matchValue_1 = name_1.escapedText, (matchValue_1 === defaultOf()) ? "computed" : matchValue_1)) : memberNameText(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), name_1))), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](propertySignature.type), false, propertySignature.questionToken != null, ModifierUtil_GetAccessor_Z1CCFC6BA(propertySignature.modifiers), false)]);
26
26
  }
27
27
  case 173: {
28
28
  const propertyDeclaration = declaration;
29
29
  const name_4 = propertyDeclaration.name;
30
- return new GlueMember(/* Property */ 1, [(Name_1 = identifierText(name_4), (Documentation_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_4), (Type_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](propertyDeclaration.type), (IsOptional_1 = (propertyDeclaration.questionToken != null), new GlueProperty(Name_1, Documentation_2, Type_1, ModifierUtil_HasModifier_742AC9D(propertyDeclaration.modifiers, 126), IsOptional_1, ModifierUtil_GetAccessor_2944DA29(propertyDeclaration.modifiers), isPrivateMember(propertyDeclaration.modifiers, name_4))))))]);
30
+ return new GlueMember(/* Property */ 1, [(Name_1 = memberNameText(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), name_4), (Documentation_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_4), (Type_1 = ((matchValue_3 = propertyDeclaration.type, (matchValue_4 = propertyDeclaration.initializer, (matchValue_3 == null) ? ((matchValue_4 != null) ? ((typNode = ((typ = ((type = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeAtLocation(propertyDeclaration), (objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg.getBaseTypeOfLiteralType(type)))), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags))), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode))) : reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](matchValue_3)) : reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](matchValue_3)))), (IsOptional_1 = (propertyDeclaration.questionToken != null), new GlueProperty(Name_1, Documentation_2, Type_1, ModifierUtil_HasModifier_742AC9D(propertyDeclaration.modifiers, 126), IsOptional_1, ModifierUtil_GetAccessor_2944DA29(propertyDeclaration.modifiers), isPrivateMember(propertyDeclaration.modifiers, name_4))))))]);
31
31
  }
32
32
  case 174: {
33
33
  const methodSignature = declaration;
34
34
  const name_3 = methodSignature.name;
35
- return new GlueMember(/* MethodSignature */ 6, [(Documentation_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_3), new GlueMethodSignature(identifierText(name_3), Documentation_1, readMemberTypeParameters(reader, methodSignature.typeParameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](methodSignature.parameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](methodSignature.type), methodSignature.questionToken != null))]);
35
+ return new GlueMember(/* MethodSignature */ 6, [(Documentation_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_3), new GlueMethodSignature(memberNameText(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), name_3), Documentation_1, readMemberTypeParameters(reader, methodSignature.typeParameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](methodSignature.parameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](methodSignature.type), methodSignature.questionToken != null))]);
36
36
  }
37
37
  case 175: {
38
38
  const methodDeclaration = declaration;
39
39
  const name_2 = methodDeclaration.name;
40
- return new GlueMember(/* Method */ 0, [new GlueMethod(identifierText(name_2), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_2), readMemberTypeParameters(reader, methodDeclaration.typeParameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](methodDeclaration.parameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](methodDeclaration.type), methodDeclaration.questionToken != null, defaultArg((option_1 = methodDeclaration.modifiers, (option_1 != null) ? exists((modifier) => (modifier.kind === 126), option_1) : undefined), false))]);
40
+ return new GlueMember(/* Method */ 0, [new GlueMethod(memberNameText(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), name_2), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_2), readMemberTypeParameters(reader, methodDeclaration.typeParameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](methodDeclaration.parameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](methodDeclaration.type), methodDeclaration.questionToken != null, defaultArg((option_1 = methodDeclaration.modifiers, (option_1 != null) ? exists((modifier) => (modifier.kind === 126), option_1) : undefined), false))]);
41
41
  }
42
42
  case 178: {
43
43
  const getAccessorDeclaration = declaration;
44
44
  const name_5 = getAccessorDeclaration.name;
45
- return new GlueMember(/* GetAccessor */ 2, [new GlueGetAccessor(identifierText(name_5), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_5), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](getAccessorDeclaration.type), ModifierUtil_HasModifier_742AC9D(getAccessorDeclaration.modifiers, 126), isPrivateMember(getAccessorDeclaration.modifiers, name_5))]);
45
+ return new GlueMember(/* GetAccessor */ 2, [new GlueGetAccessor(memberNameText(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), name_5), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_5), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](getAccessorDeclaration.type), ModifierUtil_HasModifier_742AC9D(getAccessorDeclaration.modifiers, 126), isPrivateMember(getAccessorDeclaration.modifiers, name_5))]);
46
46
  }
47
47
  case 179: {
48
48
  const setAccessorDeclaration = declaration;
49
49
  const name_6 = setAccessorDeclaration.name;
50
- return new GlueMember(/* SetAccessor */ 3, [new GlueSetAccessor(identifierText(name_6), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_6), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"]((setAccessorDeclaration.parameters[0]).type), ModifierUtil_HasModifier_742AC9D(setAccessorDeclaration.modifiers, 126), isPrivateMember(setAccessorDeclaration.modifiers, name_6))]);
50
+ return new GlueMember(/* SetAccessor */ 3, [new GlueSetAccessor(memberNameText(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), name_6), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_6), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"]((setAccessorDeclaration.parameters[0]).type), ModifierUtil_HasModifier_742AC9D(setAccessorDeclaration.modifiers, 126), isPrivateMember(setAccessorDeclaration.modifiers, name_6))]);
51
51
  }
52
52
  case 180: {
53
53
  const callSignature = declaration;
@@ -67,7 +67,7 @@ export function readDeclaration(reader, declaration) {
67
67
  let isConst;
68
68
  const parent = variableDeclaration.parent;
69
69
  isConst = (!Operators_IsNull(parent) && ((parent.flags & 2) !== 0));
70
- return new GlueMember(/* Property */ 1, [new GlueProperty(identifierText(name_7), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_7), (matchValue_5 = variableDeclaration.type, (matchValue_5 == null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])) : ((typeNode = matchValue_5, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode)))), false, false, isConst ? GlueAccessor.ReadOnly : GlueAccessor.ReadWrite, false)]);
70
+ return new GlueMember(/* Property */ 1, [new GlueProperty(memberNameText(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), name_7), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_7), (matchValue_8 = variableDeclaration.type, (matchValue_8 == null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])) : ((typeNode_1 = matchValue_8, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode_1)))), false, false, isConst ? GlueAccessor.ReadOnly : GlueAccessor.ReadWrite, false)]);
71
71
  }
72
72
  case 263: {
73
73
  const functionDeclaration = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadFunctionDeclarationZ72EBD329"](declaration);
@@ -91,12 +91,12 @@ export function readDeclaration(reader, declaration) {
91
91
  option_6 = ((option_4 != null) ? binder(option_4) : undefined);
92
92
  if (option_6 != null) {
93
93
  const target = option_6;
94
- const matchValue_3 = target.declarations;
94
+ const matchValue_6 = target.declarations;
95
95
  let matchResult, declarations_1;
96
- if (matchValue_3 != null) {
97
- if ((declarations = matchValue_3, declarations.length > 0)) {
96
+ if (matchValue_6 != null) {
97
+ if ((declarations = matchValue_6, declarations.length > 0)) {
98
98
  matchResult = 0;
99
- declarations_1 = matchValue_3;
99
+ declarations_1 = matchValue_6;
100
100
  }
101
101
  else {
102
102
  matchResult = 1;
@@ -119,7 +119,7 @@ export function readDeclaration(reader, declaration) {
119
119
  }
120
120
  let matchResult_1, target_3;
121
121
  if (target_1 != null) {
122
- if ((target_2 = target_1, (matchValue_4 = target_2.kind, (matchValue_4 === 172) ? true : ((matchValue_4 === 173) ? true : ((matchValue_4 === 174) ? true : ((matchValue_4 === 175) ? true : ((matchValue_4 === 261) ? true : (matchValue_4 === 263)))))))) {
122
+ if ((target_2 = target_1, (matchValue_7 = target_2.kind, (matchValue_7 === 172) ? true : ((matchValue_7 === 173) ? true : ((matchValue_7 === 174) ? true : ((matchValue_7 === 175) ? true : ((matchValue_7 === 261) ? true : (matchValue_7 === 263)))))))) {
123
123
  matchResult_1 = 0;
124
124
  target_3 = target_1;
125
125
  }
@@ -138,7 +138,7 @@ export function readDeclaration(reader, declaration) {
138
138
  }
139
139
  }
140
140
  default:
141
- throw new Exception(Report_readerError_Z19516DCE("declaration", concat("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(declaration.kind)), declaration, "/_//src/Glutinum.Converter/Reader/Declaration.fs", 255));
141
+ throw new Exception(Report_readerError_Z19516DCE("declaration", concat("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(declaration.kind)), declaration, "/_//src/Glutinum.Converter/Reader/Declaration.fs", 263));
142
142
  }
143
143
  }
144
144
 
@@ -1,12 +1,14 @@
1
1
 
2
- import { primitiveOfFlags, entityNameText, mainDeclaration, typeNodeBuilderFlags, enclosingDeclarationOf, resolveAlias, symbolAtLocation, identifierText, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
2
+ import { primitiveOfFlags, mainDeclaration, typeNodeBuilderFlags, enclosingDeclarationOf, resolveAlias, symbolAtLocation, entityNameText, identifierText, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
3
3
  import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.21.0/FSharp.Core.js";
4
- import { length, truncate, isEmpty, exists as exists_1, choose, cons, collect as collect_1, singleton, tryFind, fold, append, empty, reverse } from "../../fable_modules/fable-library-js.5.21.0/List.js";
5
- import { toArray, defaultArg, value as value_1 } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
6
- import { tryHead, tryFindIndex, collect as collect_2, empty as empty_3, singleton as singleton_1, append as append_1, delay, filter, map, exists, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
7
- import { FSharpMap__get_Count, FSharpMap__get_Values, FSharpMap__TryFind, empty as empty_1, FSharpMap__ContainsKey, FSharpMap__Add } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
8
- import { comparePrimitives } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
4
+ import { length, truncate, ofSeq, contains, filter as filter_1, isEmpty, exists as exists_1, choose, cons, collect as collect_1, singleton, tryFind, fold, append, empty, reverse } from "../../fable_modules/fable-library-js.5.21.0/List.js";
5
+ import { toArray, defaultArg, value as value_2 } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
6
+ import { tryHead, tryFindIndex, filter, map, exists, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
7
+ import { Record } from "../../fable_modules/fable-library-js.5.21.0/Types.js";
8
+ import { record_type, class_type, string_type } from "../../fable_modules/fable-library-js.5.21.0/Reflection.js";
9
9
  import { ts } from "@ts-morph/bootstrap";
10
+ import { containsKey, add, FSharpMap__get_Count, FSharpMap__get_Values, FSharpMap__TryFind, empty as empty_1, FSharpMap__ContainsKey, FSharpMap__Add } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
11
+ import { curry3, uncurry2, stringHash, comparePrimitives } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
10
12
  import { empty as empty_2, FSharpSet__Add, FSharpSet__Contains } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
11
13
  import { GlueClassDeclaration, GluePrimitive, GlueType } from "../GlueAST.js";
12
14
  import { item } from "../../fable_modules/fable-library-js.5.21.0/Array.js";
@@ -37,8 +39,8 @@ function typeParametersInScope(reader, typeNode) {
37
39
  if (Operators_IsNull(node)) {
38
40
  return reverse(acc);
39
41
  }
40
- else if (((Operators_IsNull(node.parent) && (node.pos < 0)) && (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]() != null)) && !(node === value_1(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]()))) {
41
- node_mut = value_1(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]());
42
+ else if (((Operators_IsNull(node.parent) && (node.pos < 0)) && (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]() != null)) && !(node === value_2(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]()))) {
43
+ node_mut = value_2(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]());
42
44
  acc_mut = acc;
43
45
  continue collect;
44
46
  }
@@ -75,13 +77,26 @@ function isDeclaredByType(typeParameter) {
75
77
  }
76
78
  }
77
79
 
80
+ class Bindings extends Record {
81
+ constructor(Checked, Compared) {
82
+ super();
83
+ this.Checked = Checked;
84
+ this.Compared = Compared;
85
+ }
86
+ }
87
+
88
+ function Bindings_$reflection() {
89
+ return record_type("Glutinum.Converter.Reader.Deferred.Bindings", [], Bindings, () => [["Checked", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, class_type("TypeScript.Ts.TypeNode")])], ["Compared", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, class_type("TypeScript.Ts.TypeNode")])]]);
90
+ }
91
+
78
92
  function boundTypeParameters(reader, typeNode) {
79
- return fold((bound, typeParameter) => {
80
- let constraint_, default_;
81
- const name = identifierText(typeParameter.name);
93
+ const typeParameters = typeParametersInScope(reader, typeNode);
94
+ const checkedBindings = fold((bound, typeParameter_1) => {
95
+ let constraint_, default_, typeParameter, name, signature, mentions;
96
+ const name_1 = identifierText(typeParameter_1.name);
82
97
  let binding;
83
- const matchValue = typeParameter.default;
84
- const matchValue_1 = typeParameter.constraint;
98
+ const matchValue = typeParameter_1.default;
99
+ const matchValue_1 = typeParameter_1.constraint;
85
100
  let matchResult, default__1, constraint__1;
86
101
  if (matchValue == null) {
87
102
  if (matchValue_1 != null) {
@@ -97,7 +112,14 @@ function boundTypeParameters(reader, typeNode) {
97
112
  matchResult = 3;
98
113
  }
99
114
  }
100
- else if ((default_ = matchValue, isDeclaredByType(typeParameter) && (default_.kind !== 133))) {
115
+ else if ((default_ = matchValue, (isDeclaredByType(typeParameter_1) ? true : ((typeParameter = typeParameter_1, (name = identifierText(typeParameter.name), (signature = typeParameter.parent, (mentions = ((node) => {
116
+ if ((node.kind === 184) && (entityNameText(node.typeName) === name)) {
117
+ return true;
118
+ }
119
+ else {
120
+ return defaultArg(ts.forEachChild(node, ((child) => (mentions(child) ? true : undefined))), false);
121
+ }
122
+ }), ((!Operators_IsNull(signature) && !isDeclaredByType(typeParameter)) && !Operators_IsNull(signature.parameters)) && !exists(mentions, signature.parameters))))))) && (default_.kind !== 133))) {
101
123
  matchResult = 0;
102
124
  default__1 = matchValue;
103
125
  }
@@ -122,7 +144,7 @@ function boundTypeParameters(reader, typeNode) {
122
144
  }
123
145
  let matchResult_1, binding_2;
124
146
  if (binding != null) {
125
- if (!FSharpMap__ContainsKey(bound, name)) {
147
+ if (!FSharpMap__ContainsKey(bound, name_1)) {
126
148
  matchResult_1 = 0;
127
149
  binding_2 = binding;
128
150
  }
@@ -135,13 +157,37 @@ function boundTypeParameters(reader, typeNode) {
135
157
  }
136
158
  switch (matchResult_1) {
137
159
  case 0:
138
- return FSharpMap__Add(bound, name, binding_2);
160
+ return FSharpMap__Add(bound, name_1, binding_2);
139
161
  default:
140
162
  return bound;
141
163
  }
142
164
  }, empty_1({
143
165
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
144
- }), typeParametersInScope(reader, typeNode));
166
+ }), typeParameters);
167
+ return new Bindings(checkedBindings, fold((bound_1, typeParameter_2) => {
168
+ let default__2;
169
+ const name_2 = identifierText(typeParameter_2.name);
170
+ const matchValue_3 = typeParameter_2.default;
171
+ let matchResult_2, default__3;
172
+ if (matchValue_3 != null) {
173
+ if ((default__2 = matchValue_3, (isDeclaredByType(typeParameter_2) && (default__2.kind === 133)) && !FSharpMap__ContainsKey(bound_1, name_2))) {
174
+ matchResult_2 = 0;
175
+ default__3 = matchValue_3;
176
+ }
177
+ else {
178
+ matchResult_2 = 1;
179
+ }
180
+ }
181
+ else {
182
+ matchResult_2 = 1;
183
+ }
184
+ switch (matchResult_2) {
185
+ case 0:
186
+ return FSharpMap__Add(bound_1, name_2, default__3);
187
+ default:
188
+ return bound_1;
189
+ }
190
+ }, checkedBindings, typeParameters));
145
191
  }
146
192
 
147
193
  /**
@@ -340,37 +386,46 @@ function resolveWithBindings(checker_mut, typeNode_mut, bindings_mut, bound_mut,
340
386
  }
341
387
  else {
342
388
  const alreadyBound = FSharpMap__get_Count(bound) | 0;
343
- const bound_3 = fold((bound_1, conditional) => fold((bound_2, name) => {
344
- const matchValue = FSharpMap__TryFind(bindings, name);
345
- let matchResult, binding_1;
346
- if (matchValue != null) {
347
- if (!FSharpMap__ContainsKey(bound_2, name)) {
348
- matchResult = 0;
349
- binding_1 = matchValue;
389
+ const bound_4 = fold((bound_1, conditional) => {
390
+ const checkedNames = typeParameterNamesOf(checker, conditional.checkType);
391
+ const comparedNames = filter_1((name) => !contains(name, checkedNames, {
392
+ Equals: (x, y) => (x === y),
393
+ GetHashCode: (x) => (stringHash(x) | 0),
394
+ }), typeParameterNamesOf(checker, conditional.extendsType));
395
+ const bind = (candidates, bound_2, name_1) => {
396
+ const matchValue = FSharpMap__TryFind(candidates, name_1);
397
+ let matchResult, binding_1;
398
+ if (matchValue != null) {
399
+ if (!containsKey(name_1, bound_2)) {
400
+ matchResult = 0;
401
+ binding_1 = matchValue;
402
+ }
403
+ else {
404
+ matchResult = 1;
405
+ }
350
406
  }
351
407
  else {
352
408
  matchResult = 1;
353
409
  }
354
- }
355
- else {
356
- matchResult = 1;
357
- }
358
- switch (matchResult) {
359
- case 0:
360
- return FSharpMap__Add(bound_2, name, binding_1);
361
- default:
362
- return bound_2;
363
- }
364
- }, bound_1, append(typeParameterNamesOf(checker, conditional.checkType), typeParameterNamesOf(checker, conditional.extendsType))), bound, conditionals);
365
- if ((FSharpMap__get_Count(bound_3) === alreadyBound) ? true : !mentionsBoundTypeParameter(bound_3, typeNode)) {
410
+ switch (matchResult) {
411
+ case 0:
412
+ return add(name_1, binding_1, bound_2);
413
+ default:
414
+ return bound_2;
415
+ }
416
+ };
417
+ const bound_3 = fold(uncurry2(curry3(bind)(bindings.Checked)), bound_1, checkedNames);
418
+ return fold(uncurry2(curry3(bind)(bindings.Compared)), bound_3, comparedNames);
419
+ }, bound, conditionals);
420
+ if ((FSharpMap__get_Count(bound_4) === alreadyBound) ? true : !mentionsBoundTypeParameter(bound_4, typeNode)) {
366
421
  return undefined;
367
422
  }
368
423
  else {
369
424
  checker_mut = checker;
370
425
  typeNode_mut = typeNode;
371
426
  bindings_mut = bindings;
372
- bound_mut = bound_3;
373
- typ_mut = checker.getTypeFromTypeNode(substituteBoundTypeParameters(bound_3, typeNode));
427
+ bound_mut = bound_4;
428
+ typ_mut = checker.getTypeFromTypeNode(substituteBoundTypeParameters(bound_4, typeNode));
374
429
  continue resolveWithBindings;
375
430
  }
376
431
  }
@@ -462,7 +517,7 @@ export function tryResolveDeferred(reader, typeNode) {
462
517
  const bindings = boundTypeParameters(reader, typeNode);
463
518
  if (((!isParseTreeNode(typeNode) ? true : !standsForConditional(checker, empty_2({
464
519
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
465
- }), typeNode)) ? true : isWithinConstraint(typeNode)) ? true : !mentionsBoundTypeParameter(bindings, typeNode)) {
520
+ }), typeNode)) ? true : isWithinConstraint(typeNode)) ? true : !mentionsBoundTypeParameter(bindings.Compared, typeNode)) {
466
521
  return undefined;
467
522
  }
468
523
  else {
@@ -500,7 +555,15 @@ export function tryResolveDeferred(reader, typeNode) {
500
555
  }
501
556
 
502
557
  export function inferTypeNodes(node) {
503
- return toList(delay(() => append_1((node.kind === 196) ? singleton_1(node) : empty_3(), delay(() => collect_2(inferTypeNodes, node.getChildren())))));
558
+ const found = [];
559
+ const visit = (node_1) => {
560
+ if (node_1.kind === 196) {
561
+ void (found.push(node_1));
562
+ }
563
+ return ts.forEachChild(node_1, visit);
564
+ };
565
+ visit(node);
566
+ return ofSeq(found);
504
567
  }
505
568
 
506
569
  /**
@@ -511,7 +574,11 @@ export function inferredConstraint(reader, inferTypeNode) {
511
574
  const matchValue_1 = inferTypeNode.typeParameter.constraint;
512
575
  if (matchValue_1 == null) {
513
576
  let atPosition;
514
- if (inferTypeNode.parent.kind === 184) {
577
+ const matchValue_2 = inferTypeNode.parent;
578
+ if (Operators_IsNull(matchValue_2)) {
579
+ atPosition = undefined;
580
+ }
581
+ else if (matchValue_2.kind === 184) {
515
582
  const typeReferenceNode = inferTypeNode.parent;
516
583
  let position;
517
584
  const option_1 = typeReferenceNode.typeArguments;
@@ -675,8 +742,10 @@ export function readTypeUsingFlags(reader, typ) {
675
742
  const declaration = item(0, declarations_1);
676
743
  const matchValue_2 = declaration.kind;
677
744
  switch (matchValue_2) {
678
- case 264:
679
- return new GlueType(/* ClassDeclaration */ 12, [new GlueClassDeclaration(empty(), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getFullyQualifiedName(typ.symbol), typ.symbol.name, empty(), empty(), empty(), empty(), true)]);
745
+ case 185:
746
+ case 186:
747
+ case 188:
748
+ case 201:
680
749
  case 265:
681
750
  case 266: {
682
751
  const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
@@ -688,6 +757,8 @@ export function readTypeUsingFlags(reader, typ) {
688
757
  return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
689
758
  }
690
759
  }
760
+ case 264:
761
+ return new GlueType(/* ClassDeclaration */ 12, [new GlueClassDeclaration(empty(), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getFullyQualifiedName(typ.symbol), typ.symbol.name, empty(), empty(), empty(), empty(), true)]);
691
762
  case 268:
692
763
  return GlueType.Discard;
693
764
  default: