@glutinum/cli 1.0.0-beta.14 → 1.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Glutinum.Converter/GlueAST.js +19 -14
- package/dist/Glutinum.Converter/Merge.js +480 -205
- package/dist/Glutinum.Converter/Packages.js +2 -2
- package/dist/Glutinum.Converter/Printer.js +26 -21
- package/dist/Glutinum.Converter/Read.js +377 -169
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +25 -8
- package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +2 -2
- package/dist/Glutinum.Converter/Reader/Declaration.js +15 -15
- package/dist/Glutinum.Converter/Reader/Deferred.js +114 -43
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +98 -44
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +2 -2
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +61 -46
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +4 -4
- package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +38 -25
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +6 -5
- package/dist/Glutinum.Converter/Reader/Node.js +1 -1
- package/dist/Glutinum.Converter/Reader/TypeNode.js +244 -29
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +1 -1
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +143 -35
- package/dist/Glutinum.Converter/Reader/UtilityType.js +114 -31
- package/dist/Glutinum.Converter/Reader/Utils.js +186 -17
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +46 -16
- package/dist/Glutinum.Converter/Transform.js +1062 -629
- package/dist/Glutinum.Converter/Transformer/CallableProperties.js +2 -2
- package/dist/Glutinum.Converter/Transformer/Conditionals.js +17 -16
- package/dist/Glutinum.Converter/Transformer/Context.js +12 -4
- package/dist/Glutinum.Converter/Transformer/Exports.js +242 -66
- package/dist/Glutinum.Converter/Transformer/Heritage.js +275 -17
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +4 -4
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +105 -19
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +2 -2
- package/dist/Glutinum.Converter/Transformer/Utils.js +3 -3
- package/dist/Glutinum.Converter/Utils/Naming.js +10 -3
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
import { primitiveOfFlags, isFromEsLib, isFromEs5Lib, withInProgress, identifierText, isTopLevelModuleDeclaration, modulePathForSymbol, declaredName, $007CHasSymbolFlags$007C_$007C, resolveAlias, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
|
|
2
|
+
import { primitiveOfFlags, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, isFromEsLib, isFromEs5Lib, withInProgress, identifierText, isTopLevelModuleDeclaration, isExternalToPackages, modulePathForSymbol, declaredName, $007CHasSymbolFlags$007C_$007C, resolveAlias, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
|
|
3
3
|
import { defaultArg } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
|
|
4
4
|
import { contains, item } from "../../fable_modules/fable-library-js.5.21.0/Array.js";
|
|
5
5
|
import { collect as collect_1, append as append_1, delay, toList, exists } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
|
|
6
6
|
import { filter, isEmpty, singleton, append, map, empty } from "../../fable_modules/fable-library-js.5.21.0/List.js";
|
|
7
|
-
import { GlueFunctionDeclaration, GlueSubstitution_substituteParameter, GlueSubstitution_substitute, GlueSubstitution_mentionedTypeParameters, GlueFunctionType,
|
|
7
|
+
import { GlueLiteral, GlueFunctionDeclaration, GlueSubstitution_substituteParameter, GlueSubstitution_substitute, GlueSubstitution_mentionedTypeParameters, GlueFunctionType, GluePrimitive, GlueType, GlueTypeReference } from "../GlueAST.js";
|
|
8
8
|
import { sanitizeTypeName, removeSurroundingQuotes } from "../Utils/Naming.js";
|
|
9
|
-
import { PackageContext__ModulePath_Z721C83C5 } from "./Types.js";
|
|
9
|
+
import { PackageContext__IsHoisted_32BC514A, PackageContext__TryFindPackage_Z721C83C5, PackageContext__IsImportable_Z384F8060, PackageContext__ModulePath_Z721C83C5 } from "./Types.js";
|
|
10
10
|
import { normalizePath } from "../Utils/String.js";
|
|
11
11
|
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.21.0/FSharp.Core.js";
|
|
12
12
|
import { FSharpSet__Contains, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
|
|
@@ -18,7 +18,7 @@ import { concat } from "../../fable_modules/fable-library-js.5.21.0/String.js";
|
|
|
18
18
|
import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
|
|
19
19
|
|
|
20
20
|
export function readTypeQueryNode(reader, typeQueryNode) {
|
|
21
|
-
let declarations_1;
|
|
21
|
+
let matchValue_10, packageContext, declarations_1;
|
|
22
22
|
const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
23
23
|
const typ = checker.getTypeAtLocation(typeQueryNode.exprName);
|
|
24
24
|
const matchValue = typ.flags;
|
|
@@ -66,7 +66,7 @@ export function readTypeQueryNode(reader, typeQueryNode) {
|
|
|
66
66
|
}
|
|
67
67
|
switch (matchResult_1) {
|
|
68
68
|
case 0:
|
|
69
|
-
return isOwnDeclaration(item(0, declarations_4));
|
|
69
|
+
return isOwnDeclaration(export$_1.name)(item(0, declarations_4));
|
|
70
70
|
default:
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
@@ -99,23 +99,83 @@ export function readTypeQueryNode(reader, typeQueryNode) {
|
|
|
99
99
|
matchResult_2 = 2;
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
case 185: {
|
|
103
|
+
if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
|
|
104
|
+
matchResult_2 = 5;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
matchResult_2 = 6;
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
case 186: {
|
|
103
112
|
if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
|
|
104
113
|
matchResult_2 = 5;
|
|
105
114
|
}
|
|
106
115
|
else {
|
|
107
116
|
matchResult_2 = 6;
|
|
108
117
|
}
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
case 188: {
|
|
121
|
+
if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
|
|
122
|
+
matchResult_2 = 5;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
matchResult_2 = 6;
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case 201: {
|
|
130
|
+
if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
|
|
131
|
+
matchResult_2 = 5;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
matchResult_2 = 6;
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
default:
|
|
139
|
+
if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
|
|
140
|
+
matchResult_2 = 5;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
matchResult_2 = 7;
|
|
144
|
+
}
|
|
109
145
|
}
|
|
110
146
|
switch (matchResult_2) {
|
|
111
147
|
case 0: {
|
|
112
|
-
|
|
113
|
-
const matchValue_9 =
|
|
114
|
-
|
|
115
|
-
|
|
148
|
+
const reference = new GlueTypeReference(defaultArg(declaredName(symbol_1), symbol_1.name), checker.getFullyQualifiedName(symbol_1), modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), false, symbol_1), empty(), false);
|
|
149
|
+
const matchValue_9 = typeQueryNode.parent.kind;
|
|
150
|
+
let matchResult_3;
|
|
151
|
+
if (isExternalToPackages(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbol_1)) {
|
|
152
|
+
matchResult_3 = 0;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
switch (matchValue_9) {
|
|
156
|
+
case 169:
|
|
157
|
+
case 184:
|
|
158
|
+
case 234: {
|
|
159
|
+
matchResult_3 = 1;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
default:
|
|
163
|
+
matchResult_3 = 2;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
switch (matchResult_3) {
|
|
167
|
+
case 0:
|
|
168
|
+
return new GlueType(/* TypeReference */ 13, [reference]);
|
|
169
|
+
case 1:
|
|
170
|
+
return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(reference.Name, reference.FullName, reference.ModulePath, (matchValue_10 = declaration_1.typeParameters, (matchValue_10 == null) ? empty() : map((_arg_6) => (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])), toList(matchValue_10))), reference.IsStandardLibrary)]);
|
|
171
|
+
default: {
|
|
172
|
+
void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_TypeMemory"]().push(new GlueType(/* ClassConstructor */ 30, [reference])));
|
|
173
|
+
return new GlueType(/* ClassConstructor */ 30, [reference]);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
116
176
|
}
|
|
117
177
|
case 1:
|
|
118
|
-
if (!hasValueExport((_arg_7) => true)) {
|
|
178
|
+
if (!hasValueExport((_arg_7) => ((_arg_8) => true))) {
|
|
119
179
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
120
180
|
}
|
|
121
181
|
else {
|
|
@@ -126,39 +186,47 @@ export function readTypeQueryNode(reader, typeQueryNode) {
|
|
|
126
186
|
}
|
|
127
187
|
case 2: {
|
|
128
188
|
const sourceFile = declaration_1;
|
|
129
|
-
const
|
|
130
|
-
let
|
|
131
|
-
if (
|
|
132
|
-
if (hasValueExport((
|
|
133
|
-
|
|
134
|
-
|
|
189
|
+
const matchValue_12 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
|
|
190
|
+
let matchResult_4, packageContext_2;
|
|
191
|
+
if (matchValue_12 != null) {
|
|
192
|
+
if (hasValueExport((packageContext = matchValue_12, (name) => ((declaration_3) => {
|
|
193
|
+
if ((normalizePath(declaration_3.getSourceFile().fileName) === normalizePath(sourceFile.fileName)) && PackageContext__IsImportable_Z384F8060(packageContext, sourceFile.fileName, name)) {
|
|
194
|
+
const matchValue_11 = PackageContext__TryFindPackage_Z721C83C5(packageContext, sourceFile.fileName);
|
|
195
|
+
return (matchValue_11 == null) ? true : !PackageContext__IsHoisted_32BC514A(packageContext, matchValue_11, sourceFile.fileName, name);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
})))) {
|
|
201
|
+
matchResult_4 = 0;
|
|
202
|
+
packageContext_2 = matchValue_12;
|
|
135
203
|
}
|
|
136
204
|
else {
|
|
137
|
-
|
|
205
|
+
matchResult_4 = 1;
|
|
138
206
|
}
|
|
139
207
|
}
|
|
140
208
|
else {
|
|
141
|
-
|
|
209
|
+
matchResult_4 = 1;
|
|
142
210
|
}
|
|
143
|
-
switch (
|
|
211
|
+
switch (matchResult_4) {
|
|
144
212
|
case 0:
|
|
145
|
-
return new GlueType(/* TypeReference */ 13, [new GlueTypeReference("Exports", checker.getFullyQualifiedName(symbol_1), PackageContext__ModulePath_Z721C83C5(
|
|
213
|
+
return new GlueType(/* TypeReference */ 13, [new GlueTypeReference("Exports", checker.getFullyQualifiedName(symbol_1), PackageContext__ModulePath_Z721C83C5(packageContext_2, sourceFile.fileName), empty(), false)]);
|
|
146
214
|
default:
|
|
147
215
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
148
216
|
}
|
|
149
217
|
}
|
|
150
218
|
case 3: {
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
153
|
-
if (!isEmpty(
|
|
219
|
+
const matchValue_13 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1);
|
|
220
|
+
if (matchValue_13.tag === 6) {
|
|
221
|
+
if (!isEmpty(matchValue_13.fields[0].TypeParameters)) {
|
|
154
222
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
155
223
|
}
|
|
156
224
|
else {
|
|
157
|
-
return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(
|
|
225
|
+
return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(matchValue_13.fields[0].Documentation, matchValue_13.fields[0].Type, matchValue_13.fields[0].TypeParameters, empty(), matchValue_13.fields[0].Parameters)]);
|
|
158
226
|
}
|
|
159
227
|
}
|
|
160
228
|
else {
|
|
161
|
-
return
|
|
229
|
+
return matchValue_13;
|
|
162
230
|
}
|
|
163
231
|
}
|
|
164
232
|
case 4: {
|
|
@@ -183,20 +251,20 @@ export function readTypeQueryNode(reader, typeQueryNode) {
|
|
|
183
251
|
inScope = ofSeq(collect(typeQueryNode, empty()), {
|
|
184
252
|
Compare: (x_8, y) => (comparePrimitives(x_8, y) | 0),
|
|
185
253
|
});
|
|
186
|
-
const toFunctionDeclaration = (
|
|
187
|
-
const free = ofList(map((
|
|
254
|
+
const toFunctionDeclaration = (name_1, documentation, parameters, returnType) => {
|
|
255
|
+
const free = ofList(map((name_3) => [name_3, new GlueType(/* Primitive */ 3, [GluePrimitive.Any])], filter((name_2) => !FSharpSet__Contains(inScope, name_2), toList(delay(() => append_1(GlueSubstitution_mentionedTypeParameters(returnType), delay(() => collect_1((parameter) => GlueSubstitution_mentionedTypeParameters(parameter.Type), parameters))))))), {
|
|
188
256
|
Compare: (x_9, y_1) => (comparePrimitives(x_9, y_1) | 0),
|
|
189
257
|
});
|
|
190
|
-
return new GlueType(/* FunctionDeclaration */ 6, [new GlueFunctionDeclaration(documentation, true,
|
|
258
|
+
return new GlueType(/* FunctionDeclaration */ 6, [new GlueFunctionDeclaration(documentation, true, name_1, GlueSubstitution_substitute(free, returnType), map((parameter_1) => GlueSubstitution_substituteParameter(free, parameter_1), parameters), empty())]);
|
|
191
259
|
};
|
|
192
|
-
const
|
|
193
|
-
switch (
|
|
260
|
+
const matchValue_14 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_1);
|
|
261
|
+
switch (matchValue_14.tag) {
|
|
194
262
|
case 0: {
|
|
195
|
-
const info_3 =
|
|
263
|
+
const info_3 = matchValue_14.fields[0];
|
|
196
264
|
return toFunctionDeclaration(info_3.Name, info_3.Documentation, info_3.Parameters, info_3.Type);
|
|
197
265
|
}
|
|
198
266
|
case 6: {
|
|
199
|
-
const info_4 =
|
|
267
|
+
const info_4 = matchValue_14.fields[0];
|
|
200
268
|
return toFunctionDeclaration(info_4.Name, info_4.Documentation, info_4.Parameters, info_4.Type);
|
|
201
269
|
}
|
|
202
270
|
default:
|
|
@@ -205,13 +273,23 @@ export function readTypeQueryNode(reader, typeQueryNode) {
|
|
|
205
273
|
}
|
|
206
274
|
case 5:
|
|
207
275
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
208
|
-
|
|
276
|
+
case 6:
|
|
209
277
|
if (contains(declaration_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, {
|
|
210
278
|
Equals: equals,
|
|
211
279
|
GetHashCode: (x_10) => (structuralHash(x_10) | 0),
|
|
212
280
|
})) {
|
|
213
281
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
214
282
|
}
|
|
283
|
+
else {
|
|
284
|
+
return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, declaration_1, () => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](declaration_1));
|
|
285
|
+
}
|
|
286
|
+
default:
|
|
287
|
+
if (contains(declaration_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, {
|
|
288
|
+
Equals: equals,
|
|
289
|
+
GetHashCode: (x_11) => (structuralHash(x_11) | 0),
|
|
290
|
+
})) {
|
|
291
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
292
|
+
}
|
|
215
293
|
else {
|
|
216
294
|
return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, declaration_1, () => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1));
|
|
217
295
|
}
|
|
@@ -300,7 +378,37 @@ export function readTypeQueryNode(reader, typeQueryNode) {
|
|
|
300
378
|
}
|
|
301
379
|
}
|
|
302
380
|
else {
|
|
303
|
-
|
|
381
|
+
let matchResult_5;
|
|
382
|
+
if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
|
|
383
|
+
matchResult_5 = 0;
|
|
384
|
+
}
|
|
385
|
+
else if ($007CHasTypeFlags$007C_$007C(2048, matchValue) != null) {
|
|
386
|
+
matchResult_5 = 0;
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
matchResult_5 = 1;
|
|
390
|
+
}
|
|
391
|
+
switch (matchResult_5) {
|
|
392
|
+
case 0: {
|
|
393
|
+
const activePatternResult_4 = Type_StringLiteral_$007CString$007COther$007C(typ);
|
|
394
|
+
if (activePatternResult_4.tag === 0) {
|
|
395
|
+
return new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_4.fields[0]])]);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
const activePatternResult_5 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ);
|
|
399
|
+
switch (activePatternResult_5.tag) {
|
|
400
|
+
case 0:
|
|
401
|
+
return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_5.fields[0]])]);
|
|
402
|
+
case 1:
|
|
403
|
+
return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_5.fields[0]])]);
|
|
404
|
+
default:
|
|
405
|
+
return primitiveOfFlags(typ);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
default:
|
|
410
|
+
return primitiveOfFlags(typ);
|
|
411
|
+
}
|
|
304
412
|
}
|
|
305
413
|
}
|
|
306
414
|
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
import { isFromEsLib, typeLiteralId, readTypeArguments,
|
|
2
|
+
import { isFromEsLib, typeLiteralId, readTypeArguments, getFullNameOrEmpty, defaultTypeArguments, isTupleType, resolveAlias, symbolAtLocation, entityNameText, identifierText, withInProgress, $007CHasSymbolFlags$007C_$007C, typeNodeBuilderFlags, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
|
|
3
3
|
import { Report_readerError_Z19516DCE } from "./Report.js";
|
|
4
4
|
import { item as item_4, contains, filter as filter_1, append, collect, map, ofArray, isEmpty, choose, singleton, empty } from "../../fable_modules/fable-library-js.5.21.0/List.js";
|
|
5
5
|
import { GlueReadonly, GlueRecord, GlueUtilityType, GlueInterface, GlueSubstitution_substituteMember, GlueSubstitution_mentionedTypeParameters, GlueTypeLiteral, GluePrimitive, GlueTypeUnion, GlueType, GlueLiteral } from "../GlueAST.js";
|
|
6
|
-
import { contains as contains_1, singleton as singleton_1, choose as choose_1, ofList as ofList_1, empty as empty_1, exists, filter, forAll, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
|
|
6
|
+
import { contains as contains_1, singleton as singleton_1, choose as choose_1, ofList as ofList_1, empty as empty_1, exists, map as map_1, filter, forAll, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
|
|
7
7
|
import { toArray, defaultArg, value as value_6 } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
|
|
8
8
|
import { readInstantiatedMember, readPropertyWithoutDeclaration } from "./MemberTypes.js";
|
|
9
9
|
import { List_distinct } from "../../fable_modules/fable-library-js.5.21.0/Seq2.js";
|
|
10
|
-
import {
|
|
10
|
+
import { stringHash, comparePrimitives, safeHash, equals } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
|
|
11
11
|
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.21.0/FSharp.Core.js";
|
|
12
|
+
import { FSharpSet__Contains, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
|
|
13
|
+
import { ts } from "@ts-morph/bootstrap";
|
|
12
14
|
import { readTypeUsingFlags } from "./Deferred.js";
|
|
13
15
|
import { FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, ofList } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
|
|
14
16
|
import { item as item_5 } from "../../fable_modules/fable-library-js.5.21.0/Array.js";
|
|
@@ -187,6 +189,68 @@ function readMembers(reader, contextNode, typ) {
|
|
|
187
189
|
});
|
|
188
190
|
}
|
|
189
191
|
|
|
192
|
+
export function tryParameterFreeMappedAlias(declaration) {
|
|
193
|
+
let typeParameters;
|
|
194
|
+
if (Operators_IsNull(declaration) ? true : (declaration.kind !== 266)) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
const alias = declaration;
|
|
199
|
+
const matchValue = alias.typeParameters;
|
|
200
|
+
let matchResult, typeParameters_1;
|
|
201
|
+
if (matchValue != null) {
|
|
202
|
+
if ((typeParameters = matchValue, (~~typeParameters.length > 0) && (alias.type.kind === 201))) {
|
|
203
|
+
matchResult = 0;
|
|
204
|
+
typeParameters_1 = matchValue;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
matchResult = 1;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
matchResult = 1;
|
|
212
|
+
}
|
|
213
|
+
switch (matchResult) {
|
|
214
|
+
case 0: {
|
|
215
|
+
const names = ofSeq(map_1((parameter) => identifierText(parameter.name), typeParameters_1), {
|
|
216
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
217
|
+
});
|
|
218
|
+
const usesParameter = (node) => {
|
|
219
|
+
if ((node.kind === 170) && (identifierText(node.name) === "this")) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
else if ((node.kind === 184) && FSharpSet__Contains(names, entityNameText(node.typeName))) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
return defaultArg(ts.forEachChild(node, ((child) => (usesParameter(child) ? true : undefined))), false);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
if (usesParameter(alias.type)) {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
return alias;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
default:
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function readParameterFreeMappedAlias(reader, alias) {
|
|
243
|
+
let members;
|
|
244
|
+
const typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(alias.type);
|
|
245
|
+
members = readMembers(reader, alias.type, typ);
|
|
246
|
+
if (isEmpty(members)) {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(members, undefined)]);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
190
254
|
/**
|
|
191
255
|
* When a generic type reference is applied with concrete type arguments
|
|
192
256
|
* (e.g. a custom utility type like <c>Picked<User, "id"></c>), the
|
|
@@ -196,7 +260,7 @@ function readMembers(reader, contextNode, typ) {
|
|
|
196
260
|
* reference to the (generic) utility.
|
|
197
261
|
*/
|
|
198
262
|
export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
199
|
-
let matchValue, typeArguments,
|
|
263
|
+
let matchValue, typeArguments, option_12, option_10, option_7, binder_4, checker_1, option_8, symbol_4, typNode;
|
|
200
264
|
if (!((matchValue = typeReferenceNode.typeArguments, (matchValue == null) ? false : ((typeArguments = matchValue, ~~typeArguments.length > 0))))) {
|
|
201
265
|
return undefined;
|
|
202
266
|
}
|
|
@@ -229,20 +293,39 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
|
229
293
|
const matchValue_4 = symbol.flags;
|
|
230
294
|
isTypeAliasApplication = ($007CHasSymbolFlags$007C_$007C(524288, matchValue_4) != null);
|
|
231
295
|
}
|
|
232
|
-
const isObjectLiteralAlias =
|
|
233
|
-
|
|
234
|
-
|
|
296
|
+
const isObjectLiteralAlias = (depth, typeName) => {
|
|
297
|
+
let option_5, option_3, option, binder, checker, option_1, symbol_2;
|
|
298
|
+
if (depth < 8) {
|
|
299
|
+
return defaultArg((option_5 = ((option_3 = ((option = symbolAtLocation(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeName), (binder = ((checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol_1) => resolveAlias(checker, symbol_1))), (option_1 = option, (option_1 != null) ? binder(option_1) : undefined)))), (option_3 != null) ? ((symbol_2 = option_3, symbol_2.declarations)) : undefined)), (option_5 != null) ? exists((declaration_1) => {
|
|
300
|
+
if (declaration_1.kind === 266) {
|
|
301
|
+
const body = declaration_1.type;
|
|
302
|
+
const matchValue_5 = body.kind;
|
|
303
|
+
switch (matchValue_5) {
|
|
304
|
+
case 184:
|
|
305
|
+
return isObjectLiteralAlias(depth + 1, body.typeName);
|
|
306
|
+
case 188:
|
|
307
|
+
return true;
|
|
308
|
+
default:
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}, option_5) : undefined), false);
|
|
235
316
|
}
|
|
236
317
|
else {
|
|
237
318
|
return false;
|
|
238
319
|
}
|
|
239
|
-
}
|
|
320
|
+
};
|
|
321
|
+
const isObjectLiteralAlias_1 = isObjectLiteralAlias(0, typeReferenceNode.typeName);
|
|
322
|
+
const isParameterFreeMappedAlias = defaultArg((option_12 = ((option_10 = ((option_7 = symbolAtLocation(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeReferenceNode.typeName), (binder_4 = ((checker_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), (symbol_3) => resolveAlias(checker_1, symbol_3))), (option_8 = option_7, (option_8 != null) ? binder_4(option_8) : undefined)))), (option_10 != null) ? ((symbol_4 = option_10, symbol_4.declarations)) : undefined)), (option_12 != null) ? exists((declaration_2) => (tryParameterFreeMappedAlias(declaration_2) != null), option_12) : undefined), false);
|
|
240
323
|
const isInProgress = exists((inProgress) => (inProgress === typ), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
|
|
241
324
|
let isGenericMapped;
|
|
242
|
-
const
|
|
243
|
-
isGenericMapped = (($007CHasTypeFlags$007C_$007C(1048576,
|
|
244
|
-
const
|
|
245
|
-
if ($007CHasTypeFlags$007C_$007C(524288,
|
|
325
|
+
const matchValue_6 = typ.flags;
|
|
326
|
+
isGenericMapped = (($007CHasTypeFlags$007C_$007C(1048576, matchValue_6) != null) && (((typ.objectFlags & 32) !== 0) && exists((argument) => {
|
|
327
|
+
const matchValue_7 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeFromTypeNode(argument).flags;
|
|
328
|
+
if ($007CHasTypeFlags$007C_$007C(524288, matchValue_7) != null) {
|
|
246
329
|
return true;
|
|
247
330
|
}
|
|
248
331
|
else {
|
|
@@ -250,9 +333,9 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
|
250
333
|
}
|
|
251
334
|
}, value_6(typeReferenceNode.typeArguments))));
|
|
252
335
|
const isArrayLike = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().isArrayLikeType(typ);
|
|
253
|
-
const
|
|
336
|
+
const matchValue_8 = typ.flags;
|
|
254
337
|
let matchResult;
|
|
255
|
-
if ($007CHasTypeFlags$007C_$007C(1048576,
|
|
338
|
+
if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_8) != null) {
|
|
256
339
|
if ((isTupleType(typ) ? true : (isArrayLike && !isNamedDeclaration)) && !isInProgress) {
|
|
257
340
|
matchResult = 0;
|
|
258
341
|
}
|
|
@@ -265,9 +348,9 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
|
265
348
|
}
|
|
266
349
|
switch (matchResult) {
|
|
267
350
|
case 0: {
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
return (typNode =
|
|
351
|
+
const option_15 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
|
|
352
|
+
if (option_15 != null) {
|
|
353
|
+
return (typNode = option_15, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode));
|
|
271
354
|
}
|
|
272
355
|
else {
|
|
273
356
|
return undefined;
|
|
@@ -275,8 +358,8 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
|
275
358
|
}
|
|
276
359
|
default: {
|
|
277
360
|
let matchResult_1;
|
|
278
|
-
if ($007CHasTypeFlags$007C_$007C(1048576,
|
|
279
|
-
if (((!isNamedDeclaration && !
|
|
361
|
+
if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_8) != null) {
|
|
362
|
+
if ((((!isNamedDeclaration && !isObjectLiteralAlias_1) && !isParameterFreeMappedAlias) && !isInProgress) && !isGenericMapped) {
|
|
280
363
|
matchResult_1 = 0;
|
|
281
364
|
}
|
|
282
365
|
else {
|
|
@@ -298,15 +381,15 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
|
298
381
|
}
|
|
299
382
|
default: {
|
|
300
383
|
let matchResult_2;
|
|
301
|
-
if ($007CHasTypeFlags$007C_$007C(32,
|
|
384
|
+
if ($007CHasTypeFlags$007C_$007C(32, matchValue_8) != null) {
|
|
302
385
|
if (isTypeAliasApplication) {
|
|
303
386
|
matchResult_2 = 0;
|
|
304
387
|
}
|
|
305
|
-
else if ($007CHasTypeFlags$007C_$007C(64,
|
|
388
|
+
else if ($007CHasTypeFlags$007C_$007C(64, matchValue_8) != null) {
|
|
306
389
|
if (isTypeAliasApplication) {
|
|
307
390
|
matchResult_2 = 0;
|
|
308
391
|
}
|
|
309
|
-
else if ($007CHasTypeFlags$007C_$007C(256,
|
|
392
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue_8) != null) {
|
|
310
393
|
if (isTypeAliasApplication) {
|
|
311
394
|
matchResult_2 = 0;
|
|
312
395
|
}
|
|
@@ -318,7 +401,7 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
|
318
401
|
matchResult_2 = 1;
|
|
319
402
|
}
|
|
320
403
|
}
|
|
321
|
-
else if ($007CHasTypeFlags$007C_$007C(256,
|
|
404
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue_8) != null) {
|
|
322
405
|
if (isTypeAliasApplication) {
|
|
323
406
|
matchResult_2 = 0;
|
|
324
407
|
}
|
|
@@ -330,11 +413,11 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
|
330
413
|
matchResult_2 = 1;
|
|
331
414
|
}
|
|
332
415
|
}
|
|
333
|
-
else if ($007CHasTypeFlags$007C_$007C(64,
|
|
416
|
+
else if ($007CHasTypeFlags$007C_$007C(64, matchValue_8) != null) {
|
|
334
417
|
if (isTypeAliasApplication) {
|
|
335
418
|
matchResult_2 = 0;
|
|
336
419
|
}
|
|
337
|
-
else if ($007CHasTypeFlags$007C_$007C(256,
|
|
420
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue_8) != null) {
|
|
338
421
|
if (isTypeAliasApplication) {
|
|
339
422
|
matchResult_2 = 0;
|
|
340
423
|
}
|
|
@@ -346,7 +429,7 @@ export function tryExpandAnonymousObjectApplication(reader, typeReferenceNode) {
|
|
|
346
429
|
matchResult_2 = 1;
|
|
347
430
|
}
|
|
348
431
|
}
|
|
349
|
-
else if ($007CHasTypeFlags$007C_$007C(256,
|
|
432
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue_8) != null) {
|
|
350
433
|
if (isTypeAliasApplication) {
|
|
351
434
|
matchResult_2 = 0;
|
|
352
435
|
}
|
|
@@ -478,7 +561,7 @@ function withoutForeignTypeParameters(reader, bound, members) {
|
|
|
478
561
|
export function readPartial(reader, typeReferenceNode) {
|
|
479
562
|
const baseType = baseTypeOf(reader, value_6(typeReferenceNode.typeArguments)[0]);
|
|
480
563
|
if (exists((typ) => (typ === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Partials)) {
|
|
481
|
-
const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs",
|
|
564
|
+
const item = Report_readerError_Z19516DCE("Partial", "Recursive Partial is not supported, defaulting to obj", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 460);
|
|
482
565
|
const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
483
566
|
void (objectArg.push(item));
|
|
484
567
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
@@ -531,7 +614,7 @@ export function readPartial(reader, typeReferenceNode) {
|
|
|
531
614
|
}
|
|
532
615
|
default:
|
|
533
616
|
if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
|
|
534
|
-
const item_1 = Report_readerError_Z19516DCE("partial inner type", "Was not able to resolve the inner type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs",
|
|
617
|
+
const item_1 = Report_readerError_Z19516DCE("partial inner type", "Was not able to resolve the inner type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 502);
|
|
535
618
|
const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
536
619
|
void (objectArg_1.push(item_1));
|
|
537
620
|
members = empty();
|
|
@@ -640,7 +723,7 @@ export function readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
|
|
|
640
723
|
const tryReadValueOfKeys = (typ) => {
|
|
641
724
|
const activePatternResult_3 = Type_StringLiteral_$007CString$007COther$007C(typ);
|
|
642
725
|
if (activePatternResult_3.tag === 1) {
|
|
643
|
-
const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs",
|
|
726
|
+
const item = Report_readerError_Z19516DCE("keysToOmit", "Expected a string literal", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 621);
|
|
644
727
|
const objectArg_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
645
728
|
void (objectArg_1.push(item));
|
|
646
729
|
return undefined;
|
|
@@ -705,7 +788,7 @@ export function readOmitOrPick(reader, typeReferenceNode, keepListedKeys) {
|
|
|
705
788
|
const filteredProperties = toList(filter((prop) => (keepListedKeys === contains_1(prop.name, keysToOmit, {
|
|
706
789
|
Equals: (x, y) => (x === y),
|
|
707
790
|
GetHashCode: (x) => (stringHash(x) | 0),
|
|
708
|
-
})), (matchValue_4 = baseType.flags, ($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? ((literalMembers != null) ? [] : (($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) ? (((item_1 = Report_readerError_Z19516DCE("omit base type", "Was not able to resolve the base type, and defaulting to any. If the base type is defined, in another file, please make sure to include it in the input files", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs",
|
|
791
|
+
})), (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", 656), (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", 656), (objectArg_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), void (objectArg_2.push(item_1)))), [])) : ((objectArg_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), objectArg_3.getPropertiesOfType(baseType)))))));
|
|
709
792
|
const isInProgress = exists((inProgress) => (inProgress === baseType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions);
|
|
710
793
|
const members_1 = isInProgress ? empty() : withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Expansions, baseType, () => collect((property) => readPropertyMembers(reader, typeReferenceNode, property), filteredProperties));
|
|
711
794
|
const defaults = defaultTypeArguments(reader, value_6(typeReferenceNode.typeArguments)[0]);
|
|
@@ -827,7 +910,7 @@ export function readReadonly(reader, typeReferenceNode) {
|
|
|
827
910
|
}, unionType.types))])])]);
|
|
828
911
|
}
|
|
829
912
|
catch (matchValue_2) {
|
|
830
|
-
const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs",
|
|
913
|
+
const item = Report_readerError_Z19516DCE("Readonly", "Unable to read the members of the union type", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UtilityType.fs", 792);
|
|
831
914
|
const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
|
|
832
915
|
void (objectArg.push(item));
|
|
833
916
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|