@glutinum/cli 1.0.0-beta.6 → 1.0.0-beta.8
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.
- package/dist/Glutinum.Converter/GlueAST.js +3 -2
- package/dist/Glutinum.Converter/Hosting.js +2 -2
- package/dist/Glutinum.Converter/Packages.js +13 -22
- package/dist/Glutinum.Converter/Read.js +103 -140
- package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
- package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
- package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
- package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
- package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +53 -5
- package/dist/Glutinum.Converter/Reader/Node.js +3 -3
- package/dist/Glutinum.Converter/Reader/Parameters.js +3 -2
- package/dist/Glutinum.Converter/Reader/TypeNode.js +102 -1941
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +53 -14
- package/dist/Glutinum.Converter/Reader/Types.js +5 -0
- package/dist/Glutinum.Converter/Reader/UtilityType.js +803 -0
- package/dist/Glutinum.Converter/Reader/Utils.js +149 -78
- package/dist/Glutinum.Converter/Transform.js +274 -1163
- package/dist/Glutinum.Converter/Transformer/Conditionals.js +2 -64
- package/dist/Glutinum.Converter/Transformer/Context.js +23 -10
- package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +89 -2
- package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
import { defaultArg, orElse } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
3
|
+
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
|
|
4
|
+
import { resolvedBaseTypeArguments, typeNodeBuilderFlags, readTypeArguments, landingOf, crossesNamespace, modulePathForSymbol, isLibraryName, resolveValueAlias, knownExternalTypeNames, isExternalToPackages, declaredName, getFullNameOrEmpty, isFromEs5Lib } from "./Utils.js";
|
|
5
|
+
import { readPick, readOmit } from "./UtilityType.js";
|
|
6
|
+
import { FSharpSet__Contains } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
|
|
7
|
+
import { GlueTypeReference, GlueType } from "../GlueAST.js";
|
|
8
|
+
import { sanitizeTypeName } from "../Utils/Naming.js";
|
|
9
|
+
import { map, isEmpty, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
10
|
+
import { toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
11
|
+
|
|
12
|
+
export function readExpressionWithTypeArguments(reader, typeNode) {
|
|
13
|
+
let symbol, symbol_2, symbol_3, symbol_4, matchValue_2, option_4, symbol_6, matchValue_3, ofAlias, matchValue_4, matchValue_5, alias, written, option_6;
|
|
14
|
+
const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
15
|
+
const expression = typeNode;
|
|
16
|
+
const typ = checker.getTypeFromTypeNode(expression);
|
|
17
|
+
const symbolOpt = orElse(orElse(typ.aliasSymbol, Operators_IsNull(typ.symbol) ? undefined : typ.symbol), checker.getSymbolAtLocation(expression.expression));
|
|
18
|
+
const isFromEs5 = isFromEs5Lib(symbolOpt);
|
|
19
|
+
const matchValue = getFullNameOrEmpty(checker, expression.expression);
|
|
20
|
+
let matchResult;
|
|
21
|
+
if (isFromEs5) {
|
|
22
|
+
switch (matchValue) {
|
|
23
|
+
case "Omit": {
|
|
24
|
+
matchResult = 0;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
case "Pick": {
|
|
28
|
+
matchResult = 1;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
default:
|
|
32
|
+
matchResult = 2;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
matchResult = 2;
|
|
37
|
+
}
|
|
38
|
+
switch (matchResult) {
|
|
39
|
+
case 0:
|
|
40
|
+
return readOmit(reader, expression);
|
|
41
|
+
case 1:
|
|
42
|
+
return readPick(reader, expression);
|
|
43
|
+
default: {
|
|
44
|
+
const isQualified = expression.expression.kind === 212;
|
|
45
|
+
const name = (symbolOpt != null) ? (((symbol = symbolOpt, symbol.name === "default")) ? ((symbol_2 = symbolOpt, defaultArg(declaredName(symbol_2), symbol_2.name))) : ((!isFromEs5) ? ((symbol_3 = symbolOpt, symbol_3.name)) : (isQualified ? expression.expression.name.text : expression.expression.getText()))) : (isQualified ? expression.expression.name.text : expression.expression.getText());
|
|
46
|
+
const isExternal = isExternalToPackages(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbolOpt);
|
|
47
|
+
if (((symbolOpt == null) ? false : ((symbol_4 = symbolOpt, (symbol_4.name === "__type") ? true : (symbol_4.name === "__object")))) ? true : ((isExternal && !FSharpSet__Contains(knownExternalTypeNames, name)) && !(isFromEs5 && (name === "Partial")))) {
|
|
48
|
+
return GlueType.Discard;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return new GlueType(/* TypeReference */ 13, [new GlueTypeReference((name.indexOf(".") >= 0) ? name : sanitizeTypeName(name), (matchValue_2 = ((option_4 = symbolOpt, (option_4 != null) ? resolveValueAlias(checker, option_4) : undefined)), (matchValue_2 == null) ? getFullNameOrEmpty(checker, expression.expression) : ((symbol_6 = matchValue_2, checker.getFullyQualifiedName(symbol_6)))), isLibraryName(reader, name) ? empty() : modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), isQualified ? true : crossesNamespace(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbolOpt, landingOf(reader, expression)), symbolOpt), (matchValue_3 = readTypeArguments(reader, expression), isEmpty(matchValue_3) ? ((ofAlias = (((matchValue_4 = checker.getSymbolAtLocation(expression.expression), (matchValue_5 = typ.aliasSymbol, (matchValue_4 != null) && ((matchValue_5 != null) && ((alias = matchValue_5, (written = matchValue_4, !(written === alias)))))))) ? defaultArg((option_6 = typ.aliasTypeArguments, (option_6 != null) ? toList(option_6) : undefined), empty()) : empty()), map((argument) => {
|
|
52
|
+
const typNode = checker.typeToTypeNode(argument, undefined, typeNodeBuilderFlags);
|
|
53
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode);
|
|
54
|
+
}, isEmpty(ofAlias) ? resolvedBaseTypeArguments(checker, expression) : ofAlias))) : matchValue_3), (isFromEs5 ? true : isExternal) ? true : isLibraryName(reader, name))]);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
|
|
2
|
+
import { Exception, stringHash, structuralHash, equals, disposeSafe } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
3
|
+
import { head, tail, append, forAll as forAll_1, filter, empty, exists as exists_1, collect, isEmpty, map, concat, choose } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
4
|
+
import { readInstantiatedMember, readPropertyWithoutDeclaration, IntersectionTypePropertyResult } from "./MemberTypes.js";
|
|
5
|
+
import { item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
6
|
+
import { filter as filter_1, exists, toList, forAll } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
7
|
+
import { List_distinctBy, List_distinct } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
8
|
+
import { withInProgress, typeNodeBuilderFlags } from "./Utils.js";
|
|
9
|
+
import { GluePrimitive, GlueType } from "../GlueAST.js";
|
|
10
|
+
|
|
11
|
+
function readIntersectionConstituents(reader, typeNode) {
|
|
12
|
+
let matchValue;
|
|
13
|
+
const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
14
|
+
const intersectionTypeNode = typeNode;
|
|
15
|
+
const unionOrIntersectionType = checker.getTypeAtLocation(intersectionTypeNode);
|
|
16
|
+
void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections.push(unionOrIntersectionType));
|
|
17
|
+
const _guard = {
|
|
18
|
+
Dispose() {
|
|
19
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections.splice(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Intersections.length - 1, 1);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
const properties_1 = choose((property_1) => {
|
|
24
|
+
const matchValue_1 = property_1.declarations;
|
|
25
|
+
if (matchValue_1 == null) {
|
|
26
|
+
return new IntersectionTypePropertyResult(/* WithoutDeclaration */ 1, [property_1]);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const declarations = matchValue_1;
|
|
30
|
+
if (declarations.length === 1) {
|
|
31
|
+
return new IntersectionTypePropertyResult(/* Single */ 0, [property_1, item(0, declarations)]);
|
|
32
|
+
}
|
|
33
|
+
else if (forAll((declaration) => {
|
|
34
|
+
if (declaration.kind === 172) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return declaration.kind === 173;
|
|
39
|
+
}
|
|
40
|
+
}, declarations)) {
|
|
41
|
+
return new IntersectionTypePropertyResult(/* WithoutDeclaration */ 1, [property_1]);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return IntersectionTypePropertyResult.ForceAny;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, unionOrIntersectionType.isUnion() ? List_distinct(concat(map((arg) => toList(checker.getPropertiesOfType(arg)), toList(unionOrIntersectionType.types))), {
|
|
48
|
+
Equals: equals,
|
|
49
|
+
GetHashCode: (x) => (structuralHash(x) | 0),
|
|
50
|
+
}) : ((matchValue = toList(unionOrIntersectionType.getProperties()), isEmpty(matchValue) ? ((intersectionTypeNode.pos >= 0) ? List_distinctBy((property) => property.name, collect((constituent) => {
|
|
51
|
+
let type_1;
|
|
52
|
+
return toList((type_1 = checker.getTypeAtLocation(constituent), checker.getPropertiesOfType(type_1)));
|
|
53
|
+
}, toList(intersectionTypeNode.types)), {
|
|
54
|
+
Equals: (x_1, y_1) => (x_1 === y_1),
|
|
55
|
+
GetHashCode: (x_1) => (stringHash(x_1) | 0),
|
|
56
|
+
}) : matchValue) : matchValue)));
|
|
57
|
+
const intersectsATypeQuery = exists((constituent_1) => (constituent_1.kind === 187), intersectionTypeNode.types);
|
|
58
|
+
const everyConstituentIsAReference = forAll((constituent_2) => (constituent_2.kind === 184), intersectionTypeNode.types);
|
|
59
|
+
const hasUnsupportedProperties = intersectsATypeQuery ? true : exists_1((property_2) => {
|
|
60
|
+
switch (property_2.tag) {
|
|
61
|
+
case 1:
|
|
62
|
+
return false;
|
|
63
|
+
case 0:
|
|
64
|
+
if (everyConstituentIsAReference) {
|
|
65
|
+
return property_2.fields[1].kind === 175;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
default:
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}, properties_1);
|
|
74
|
+
const callSignatures = unionOrIntersectionType.isUnion() ? empty() : choose((signature) => {
|
|
75
|
+
const synthesized = checker.signatureToSignatureDeclaration(signature, 180, typeNode, typeNodeBuilderFlags);
|
|
76
|
+
if (synthesized == null) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const declaration_2 = synthesized;
|
|
81
|
+
declaration_2.parent = typeNode;
|
|
82
|
+
const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
|
|
83
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](declaration_2);
|
|
84
|
+
try {
|
|
85
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_2);
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, toList(checker.getSignaturesOfType(unionOrIntersectionType, 0)));
|
|
92
|
+
if (hasUnsupportedProperties) {
|
|
93
|
+
const references = map((constituent_3) => {
|
|
94
|
+
if (constituent_3.kind === 184) {
|
|
95
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constituent_3);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return GlueType.Discard;
|
|
99
|
+
}
|
|
100
|
+
}, toList(intersectionTypeNode.types));
|
|
101
|
+
const literalMembers = collect((constituent_4) => {
|
|
102
|
+
if (constituent_4.kind === 188) {
|
|
103
|
+
const matchValue_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constituent_4);
|
|
104
|
+
if (matchValue_2.tag === 22) {
|
|
105
|
+
return matchValue_2.fields[0].Members;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return empty();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return empty();
|
|
113
|
+
}
|
|
114
|
+
}, toList(intersectionTypeNode.types));
|
|
115
|
+
const inheritable = filter((reference) => !equals(reference, GlueType.Discard), references);
|
|
116
|
+
return (!isEmpty(inheritable) && forAll_1((_arg) => {
|
|
117
|
+
if (_arg.tag === 13) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}, inheritable)) ? (new GlueType(/* IntersectionOfReferences */ 21, [inheritable, literalMembers])) : (new GlueType(/* Primitive */ 3, [GluePrimitive.Any]));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return new GlueType(/* IntersectionType */ 20, [append(withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing, typeNode, () => choose((_arg_1) => {
|
|
127
|
+
switch (_arg_1.tag) {
|
|
128
|
+
case 1:
|
|
129
|
+
return readPropertyWithoutDeclaration(reader, typeNode, _arg_1.fields[0]);
|
|
130
|
+
case 2:
|
|
131
|
+
throw new Exception("Should not happen here");
|
|
132
|
+
default:
|
|
133
|
+
return readInstantiatedMember(reader, typeNode, _arg_1.fields[0], _arg_1.fields[1]);
|
|
134
|
+
}
|
|
135
|
+
}, properties_1)), append(callSignatures, collect((constituent_5) => {
|
|
136
|
+
if (constituent_5.kind === 188) {
|
|
137
|
+
return map((declaration_4) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_4), filter((element) => (element.kind === 182), toList(constituent_5.members)));
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
return empty();
|
|
141
|
+
}
|
|
142
|
+
}, toList(intersectionTypeNode.types))))]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
disposeSafe(_guard);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* `DateArg<Date> & {}` is `DateArg<Date>`, the empty type literal only bars `null`
|
|
152
|
+
*/
|
|
153
|
+
export function readIntersectionType(reader, typeNode) {
|
|
154
|
+
const constituents = toList(filter_1((arg) => {
|
|
155
|
+
let constituent, this$;
|
|
156
|
+
return !((constituent = arg, (constituent.kind === 188) && (((this$ = constituent.members, ~~this$.length)) === 0)));
|
|
157
|
+
}, typeNode.types));
|
|
158
|
+
let matchResult, single;
|
|
159
|
+
if (!isEmpty(constituents)) {
|
|
160
|
+
if (isEmpty(tail(constituents))) {
|
|
161
|
+
matchResult = 0;
|
|
162
|
+
single = head(constituents);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
matchResult = 1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
matchResult = 1;
|
|
170
|
+
}
|
|
171
|
+
switch (matchResult) {
|
|
172
|
+
case 0:
|
|
173
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](single);
|
|
174
|
+
default:
|
|
175
|
+
return readIntersectionConstituents(reader, typeNode);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
|
|
2
|
+
import { Union } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
3
|
+
import { union_type, class_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
|
|
4
|
+
import { enclosingDeclarationOf, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags } from "./Utils.js";
|
|
5
|
+
import { Report_readerError_Z19516DCE } from "./Report.js";
|
|
6
|
+
import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
|
|
7
|
+
import { empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
8
|
+
import { GlueMethod, GlueMethodSignature, GlueMember, GlueProperty, GlueAccessor } from "../GlueAST.js";
|
|
9
|
+
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
|
|
10
|
+
|
|
11
|
+
export class IntersectionTypePropertyResult extends Union {
|
|
12
|
+
constructor(tag, fields) {
|
|
13
|
+
super();
|
|
14
|
+
this.tag = tag;
|
|
15
|
+
this.fields = fields;
|
|
16
|
+
}
|
|
17
|
+
cases() {
|
|
18
|
+
return ["Single", "WithoutDeclaration", "ForceAny"];
|
|
19
|
+
}
|
|
20
|
+
static ForceAny = new IntersectionTypePropertyResult(2, []);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function IntersectionTypePropertyResult_$reflection() {
|
|
24
|
+
return union_type("Glutinum.Converter.Reader.MemberTypes.IntersectionTypePropertyResult", [], IntersectionTypePropertyResult, () => [[["Item1", class_type("TypeScript.Ts.Symbol")], ["Item2", class_type("TypeScript.Ts.Declaration")]], [["Item", class_type("TypeScript.Ts.Symbol")]], []]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function readPropertyWithoutDeclaration(reader, contextNode, property) {
|
|
28
|
+
let matchValue_1;
|
|
29
|
+
const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeOfSymbol(property);
|
|
30
|
+
const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
|
|
31
|
+
if (matchValue == null) {
|
|
32
|
+
const item = Report_readerError_Z19516DCE("type node", concat("Could not resolve the type of the property \'", property.name, "\'"), contextNode, "/_//src/Glutinum.Converter/Reader/MemberTypes.fs", 52);
|
|
33
|
+
const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
34
|
+
void (objectArg.push(item));
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const typeNode = matchValue;
|
|
39
|
+
const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
|
|
40
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](contextNode);
|
|
41
|
+
let propertyType;
|
|
42
|
+
try {
|
|
43
|
+
propertyType = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
|
|
47
|
+
}
|
|
48
|
+
return new GlueMember(/* Property */ 1, [new GlueProperty(property.name, empty(), propertyType, false, (matchValue_1 = property.flags, $007CHasSymbolFlags$007C_$007C(16777216, matchValue_1) != null), GlueAccessor.ReadWrite, false)]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function readInstantiatedMember(reader, contextNode, property, declaration) {
|
|
53
|
+
const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
54
|
+
const instantiatedType = checker.getTypeOfSymbol(property);
|
|
55
|
+
const isInstantiated = !Operators_IsNull(declaration.symbol) && !(instantiatedType === checker.getTypeOfSymbol(declaration.symbol));
|
|
56
|
+
const declaredMember = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration);
|
|
57
|
+
if (!isInstantiated) {
|
|
58
|
+
return declaredMember;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const matchValue = checker.typeToTypeNode(instantiatedType, enclosingDeclarationOf(contextNode), typeNodeBuilderFlags);
|
|
62
|
+
if (matchValue != null) {
|
|
63
|
+
const typeNode = matchValue;
|
|
64
|
+
const previousContext = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
|
|
65
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](contextNode);
|
|
66
|
+
let instantiatedMember;
|
|
67
|
+
try {
|
|
68
|
+
instantiatedMember = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.set_SyntheticContext"](previousContext);
|
|
72
|
+
}
|
|
73
|
+
let matchResult, info, typ, functionType, info_1, functionType_1, info_2, declaredMember_1;
|
|
74
|
+
switch (declaredMember.tag) {
|
|
75
|
+
case 1: {
|
|
76
|
+
matchResult = 0;
|
|
77
|
+
info = declaredMember.fields[0];
|
|
78
|
+
typ = instantiatedMember;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 6: {
|
|
82
|
+
if (instantiatedMember.tag === 15) {
|
|
83
|
+
matchResult = 1;
|
|
84
|
+
functionType = instantiatedMember.fields[0];
|
|
85
|
+
info_1 = declaredMember.fields[0];
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
matchResult = 3;
|
|
89
|
+
declaredMember_1 = declaredMember;
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case 0: {
|
|
94
|
+
if (instantiatedMember.tag === 15) {
|
|
95
|
+
matchResult = 2;
|
|
96
|
+
functionType_1 = instantiatedMember.fields[0];
|
|
97
|
+
info_2 = declaredMember.fields[0];
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
matchResult = 3;
|
|
101
|
+
declaredMember_1 = declaredMember;
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
default: {
|
|
106
|
+
matchResult = 3;
|
|
107
|
+
declaredMember_1 = declaredMember;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
switch (matchResult) {
|
|
111
|
+
case 0:
|
|
112
|
+
return new GlueMember(/* Property */ 1, [new GlueProperty(info.Name, info.Documentation, typ, info.IsStatic, info.IsOptional, info.Accessor, info.IsPrivate)]);
|
|
113
|
+
case 1:
|
|
114
|
+
return new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature(info_1.Name, info_1.Documentation, info_1.TypeParameters, functionType.Parameters, functionType.Type, info_1.IsOptional)]);
|
|
115
|
+
case 2:
|
|
116
|
+
return new GlueMember(/* Method */ 0, [new GlueMethod(info_2.Name, info_2.Documentation, info_2.TypeParameters, functionType_1.Parameters, functionType_1.Type, info_2.IsOptional, info_2.IsStatic)]);
|
|
117
|
+
default:
|
|
118
|
+
return declaredMember_1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
return declaredMember;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
|
|
2
2
|
import { choose, concat, toList, exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { isExportedDeclaration, isGlobalAugmentation, isTopLevelModuleDeclaration, isMergedInterfaceDeclaration, identifierText } from "./Utils.js";
|
|
4
|
+
import { ofSeq, filter, empty, map, collect, singleton } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
5
|
+
import { singleton as singleton_1 } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
|
|
6
|
+
import { comparePrimitives } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
5
7
|
import { GlueModuleDeclaration } from "../GlueAST.js";
|
|
6
8
|
|
|
7
9
|
export function readModuleDeclaration(reader, declaration) {
|
|
8
10
|
const name = declaration.name;
|
|
9
11
|
const children = declaration.getChildren();
|
|
10
|
-
const
|
|
12
|
+
const isBodyOfDottedName = (declaration.parent.kind === 268) && (declaration.parent.body === declaration);
|
|
13
|
+
const isNamespace = isBodyOfDottedName ? true : exists((node) => (node.kind === 145), children);
|
|
14
|
+
const isAmbientModule = declaration.name.kind === 11;
|
|
15
|
+
const isExportAssigned = exists((statement) => {
|
|
16
|
+
if (statement.kind === 278) {
|
|
17
|
+
const expression = statement.expression;
|
|
18
|
+
if (expression.kind === 80) {
|
|
19
|
+
return identifierText(expression) === name.getText();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}, declaration.getSourceFile().statements);
|
|
11
29
|
const types = toList(concat(choose((child) => {
|
|
12
30
|
const matchValue = child.kind;
|
|
13
31
|
switch (matchValue) {
|
|
@@ -15,12 +33,42 @@ export function readModuleDeclaration(reader, declaration) {
|
|
|
15
33
|
return singleton(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](child));
|
|
16
34
|
case 269: {
|
|
17
35
|
const moduleBlock = child;
|
|
18
|
-
return
|
|
36
|
+
return collect((statement_2) => {
|
|
37
|
+
let exportClause;
|
|
38
|
+
if (statement_2.kind === 279) {
|
|
39
|
+
const exportDeclaration = statement_2;
|
|
40
|
+
const matchValue_2 = exportDeclaration.exportClause;
|
|
41
|
+
let matchResult, exportClause_1;
|
|
42
|
+
if (matchValue_2 != null) {
|
|
43
|
+
if ((exportClause = matchValue_2, (exportDeclaration.moduleSpecifier == null) && (exportClause.kind === 280))) {
|
|
44
|
+
matchResult = 0;
|
|
45
|
+
exportClause_1 = matchValue_2;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
matchResult = 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
matchResult = 1;
|
|
53
|
+
}
|
|
54
|
+
switch (matchResult) {
|
|
55
|
+
case 0:
|
|
56
|
+
return map((node_1) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](node_1), toList(exportClause_1.elements));
|
|
57
|
+
default:
|
|
58
|
+
return empty();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return singleton(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](statement_2));
|
|
63
|
+
}
|
|
64
|
+
}, filter((statement_1) => !isMergedInterfaceDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), statement_1), ofSeq(moduleBlock.statements)));
|
|
19
65
|
}
|
|
20
66
|
default:
|
|
21
67
|
return undefined;
|
|
22
68
|
}
|
|
23
69
|
}, children)));
|
|
24
|
-
return new GlueModuleDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](declaration), name.getText(), isTopLevelModuleDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), declaration), isNamespace, (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]() != null) && isGlobalAugmentation(declaration),
|
|
70
|
+
return new GlueModuleDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](declaration), name.getText(), isTopLevelModuleDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), declaration), isNamespace, (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]() != null) && isGlobalAugmentation(declaration), ((isAmbientModule ? true : isBodyOfDottedName) ? true : isExportAssigned) ? true : isExportedDeclaration(declaration, singleton_1(name.getText(), {
|
|
71
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
72
|
+
})), false, types);
|
|
25
73
|
}
|
|
26
74
|
|
|
@@ -9,7 +9,7 @@ import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
|
|
|
9
9
|
import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
|
|
10
10
|
|
|
11
11
|
export function readNode(reader, node) {
|
|
12
|
-
let option_3, option, binder, checker, option_1, target, matchValue_1, declarations, declarations_1, declaration, matchValue_2;
|
|
12
|
+
let option_3, option, binder, checker, option_1, target, matchValue_1, declarations, declarations_1, declaration, declaration_1, matchValue_2;
|
|
13
13
|
const matchValue = node.kind;
|
|
14
14
|
switch (matchValue) {
|
|
15
15
|
case 136:
|
|
@@ -44,10 +44,10 @@ export function readNode(reader, node) {
|
|
|
44
44
|
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadExportAssignmentZ3497D0FE"](node);
|
|
45
45
|
case 282: {
|
|
46
46
|
const exportSpecifier = node;
|
|
47
|
-
return defaultArg((option_3 = ((option = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getExportSpecifierLocalTargetSymbol(exportSpecifier), (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) ? ((target = option_3, (matchValue_1 = target.declarations, (matchValue_1 != null) ? (((declarations = matchValue_1, declarations.length > 0)) ? ((declarations_1 = matchValue_1, (declaration = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](
|
|
47
|
+
return defaultArg((option_3 = ((option = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getExportSpecifierLocalTargetSymbol(exportSpecifier), (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) ? ((target = option_3, (matchValue_1 = target.declarations, (matchValue_1 != null) ? (((declarations = matchValue_1, declarations.length > 0)) ? ((declarations_1 = matchValue_1, (declaration = item(0, declarations_1), (declaration_1 = ((declaration.kind === 261) ? reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration.parent.parent) : reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration)), (matchValue_2 = exportSpecifier.propertyName, (matchValue_2 == null) ? declaration_1 : (new GlueType(/* ReExport */ 32, [new GlueReExport(moduleExportNameText(exportSpecifier.name), declaration_1, empty())]))))))) : undefined) : undefined))) : undefined), GlueType.Discard);
|
|
48
48
|
}
|
|
49
49
|
default: {
|
|
50
|
-
const warning = Report_readerError_Z19516DCE("node", concat("Unsupported node kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue)), node, "/_//src/Glutinum.Converter/Reader/Node.fs",
|
|
50
|
+
const warning = Report_readerError_Z19516DCE("node", concat("Unsupported node kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue)), node, "/_//src/Glutinum.Converter/Reader/Node.fs", 83);
|
|
51
51
|
void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning));
|
|
52
52
|
return GlueType.Discard;
|
|
53
53
|
}
|
|
@@ -18,12 +18,13 @@ export function readParameters(reader, parameters) {
|
|
|
18
18
|
name = identifierText(nameNode_1);
|
|
19
19
|
break;
|
|
20
20
|
}
|
|
21
|
-
case 207:
|
|
21
|
+
case 207:
|
|
22
|
+
case 208: {
|
|
22
23
|
name = (`arg${index}`);
|
|
23
24
|
break;
|
|
24
25
|
}
|
|
25
26
|
default: {
|
|
26
|
-
const item = Report_readerError_Z19516DCE("name", concat_1("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(nameNode_1.kind)), nameNode_1, "/_//src/Glutinum.Converter/Reader/Parameters.fs",
|
|
27
|
+
const item = Report_readerError_Z19516DCE("name", concat_1("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(nameNode_1.kind)), nameNode_1, "/_//src/Glutinum.Converter/Reader/Parameters.fs", 36);
|
|
27
28
|
const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
28
29
|
void (objectArg.push(item));
|
|
29
30
|
name = (`arg${index}`);
|