@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,803 @@
|
|
|
1
|
+
|
|
2
|
+
import { typeLiteralId, readTypeArguments, entityNameText, getFullNameOrEmpty, defaultTypeArguments, identifierText, resolveAlias, symbolAtLocation, isTupleType, withInProgress, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
|
|
3
|
+
import { Report_readerError_Z19516DCE } from "./Report.js";
|
|
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.17.2/List.js";
|
|
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.17.2/Seq.js";
|
|
7
|
+
import { toArray, defaultArg, value as value_6 } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
8
|
+
import { readInstantiatedMember, readPropertyWithoutDeclaration } from "./MemberTypes.js";
|
|
9
|
+
import { List_distinct } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
10
|
+
import { comparePrimitives, stringHash, safeHash, equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
11
|
+
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
|
|
12
|
+
import { readTypeUsingFlags } from "./Deferred.js";
|
|
13
|
+
import { FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, ofList } from "../../fable_modules/fable-library-js.5.17.2/Map.js";
|
|
14
|
+
import { item as item_5 } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
15
|
+
|
|
16
|
+
export function readExclude(reader, typeReferenceNode) {
|
|
17
|
+
let matchValue_1, activePatternResult_4, item, objectArg, activePatternResult_6, item_1, objectArg_1, matchValue_3, typeArguments, typeArguments_1, excluded, isNullish, matchValue_5, symbol, matchValue_6, matchValue_7, typeArguments_2, typeArguments_3, excluded_1, isNullish_1, matchValue_9, symbol_1, matchValue_10, matchValue_11, typeArguments_4, typeArguments_5, excluded_2, isNullish_2, matchValue_13, symbol_2, matchValue_14;
|
|
18
|
+
const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
|
|
19
|
+
const matchValue = typ.flags;
|
|
20
|
+
let matchResult;
|
|
21
|
+
if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
|
|
22
|
+
matchResult = 0;
|
|
23
|
+
}
|
|
24
|
+
else if ($007CHasTypeFlags$007C_$007C(2048, matchValue) != null) {
|
|
25
|
+
matchResult = 0;
|
|
26
|
+
}
|
|
27
|
+
else if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
|
|
28
|
+
matchResult = 0;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
matchResult = 1;
|
|
32
|
+
}
|
|
33
|
+
switch (matchResult) {
|
|
34
|
+
case 0:
|
|
35
|
+
return new GlueType(/* Union */ 7, [new GlueTypeUnion((matchValue_1 = typ.flags, ($007CHasTypeFlags$007C_$007C(1024, matchValue_1) != null) ? ((activePatternResult_4 = Type_StringLiteral_$007CString$007COther$007C(typ), (activePatternResult_4.tag === 1) ? (((item = Report_readerError_Z19516DCE("Exclude", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 26), (objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg.push(item)))), empty())) : singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_4.fields[0]])])))) : (($007CHasTypeFlags$007C_$007C(2048, matchValue_1) != null) ? ((activePatternResult_6 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ), (activePatternResult_6.tag === 1) ? singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_6.fields[0]])])) : ((activePatternResult_6.tag === 2) ? (((item_1 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 36), (objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_1.push(item_1)))), empty())) : singleton(new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_6.fields[0]])]))))) : choose((typ_1) => {
|
|
36
|
+
const matchValue_2 = typ_1.flags;
|
|
37
|
+
if ($007CHasTypeFlags$007C_$007C(1024, matchValue_2) != null) {
|
|
38
|
+
const literalType = typ_1;
|
|
39
|
+
return new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [literalType.value])]);
|
|
40
|
+
}
|
|
41
|
+
else if ($007CHasTypeFlags$007C_$007C(2048, matchValue_2) != null) {
|
|
42
|
+
const activePatternResult_9 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ_1);
|
|
43
|
+
switch (activePatternResult_9.tag) {
|
|
44
|
+
case 1:
|
|
45
|
+
return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_9.fields[0]])]);
|
|
46
|
+
case 2: {
|
|
47
|
+
const item_2 = Report_readerError_Z19516DCE("Exclude", "Expected a number literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 59);
|
|
48
|
+
const objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
49
|
+
void (objectArg_2.push(item_2));
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
default:
|
|
53
|
+
return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_9.fields[0]])]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
}, toList(typ.types)))))]);
|
|
60
|
+
default: {
|
|
61
|
+
let matchResult_1;
|
|
62
|
+
if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
|
|
63
|
+
if ((matchValue_3 = typeReferenceNode.typeArguments, (matchValue_3 != null) && (((typeArguments = matchValue_3, ~~typeArguments.length > 1)) && ((typeArguments_1 = matchValue_3, (excluded = (typeArguments_1[0]), (isNullish = ((typeNode) => {
|
|
64
|
+
const matchValue_4 = typeNode.kind;
|
|
65
|
+
switch (matchValue_4) {
|
|
66
|
+
case 157:
|
|
67
|
+
return true;
|
|
68
|
+
case 193:
|
|
69
|
+
return forAll(isNullish, typeNode.types);
|
|
70
|
+
case 202:
|
|
71
|
+
return typeNode.literal.kind === 106;
|
|
72
|
+
default:
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}), (isNullish(typeArguments_1[1]) ? true : (excluded.kind === 200)) ? true : ((excluded.kind === 184) && ((matchValue_5 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(excluded.typeName), (matchValue_5 == null) ? false : ((symbol = matchValue_5, (matchValue_6 = symbol.flags, $007CHasSymbolFlags$007C_$007C(262144, matchValue_6) != null))))))))))))) {
|
|
76
|
+
matchResult_1 = 0;
|
|
77
|
+
}
|
|
78
|
+
else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
|
|
79
|
+
if ((matchValue_7 = typeReferenceNode.typeArguments, (matchValue_7 != null) && (((typeArguments_2 = matchValue_7, ~~typeArguments_2.length > 1)) && ((typeArguments_3 = matchValue_7, (excluded_1 = (typeArguments_3[0]), (isNullish_1 = ((typeNode_1) => {
|
|
80
|
+
const matchValue_8 = typeNode_1.kind;
|
|
81
|
+
switch (matchValue_8) {
|
|
82
|
+
case 157:
|
|
83
|
+
return true;
|
|
84
|
+
case 193:
|
|
85
|
+
return forAll(isNullish_1, typeNode_1.types);
|
|
86
|
+
case 202:
|
|
87
|
+
return typeNode_1.literal.kind === 106;
|
|
88
|
+
default:
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}), (isNullish_1(typeArguments_3[1]) ? true : (excluded_1.kind === 200)) ? true : ((excluded_1.kind === 184) && ((matchValue_9 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(excluded_1.typeName), (matchValue_9 == null) ? false : ((symbol_1 = matchValue_9, (matchValue_10 = symbol_1.flags, $007CHasSymbolFlags$007C_$007C(262144, matchValue_10) != null))))))))))))) {
|
|
92
|
+
matchResult_1 = 0;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
matchResult_1 = 1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
matchResult_1 = 1;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
|
|
103
|
+
if ((matchValue_11 = typeReferenceNode.typeArguments, (matchValue_11 != null) && (((typeArguments_4 = matchValue_11, ~~typeArguments_4.length > 1)) && ((typeArguments_5 = matchValue_11, (excluded_2 = (typeArguments_5[0]), (isNullish_2 = ((typeNode_2) => {
|
|
104
|
+
const matchValue_12 = typeNode_2.kind;
|
|
105
|
+
switch (matchValue_12) {
|
|
106
|
+
case 157:
|
|
107
|
+
return true;
|
|
108
|
+
case 193:
|
|
109
|
+
return forAll(isNullish_2, typeNode_2.types);
|
|
110
|
+
case 202:
|
|
111
|
+
return typeNode_2.literal.kind === 106;
|
|
112
|
+
default:
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}), (isNullish_2(typeArguments_5[1]) ? true : (excluded_2.kind === 200)) ? true : ((excluded_2.kind === 184) && ((matchValue_13 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(excluded_2.typeName), (matchValue_13 == null) ? false : ((symbol_2 = matchValue_13, (matchValue_14 = symbol_2.flags, $007CHasSymbolFlags$007C_$007C(262144, matchValue_14) != null))))))))))))) {
|
|
116
|
+
matchResult_1 = 0;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
matchResult_1 = 1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
matchResult_1 = 1;
|
|
124
|
+
}
|
|
125
|
+
switch (matchResult_1) {
|
|
126
|
+
case 0:
|
|
127
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_6(typeReferenceNode.typeArguments)[0]);
|
|
128
|
+
default:
|
|
129
|
+
if ($007CHasTypeFlags$007C_$007C(32, matchValue) != null) {
|
|
130
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
|
|
131
|
+
}
|
|
132
|
+
else if ($007CHasTypeFlags$007C_$007C(64, matchValue) != null) {
|
|
133
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]);
|
|
134
|
+
}
|
|
135
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue) != null) {
|
|
136
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Bool]);
|
|
137
|
+
}
|
|
138
|
+
else if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
|
|
139
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
140
|
+
}
|
|
141
|
+
else if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
|
|
142
|
+
const matchValue_15 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
|
|
143
|
+
if (matchValue_15 == null) {
|
|
144
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const typeNode_3 = matchValue_15;
|
|
148
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode_3);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const item_3 = Report_readerError_Z19516DCE("Exclude", "Was expecting the resolved type to be a literal or a union", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 120);
|
|
153
|
+
const objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
154
|
+
void (objectArg_3.push(item_3));
|
|
155
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function isMemberDeclaration(declaration) {
|
|
163
|
+
const matchValue = declaration.kind;
|
|
164
|
+
switch (matchValue) {
|
|
165
|
+
case 264:
|
|
166
|
+
case 265:
|
|
167
|
+
case 266:
|
|
168
|
+
case 267:
|
|
169
|
+
case 268:
|
|
170
|
+
return false;
|
|
171
|
+
default:
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function readPropertyMembers(reader, contextNode, property) {
|
|
177
|
+
let option_1;
|
|
178
|
+
const declarations = defaultArg((option_1 = property.declarations, (option_1 != null) ? toList(filter(isMemberDeclaration, option_1)) : undefined), empty());
|
|
179
|
+
return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing, contextNode, () => (isEmpty(declarations) ? ofArray(toArray(readPropertyWithoutDeclaration(reader, contextNode, property))) : map((declaration_1) => readInstantiatedMember(reader, contextNode, property, declaration_1), declarations)));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function readMembers(reader, contextNode, typ) {
|
|
183
|
+
let objectArg;
|
|
184
|
+
return List_distinct(collect((property) => readPropertyMembers(reader, contextNode, property), toList((objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg.getPropertiesOfType(typ)))), {
|
|
185
|
+
Equals: equals,
|
|
186
|
+
GetHashCode: (x) => (safeHash(x) | 0),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* When a generic type reference is applied with concrete type arguments
|
|
192
|
+
* (e.g. a custom utility type like <c>Picked<User, "id"></c>), the
|
|
193
|
+
* TypeChecker resolves it to an anonymous object type. We read its resolved
|
|
194
|
+
* members (via <see cref="readMembers"/>) and expand it into a TypeLiteral
|
|
195
|
+
* so it is generated as a concrete interface instead of an unusable
|
|
196
|
+
* reference to the (generic) utility.
|
|
197
|
+
*/
|
|
198
|
+
export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
199
|
+
let matchValue, typeArguments, typNode;
|
|
200
|
+
if (!((matchValue = typeReferenceNode.typeArguments, (matchValue == null) ? false : ((typeArguments = matchValue, ~~typeArguments.length > 0))))) {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
|
|
205
|
+
let isNamedDeclaration;
|
|
206
|
+
if (Operators_IsNull(typ.symbol)) {
|
|
207
|
+
isNamedDeclaration = false;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const matchValue_1 = typ.symbol.declarations;
|
|
211
|
+
isNamedDeclaration = ((matchValue_1 == null) ? false : exists((declaration) => {
|
|
212
|
+
const matchValue_2 = declaration.kind;
|
|
213
|
+
switch (matchValue_2) {
|
|
214
|
+
case 264:
|
|
215
|
+
case 265:
|
|
216
|
+
return true;
|
|
217
|
+
default:
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}, matchValue_1));
|
|
221
|
+
}
|
|
222
|
+
let isTypeAliasApplication;
|
|
223
|
+
const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(typeReferenceNode.typeName);
|
|
224
|
+
if (matchValue_3 == null) {
|
|
225
|
+
isTypeAliasApplication = false;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
const symbol = matchValue_3;
|
|
229
|
+
const matchValue_4 = symbol.flags;
|
|
230
|
+
isTypeAliasApplication = ($007CHasSymbolFlags$007C_$007C(524288, matchValue_4) != null);
|
|
231
|
+
}
|
|
232
|
+
const isInProgress = exists((inProgress) => (inProgress === typ), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
|
|
233
|
+
let isGenericMapped;
|
|
234
|
+
const matchValue_5 = typ.flags;
|
|
235
|
+
isGenericMapped = (($007CHasTypeFlags$007C_$007C(1048576, matchValue_5) != null) && (((typ.objectFlags & 32) !== 0) && exists((argument) => {
|
|
236
|
+
const matchValue_6 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(argument).flags;
|
|
237
|
+
if ($007CHasTypeFlags$007C_$007C(524288, matchValue_6) != null) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}, value_6(typeReferenceNode.typeArguments))));
|
|
244
|
+
const isArrayLike = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().isArrayLikeType(typ);
|
|
245
|
+
const matchValue_7 = typ.flags;
|
|
246
|
+
let matchResult;
|
|
247
|
+
if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
|
|
248
|
+
if ((isTupleType(typ) ? true : (isArrayLike && !isNamedDeclaration)) && !isInProgress) {
|
|
249
|
+
matchResult = 0;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
matchResult = 1;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
matchResult = 1;
|
|
257
|
+
}
|
|
258
|
+
switch (matchResult) {
|
|
259
|
+
case 0: {
|
|
260
|
+
const option_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
|
|
261
|
+
if (option_1 != null) {
|
|
262
|
+
return (typNode = option_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
default: {
|
|
269
|
+
let matchResult_1;
|
|
270
|
+
if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_7) != null) {
|
|
271
|
+
if ((!isNamedDeclaration && !isInProgress) && !isGenericMapped) {
|
|
272
|
+
matchResult_1 = 0;
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
matchResult_1 = 1;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
matchResult_1 = 1;
|
|
280
|
+
}
|
|
281
|
+
switch (matchResult_1) {
|
|
282
|
+
case 0: {
|
|
283
|
+
const members = withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions, typ, () => readMembers(reader, typeReferenceNode, typ));
|
|
284
|
+
if (isEmpty(members)) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(members, undefined)]);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
default: {
|
|
292
|
+
let matchResult_2;
|
|
293
|
+
if ($007CHasTypeFlags$007C_$007C(32, matchValue_7) != null) {
|
|
294
|
+
if (isTypeAliasApplication) {
|
|
295
|
+
matchResult_2 = 0;
|
|
296
|
+
}
|
|
297
|
+
else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
|
|
298
|
+
if (isTypeAliasApplication) {
|
|
299
|
+
matchResult_2 = 0;
|
|
300
|
+
}
|
|
301
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
|
|
302
|
+
if (isTypeAliasApplication) {
|
|
303
|
+
matchResult_2 = 0;
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
matchResult_2 = 1;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
matchResult_2 = 1;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
|
|
314
|
+
if (isTypeAliasApplication) {
|
|
315
|
+
matchResult_2 = 0;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
matchResult_2 = 1;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
matchResult_2 = 1;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else if ($007CHasTypeFlags$007C_$007C(64, matchValue_7) != null) {
|
|
326
|
+
if (isTypeAliasApplication) {
|
|
327
|
+
matchResult_2 = 0;
|
|
328
|
+
}
|
|
329
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
|
|
330
|
+
if (isTypeAliasApplication) {
|
|
331
|
+
matchResult_2 = 0;
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
matchResult_2 = 1;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
matchResult_2 = 1;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue_7) != null) {
|
|
342
|
+
if (isTypeAliasApplication) {
|
|
343
|
+
matchResult_2 = 0;
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
matchResult_2 = 1;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
matchResult_2 = 1;
|
|
351
|
+
}
|
|
352
|
+
switch (matchResult_2) {
|
|
353
|
+
case 0:
|
|
354
|
+
return readTypeUsingFlags(reader, typ);
|
|
355
|
+
default:
|
|
356
|
+
return undefined;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function baseTypeOf(reader, typeNode) {
|
|
366
|
+
let option_2, option, binder, checker, option_1, mapping, objectArg, option_3;
|
|
367
|
+
const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeNode);
|
|
368
|
+
const matchValue = typ.flags;
|
|
369
|
+
let matchResult;
|
|
370
|
+
if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
|
|
371
|
+
if ((typeNode.pos < 0) && (typeNode.kind === 184)) {
|
|
372
|
+
matchResult = 0;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
matchResult = 1;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
matchResult = 1;
|
|
380
|
+
}
|
|
381
|
+
switch (matchResult) {
|
|
382
|
+
case 0:
|
|
383
|
+
return defaultArg((option_2 = ((option = symbolAtLocation(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeNode.typeName), (binder = ((checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol) => resolveAlias(checker, symbol))), (option_1 = option, (option_1 != null) ? binder(option_1) : undefined)))), (mapping = ((objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol_1) => objectArg.getDeclaredTypeOfSymbol(symbol_1))), (option_3 = option_2, (option_3 != null) ? mapping(option_3) : undefined))), typ);
|
|
384
|
+
default:
|
|
385
|
+
return typ;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function literalKeysOf(typeNode_mut) {
|
|
390
|
+
literalKeysOf:
|
|
391
|
+
while (true) {
|
|
392
|
+
const typeNode = typeNode_mut;
|
|
393
|
+
const matchValue = typeNode.kind;
|
|
394
|
+
switch (matchValue) {
|
|
395
|
+
case 193:
|
|
396
|
+
return collect(literalKeysOf, toList(typeNode.types));
|
|
397
|
+
case 197: {
|
|
398
|
+
typeNode_mut = typeNode.type;
|
|
399
|
+
continue literalKeysOf;
|
|
400
|
+
}
|
|
401
|
+
case 202: {
|
|
402
|
+
const literal = typeNode.literal;
|
|
403
|
+
if (literal.kind === 11) {
|
|
404
|
+
return singleton(literal.text);
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
return empty();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
default:
|
|
411
|
+
return empty();
|
|
412
|
+
}
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function withoutForeignTypeParameters(reader, bound, members) {
|
|
418
|
+
const declaredAbove = (node) => {
|
|
419
|
+
if (Operators_IsNull(node)) {
|
|
420
|
+
return empty();
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
const typeParameters = node.typeParameters;
|
|
424
|
+
return append((typeParameters == null) ? empty() : map((p) => identifierText(p.name), toList(typeParameters)), declaredAbove(node.parent));
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
let inScope;
|
|
428
|
+
const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_SyntheticContext"]();
|
|
429
|
+
inScope = ((matchValue == null) ? empty() : declaredAbove(matchValue));
|
|
430
|
+
const signatureMentions = (returnType, parameters) => append(GlueSubstitution_mentionedTypeParameters(returnType), collect((parameter) => GlueSubstitution_mentionedTypeParameters(parameter.Type), parameters));
|
|
431
|
+
const foreign = ofList(map((name_1) => [name_1, new GlueType(/* Primitive */ 3, [GluePrimitive.Any])], filter_1((name) => {
|
|
432
|
+
if (!contains(name, inScope, {
|
|
433
|
+
Equals: (x_1, y_1) => (x_1 === y_1),
|
|
434
|
+
GetHashCode: (x_1) => (stringHash(x_1) | 0),
|
|
435
|
+
})) {
|
|
436
|
+
return !FSharpMap__ContainsKey(bound, name);
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
}, List_distinct(collect((glueMember) => {
|
|
442
|
+
switch (glueMember.tag) {
|
|
443
|
+
case 1:
|
|
444
|
+
return GlueSubstitution_mentionedTypeParameters(glueMember.fields[0].Type);
|
|
445
|
+
case 0: {
|
|
446
|
+
const method = glueMember.fields[0];
|
|
447
|
+
return signatureMentions(method.Type, method.Parameters);
|
|
448
|
+
}
|
|
449
|
+
case 6: {
|
|
450
|
+
const method_1 = glueMember.fields[0];
|
|
451
|
+
return signatureMentions(method_1.Type, method_1.Parameters);
|
|
452
|
+
}
|
|
453
|
+
default:
|
|
454
|
+
return empty();
|
|
455
|
+
}
|
|
456
|
+
}, members), {
|
|
457
|
+
Equals: (x, y) => (x === y),
|
|
458
|
+
GetHashCode: (x) => (stringHash(x) | 0),
|
|
459
|
+
}))), {
|
|
460
|
+
Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
|
|
461
|
+
});
|
|
462
|
+
if (FSharpMap__get_IsEmpty(foreign)) {
|
|
463
|
+
return members;
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
return map((glueMember_1) => GlueSubstitution_substituteMember(foreign, glueMember_1), members);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export function readPartial(reader, typeReferenceNode) {
|
|
471
|
+
const baseType = baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
|
|
472
|
+
if (exists((typ) => (typ === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials)) {
|
|
473
|
+
const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 366);
|
|
474
|
+
const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
475
|
+
void (objectArg.push(item));
|
|
476
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials, baseType, () => {
|
|
480
|
+
if (isTupleType(baseType)) {
|
|
481
|
+
const typNode = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode), undefined, typeNodeBuilderFlags);
|
|
482
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
const baseNode = value_6(typeReferenceNode.typeArguments)[0];
|
|
486
|
+
let members;
|
|
487
|
+
const matchValue = baseType.flags;
|
|
488
|
+
let matchResult;
|
|
489
|
+
if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
|
|
490
|
+
if (baseNode.kind === 133) {
|
|
491
|
+
matchResult = 0;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
matchResult = 1;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
matchResult = 1;
|
|
499
|
+
}
|
|
500
|
+
switch (matchResult) {
|
|
501
|
+
case 0: {
|
|
502
|
+
members = empty();
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
default: {
|
|
506
|
+
let matchResult_1;
|
|
507
|
+
if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
|
|
508
|
+
if ((baseNode.pos < 0) && (baseNode.kind === 188)) {
|
|
509
|
+
matchResult_1 = 0;
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
matchResult_1 = 1;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
matchResult_1 = 1;
|
|
517
|
+
}
|
|
518
|
+
switch (matchResult_1) {
|
|
519
|
+
case 0: {
|
|
520
|
+
const matchValue_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](baseNode);
|
|
521
|
+
members = ((matchValue_1.tag === 22) ? matchValue_1.fields[0].Members : empty());
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
default:
|
|
525
|
+
if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
|
|
526
|
+
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", 408);
|
|
527
|
+
const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
528
|
+
void (objectArg_1.push(item_1));
|
|
529
|
+
members = empty();
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
members = readMembers(reader, typeReferenceNode, baseType);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
|
|
538
|
+
let members_2;
|
|
539
|
+
const members_1 = map((glueMember) => GlueSubstitution_substituteMember(defaults, glueMember), members);
|
|
540
|
+
members_2 = ((typeReferenceNode.pos < 0) ? withoutForeignTypeParameters(reader, defaults, members_1) : members_1);
|
|
541
|
+
return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Partial */ 0, [new GlueInterface(empty(), getFullNameOrEmpty(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeReferenceNode), entityNameText(typeReferenceNode.typeName), members_2, empty(), empty())])]);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export function readRecord(reader, typeReferenceNode) {
|
|
548
|
+
const typeArguments = readTypeArguments(reader, typeReferenceNode);
|
|
549
|
+
return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Record */ 1, [new GlueRecord(item_4(0, typeArguments), item_4(1, typeArguments))])]);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export function readReturnType(reader, typeReferenceNode) {
|
|
553
|
+
let matchValue_4, matchValue_1, symbol, matchValue_2, declarations, declarations_1;
|
|
554
|
+
const rawTyp = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
|
|
555
|
+
let typ;
|
|
556
|
+
const matchValue = rawTyp.flags;
|
|
557
|
+
let matchResult;
|
|
558
|
+
if ($007CHasTypeFlags$007C_$007C(67108864, matchValue) != null) {
|
|
559
|
+
matchResult = 0;
|
|
560
|
+
}
|
|
561
|
+
else if ($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) {
|
|
562
|
+
matchResult = 0;
|
|
563
|
+
}
|
|
564
|
+
else if ($007CHasTypeFlags$007C_$007C(16777216, matchValue) != null) {
|
|
565
|
+
matchResult = 0;
|
|
566
|
+
}
|
|
567
|
+
else if ($007CHasTypeFlags$007C_$007C(2097152, matchValue) != null) {
|
|
568
|
+
matchResult = 0;
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
matchResult = 1;
|
|
572
|
+
}
|
|
573
|
+
switch (matchResult) {
|
|
574
|
+
case 0: {
|
|
575
|
+
typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getApparentType(rawTyp);
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
default:
|
|
579
|
+
typ = rawTyp;
|
|
580
|
+
}
|
|
581
|
+
const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
|
|
582
|
+
if (matchValue_3 == null) {
|
|
583
|
+
return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ReturnType */ 2, [readTypeUsingFlags(reader, typ)])]);
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
const typeNode = matchValue_3;
|
|
587
|
+
return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ReturnType */ 2, [(matchValue_4 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode), (matchValue_4.tag === 22) ? ((matchValue_4.fields[0].Id == null) ? (new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(matchValue_4.fields[0].Members, (matchValue_1 = typ.getSymbol(), (matchValue_1 == null) ? undefined : ((symbol = matchValue_1, (matchValue_2 = symbol.declarations, (matchValue_2 != null) ? (((declarations = matchValue_2, declarations.length > 0)) ? ((declarations_1 = matchValue_2, typeLiteralId(item_5(0, declarations_1)))) : undefined) : undefined)))))])) : matchValue_4) : matchValue_4)])]);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
export function readThisParameterType(reader, typeReferenceNode) {
|
|
592
|
+
const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
|
|
593
|
+
const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
|
|
594
|
+
if (matchValue == null) {
|
|
595
|
+
return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ThisParameterType */ 3, [readTypeUsingFlags(reader, typ)])]);
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
const typeNode = matchValue;
|
|
599
|
+
return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* ThisParameterType */ 3, [reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode)])]);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export function readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
|
|
604
|
+
let option_1, matchValue_4, item_1, objectArg_2, objectArg_3;
|
|
605
|
+
let keysToOmitType;
|
|
606
|
+
const node = value_6(typeReferenceNode.typeArguments)[1];
|
|
607
|
+
const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
608
|
+
keysToOmitType = objectArg.getTypeFromTypeNode(node);
|
|
609
|
+
let hasUnboundKeys;
|
|
610
|
+
const matchValue = keysToOmitType.flags;
|
|
611
|
+
let matchResult;
|
|
612
|
+
if ($007CHasTypeFlags$007C_$007C(524288, matchValue) != null) {
|
|
613
|
+
matchResult = 0;
|
|
614
|
+
}
|
|
615
|
+
else if ($007CHasTypeFlags$007C_$007C(2097152, matchValue) != null) {
|
|
616
|
+
matchResult = 0;
|
|
617
|
+
}
|
|
618
|
+
else if ($007CHasTypeFlags$007C_$007C(33554432, matchValue) != null) {
|
|
619
|
+
matchResult = 0;
|
|
620
|
+
}
|
|
621
|
+
else {
|
|
622
|
+
matchResult = 1;
|
|
623
|
+
}
|
|
624
|
+
switch (matchResult) {
|
|
625
|
+
case 0: {
|
|
626
|
+
hasUnboundKeys = true;
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
default:
|
|
630
|
+
hasUnboundKeys = false;
|
|
631
|
+
}
|
|
632
|
+
const tryReadValueOfKeys = (typ) => {
|
|
633
|
+
const activePatternResult_3 = Type_StringLiteral_$007CString$007COther$007C(typ);
|
|
634
|
+
if (activePatternResult_3.tag === 1) {
|
|
635
|
+
const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 527);
|
|
636
|
+
const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
637
|
+
void (objectArg_1.push(item));
|
|
638
|
+
return undefined;
|
|
639
|
+
}
|
|
640
|
+
else {
|
|
641
|
+
return activePatternResult_3.fields[0];
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
let keysToOmit;
|
|
645
|
+
const matchValue_1 = keysToOmitType.flags;
|
|
646
|
+
let matchResult_1;
|
|
647
|
+
if (hasUnboundKeys) {
|
|
648
|
+
matchResult_1 = 0;
|
|
649
|
+
}
|
|
650
|
+
else if ($007CHasTypeFlags$007C_$007C(1, matchValue_1) != null) {
|
|
651
|
+
if (typeReferenceNode.pos < 0) {
|
|
652
|
+
matchResult_1 = 1;
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
matchResult_1 = 2;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
matchResult_1 = 2;
|
|
660
|
+
}
|
|
661
|
+
switch (matchResult_1) {
|
|
662
|
+
case 0: {
|
|
663
|
+
keysToOmit = empty_1();
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
case 1: {
|
|
667
|
+
keysToOmit = ofList_1(literalKeysOf(value_6(typeReferenceNode.typeArguments)[1]));
|
|
668
|
+
break;
|
|
669
|
+
}
|
|
670
|
+
default:
|
|
671
|
+
keysToOmit = (keysToOmitType.isUnion() ? choose_1(tryReadValueOfKeys, keysToOmitType.types) : defaultArg((option_1 = tryReadValueOfKeys(keysToOmitType), (option_1 != null) ? singleton_1(option_1) : undefined), []));
|
|
672
|
+
}
|
|
673
|
+
const baseType = baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
|
|
674
|
+
let literalMembers;
|
|
675
|
+
const matchValue_2 = baseType.flags;
|
|
676
|
+
let matchResult_2;
|
|
677
|
+
if ($007CHasTypeFlags$007C_$007C(1, matchValue_2) != null) {
|
|
678
|
+
if (typeReferenceNode.pos < 0) {
|
|
679
|
+
matchResult_2 = 0;
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
matchResult_2 = 1;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
else {
|
|
686
|
+
matchResult_2 = 1;
|
|
687
|
+
}
|
|
688
|
+
switch (matchResult_2) {
|
|
689
|
+
case 0: {
|
|
690
|
+
const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](value_6(typeReferenceNode.typeArguments)[0]);
|
|
691
|
+
literalMembers = ((matchValue_3.tag === 20) ? matchValue_3.fields[0] : ((matchValue_3.tag === 22) ? matchValue_3.fields[0].Members : undefined));
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
694
|
+
default:
|
|
695
|
+
literalMembers = undefined;
|
|
696
|
+
}
|
|
697
|
+
const filteredProperties = toList(filter((prop) => (keepListedKeys === contains_1(prop.name, keysToOmit, {
|
|
698
|
+
Equals: (x, y) => (x === y),
|
|
699
|
+
GetHashCode: (x) => (stringHash(x) | 0),
|
|
700
|
+
})), (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", 562), (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", 562), (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)))))));
|
|
701
|
+
const isInProgress = exists((inProgress) => (inProgress === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
|
|
702
|
+
const members_1 = isInProgress ? empty() : withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions, baseType, () => collect((property) => readPropertyMembers(reader, typeReferenceNode, property), filteredProperties));
|
|
703
|
+
const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
|
|
704
|
+
let members_4;
|
|
705
|
+
const members_3 = map((glueMember_2) => GlueSubstitution_substituteMember(defaults, glueMember_2), (literalMembers == null) ? members_1 : filter_1((glueMember_1) => {
|
|
706
|
+
let matchValue_5;
|
|
707
|
+
const glueMember = glueMember_1;
|
|
708
|
+
switch (glueMember.tag) {
|
|
709
|
+
case 0: {
|
|
710
|
+
matchValue_5 = glueMember.fields[0].Name;
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
case 6: {
|
|
714
|
+
matchValue_5 = glueMember.fields[0].Name;
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
case 2: {
|
|
718
|
+
matchValue_5 = glueMember.fields[0].Name;
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
case 3: {
|
|
722
|
+
matchValue_5 = glueMember.fields[0].Name;
|
|
723
|
+
break;
|
|
724
|
+
}
|
|
725
|
+
case 4:
|
|
726
|
+
case 5:
|
|
727
|
+
case 7: {
|
|
728
|
+
matchValue_5 = undefined;
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
default:
|
|
732
|
+
matchValue_5 = glueMember.fields[0].Name;
|
|
733
|
+
}
|
|
734
|
+
if (matchValue_5 == null) {
|
|
735
|
+
return !keepListedKeys;
|
|
736
|
+
}
|
|
737
|
+
else {
|
|
738
|
+
return keepListedKeys === contains_1(matchValue_5, keysToOmit, {
|
|
739
|
+
Equals: (x_1, y_2) => (x_1 === y_2),
|
|
740
|
+
GetHashCode: (x_1) => (stringHash(x_1) | 0),
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
}, literalMembers));
|
|
744
|
+
members_4 = ((typeReferenceNode.pos < 0) ? withoutForeignTypeParameters(reader, defaults, members_3) : members_3);
|
|
745
|
+
if (hasUnboundKeys ? true : isInProgress) {
|
|
746
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
return new GlueType(/* UtilityType */ 27, [(keepListedKeys ? ((Item) => (new GlueUtilityType(/* Pick */ 5, [Item]))) : ((Item_1) => (new GlueUtilityType(/* Omit */ 4, [Item_1]))))(members_4)]);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export function readOmit(reader, typeReferenceNode) {
|
|
754
|
+
return readOmitOrPick(reader, typeReferenceNode, false);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
export function readPick(reader, typeReferenceNode) {
|
|
758
|
+
return readOmitOrPick(reader, typeReferenceNode, true);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export function readReadonly(reader, typeReferenceNode) {
|
|
762
|
+
const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(typeReferenceNode);
|
|
763
|
+
const matchValue = typ.flags;
|
|
764
|
+
let matchResult;
|
|
765
|
+
if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
|
|
766
|
+
matchResult = 0;
|
|
767
|
+
}
|
|
768
|
+
else if ($007CHasTypeFlags$007C_$007C(268435456, matchValue) != null) {
|
|
769
|
+
matchResult = 0;
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
matchResult = 1;
|
|
773
|
+
}
|
|
774
|
+
switch (matchResult) {
|
|
775
|
+
case 0:
|
|
776
|
+
return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Readonly */ 6, [new GlueReadonly(/* Members */ 0, [readMembers(reader, typeReferenceNode, typ)])])]);
|
|
777
|
+
default:
|
|
778
|
+
if ($007CHasTypeFlags$007C_$007C(134217728, matchValue) != null) {
|
|
779
|
+
const unionType = typ;
|
|
780
|
+
try {
|
|
781
|
+
return new GlueType(/* UtilityType */ 27, [new GlueUtilityType(/* Readonly */ 6, [new GlueReadonly(/* Union */ 1, [toList(choose_1((innerType) => {
|
|
782
|
+
let copyOfStruct, Name;
|
|
783
|
+
if ((copyOfStruct = innerType.flags, (copyOfStruct & 1048576) !== 0)) {
|
|
784
|
+
return (Name = (value_6(innerType.aliasTypeArguments)[0]).symbol.name, new GlueInterface(empty(), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getFullyQualifiedName((value_6(innerType.aliasTypeArguments)[0]).symbol), Name, readMembers(reader, typeReferenceNode, innerType), empty(), empty()));
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
return undefined;
|
|
788
|
+
}
|
|
789
|
+
}, unionType.types))])])]);
|
|
790
|
+
}
|
|
791
|
+
catch (matchValue_1) {
|
|
792
|
+
const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 686);
|
|
793
|
+
const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
794
|
+
void (objectArg.push(item));
|
|
795
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|