@glutinum/cli 1.0.0-beta.1 → 1.0.0-beta.10
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/README.md +16 -0
- package/dist/Glutinum.Converter/Abbreviations.js +9 -32
- package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
- package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
- package/dist/Glutinum.Converter/FsharpAST.js +116 -65
- package/dist/Glutinum.Converter/Generate.js +38 -25
- package/dist/Glutinum.Converter/GlueAST.js +82 -43
- package/dist/Glutinum.Converter/Hosting.js +143 -169
- package/dist/Glutinum.Converter/Merge.js +369 -337
- package/dist/Glutinum.Converter/Packages.js +384 -94
- package/dist/Glutinum.Converter/Printer.js +432 -393
- package/dist/Glutinum.Converter/Read.js +361 -99
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
- package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
- package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
- package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
- package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
- package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +15 -21
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
- 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 +8 -11
- package/dist/Glutinum.Converter/Reader/Parameters.js +36 -27
- package/dist/Glutinum.Converter/Reader/TypeNode.js +389 -1583
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +76 -49
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
- package/dist/Glutinum.Converter/Reader/Types.js +295 -15
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
- package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
- package/dist/Glutinum.Converter/Reader/Utils.js +487 -101
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +2915 -8176
- package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
- package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
- package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
- package/dist/Glutinum.Converter/Transformer/Conditionals.js +1087 -0
- package/dist/Glutinum.Converter/Transformer/Context.js +678 -0
- package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
- package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +493 -0
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
- package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +356 -0
- package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
- package/dist/Glutinum.Converter/Utils/String.js +14 -3
- package/dist/Program.js +102 -239
- package/package.json +3 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ts } from "@ts-morph/bootstrap";
|
|
3
3
|
import { singleton, empty, append as append_1, delay, indexed, choose, toList, tryItem } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
4
4
|
import { isNullOrWhiteSpace, concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
|
|
5
|
-
import { value as
|
|
5
|
+
import { value as value_3, defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
6
6
|
import { match } from "../../fable_modules/fable-library-js.5.17.2/RegExp.js";
|
|
7
7
|
import { empty as empty_1, forAll, append } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
8
8
|
import { splitLines } from "../Utils/String.js";
|
|
@@ -115,47 +115,35 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
115
115
|
const matchValue_5 = tag_3.kind;
|
|
116
116
|
switch (matchValue_5) {
|
|
117
117
|
case 328: {
|
|
118
|
+
const textTag = (make) => {
|
|
119
|
+
const option_13 = tag_3.comment;
|
|
120
|
+
if (option_13 != null) {
|
|
121
|
+
return make(defaultArg(textOfComment(option_13), ""));
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
118
127
|
const matchValue_8 = tag_3.tagName.getText();
|
|
119
128
|
switch (matchValue_8) {
|
|
120
|
-
case "remarks":
|
|
129
|
+
case "remarks":
|
|
130
|
+
return textTag((Item_4) => (new GlueComment(/* Remarks */ 4, [Item_4])));
|
|
131
|
+
case "defaultValue":
|
|
132
|
+
return textTag((Item_5) => (new GlueComment(/* DefaultValue */ 5, [Item_5])));
|
|
133
|
+
case "example":
|
|
134
|
+
return textTag((Item_6) => (new GlueComment(/* Example */ 6, [Item_6])));
|
|
135
|
+
case "typeParam": {
|
|
121
136
|
const matchValue_9 = tag_3.comment;
|
|
122
137
|
if (matchValue_9 == null) {
|
|
123
138
|
return undefined;
|
|
124
139
|
}
|
|
125
140
|
else {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
case "defaultValue": {
|
|
130
|
-
const matchValue_10 = tag_3.comment;
|
|
131
|
-
if (matchValue_10 == null) {
|
|
132
|
-
return undefined;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return new GlueComment(/* DefaultValue */ 5, [defaultArg(textOfComment(matchValue_10), "")]);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
case "example": {
|
|
139
|
-
const matchValue_11 = tag_3.comment;
|
|
140
|
-
if (matchValue_11 == null) {
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
return new GlueComment(/* Example */ 6, [defaultArg(textOfComment(matchValue_11), "")]);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
case "typeParam": {
|
|
148
|
-
const matchValue_12 = tag_3.comment;
|
|
149
|
-
if (matchValue_12 == null) {
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
const matchValue_13 = textOfComment(matchValue_12);
|
|
154
|
-
if (matchValue_13 == null) {
|
|
141
|
+
const matchValue_10 = textOfComment(matchValue_9);
|
|
142
|
+
if (matchValue_10 == null) {
|
|
155
143
|
return undefined;
|
|
156
144
|
}
|
|
157
145
|
else {
|
|
158
|
-
const text_3 =
|
|
146
|
+
const text_3 = matchValue_10;
|
|
159
147
|
const m_1 = match(/\s*(?<type>[^-\s]*)\s*-\s*(?<description>.*)/gus, text_3);
|
|
160
148
|
if (m_1 != null) {
|
|
161
149
|
return new GlueComment(/* TypeParam */ 7, [new GlueCommentTypeParam((m_1.groups && m_1.groups.type) || "", ((m_1.groups && m_1.groups.description) != null) ? ((m_1.groups && m_1.groups.description) || "") : undefined)]);
|
|
@@ -213,8 +201,8 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
213
201
|
}
|
|
214
202
|
}, indexed(jsDocTags)));
|
|
215
203
|
return toList(delay(() => {
|
|
216
|
-
let
|
|
217
|
-
return append_1((
|
|
204
|
+
let matchValue_11;
|
|
205
|
+
return append_1((matchValue_11 = summary_1, (matchValue_11 == null) ? (empty()) : singleton(matchValue_11)), delay(() => jsDocTags_1));
|
|
218
206
|
}));
|
|
219
207
|
}
|
|
220
208
|
|
|
@@ -246,7 +234,7 @@ export function readDocumentationForNode(reader, node) {
|
|
|
246
234
|
return empty_1();
|
|
247
235
|
}
|
|
248
236
|
else {
|
|
249
|
-
const symbol_1 =
|
|
237
|
+
const symbol_1 = value_3(matchValue_1);
|
|
250
238
|
return readDocumentation(reader, symbol_1.getDocumentationComment(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]()), ts.getJSDocTags(node));
|
|
251
239
|
}
|
|
252
240
|
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
import { equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { defaultOf, equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
3
|
+
import { PackageContext__DefaultExportName_Z721C83C5, PackageContext__TryFindPackage_Z721C83C5 } from "./Types.js";
|
|
4
|
+
import { normalizePath } from "../Utils/String.js";
|
|
5
|
+
import { forAll } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
6
|
+
import { isLetterOrDigit } from "../../fable_modules/fable-library-js.5.17.2/Char.js";
|
|
7
|
+
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
|
|
8
|
+
import { primitiveOfFlags, $007CHasTypeFlags$007C_$007C, $007CHasSymbolFlags$007C_$007C } from "./Utils.js";
|
|
9
|
+
import { value as value_2, some, defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
10
|
+
import { GlueVariable, GlueFunctionDeclaration, GluePrimitive, GlueType } from "../GlueAST.js";
|
|
5
11
|
import { item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
6
12
|
|
|
7
13
|
export function readExportAssignment(reader, exportNode) {
|
|
8
|
-
let declaration;
|
|
14
|
+
let declaration, package$, name_1, declares, exports, option_5, moduleSymbol, declaration_1, declarations;
|
|
9
15
|
const symbolOpt = exportNode.symbol;
|
|
10
|
-
let
|
|
11
|
-
if (
|
|
16
|
+
let targetDeclarationKind;
|
|
17
|
+
if (exportNode.expression.kind === 80) {
|
|
12
18
|
let option_3;
|
|
13
19
|
const option_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(exportNode.expression);
|
|
14
20
|
if (option_1 != null) {
|
|
@@ -18,39 +24,77 @@ export function readExportAssignment(reader, exportNode) {
|
|
|
18
24
|
else {
|
|
19
25
|
option_3 = undefined;
|
|
20
26
|
}
|
|
21
|
-
|
|
27
|
+
targetDeclarationKind = ((option_3 != null) ? ((declaration = option_3, declaration.kind)) : undefined);
|
|
22
28
|
}
|
|
23
29
|
else {
|
|
24
|
-
|
|
30
|
+
targetDeclarationKind = undefined;
|
|
25
31
|
}
|
|
32
|
+
const exportEqualsDeclarationKind = equals(exportNode.isExportEquals, true) ? targetDeclarationKind : undefined;
|
|
33
|
+
const isDefaultOfVariable = !equals(exportNode.isExportEquals, true) && equals(targetDeclarationKind, 261);
|
|
34
|
+
const sourceFile = exportNode.getSourceFile();
|
|
35
|
+
let packageName;
|
|
36
|
+
let option_14;
|
|
37
|
+
let option_12;
|
|
38
|
+
let option_10;
|
|
39
|
+
const option_8 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
|
|
40
|
+
option_10 = ((option_8 != null) ? PackageContext__TryFindPackage_Z721C83C5(option_8, sourceFile.fileName) : undefined);
|
|
41
|
+
option_12 = ((option_10 != null) ? (((package$ = option_10, normalizePath(sourceFile.fileName) === package$.EntryFile)) ? option_10 : undefined) : undefined);
|
|
42
|
+
option_14 = ((option_12 != null) ? option_12.RuntimeName : undefined);
|
|
43
|
+
packageName = ((option_14 != null) ? (((name_1 = option_14, forAll((c) => {
|
|
44
|
+
if (isLetterOrDigit(c)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return c === "_";
|
|
49
|
+
}
|
|
50
|
+
}, name_1.split("")) && !((declares = ((table) => {
|
|
51
|
+
if (Operators_IsNull(table)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const symbol_1 = table.get(name_1);
|
|
56
|
+
if (!Operators_IsNull(symbol_1)) {
|
|
57
|
+
const matchValue = symbol_1.flags;
|
|
58
|
+
if ($007CHasSymbolFlags$007C_$007C(2097152, matchValue) != null) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}), (exports = defaultArg((option_5 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(sourceFile), (option_5 != null) ? some((moduleSymbol = option_5, moduleSymbol.exports)) : undefined), defaultOf()), declares(sourceFile.locals) ? true : declares(exports)))))) ? option_14 : undefined) : undefined);
|
|
70
|
+
let publishedName;
|
|
71
|
+
const option_16 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
|
|
72
|
+
publishedName = ((option_16 != null) ? PackageContext__DefaultExportName_Z721C83C5(option_16, sourceFile.fileName) : undefined);
|
|
26
73
|
const isExportEqualsOfVariable = equals(exportEqualsDeclarationKind, 261);
|
|
27
74
|
const isExportEqualsOfDeclaration = equals(exportEqualsDeclarationKind, 263) ? true : equals(exportEqualsDeclarationKind, 264);
|
|
28
75
|
if (symbolOpt == null) {
|
|
29
76
|
return GlueType.Discard;
|
|
30
77
|
}
|
|
31
78
|
else {
|
|
32
|
-
const
|
|
33
|
-
if (((
|
|
79
|
+
const symbol_2 = symbolOpt;
|
|
80
|
+
if (((symbol_2.name === "default") ? true : isExportEqualsOfVariable) ? true : isExportEqualsOfDeclaration) {
|
|
34
81
|
if (exportNode.expression.kind === 80) {
|
|
35
82
|
const identiferNode = exportNode.expression;
|
|
36
83
|
let declaredTypeNode;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
else {
|
|
52
|
-
declaredTypeNode = undefined;
|
|
53
|
-
}
|
|
84
|
+
let option_22;
|
|
85
|
+
let option_20;
|
|
86
|
+
const option_18 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(exportNode.expression);
|
|
87
|
+
if (option_18 != null) {
|
|
88
|
+
const _arg_1 = option_18;
|
|
89
|
+
option_20 = _arg_1.valueDeclaration;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
option_20 = undefined;
|
|
93
|
+
}
|
|
94
|
+
option_22 = ((option_20 != null) ? (((declaration_1 = option_20, declaration_1.kind === 261)) ? option_20 : undefined) : undefined);
|
|
95
|
+
if (option_22 != null) {
|
|
96
|
+
const declaration_2 = option_22;
|
|
97
|
+
declaredTypeNode = declaration_2.type;
|
|
54
98
|
}
|
|
55
99
|
else {
|
|
56
100
|
declaredTypeNode = undefined;
|
|
@@ -58,26 +102,49 @@ export function readExportAssignment(reader, exportNode) {
|
|
|
58
102
|
let typ;
|
|
59
103
|
const tsTyp = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeAtLocation(exportNode.expression);
|
|
60
104
|
if (declaredTypeNode == null) {
|
|
61
|
-
const
|
|
62
|
-
if ($007CHasTypeFlags$007C_$007C(1048576,
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
105
|
+
const matchValue_2 = tsTyp.flags;
|
|
106
|
+
if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_2) != null) {
|
|
107
|
+
const matchValue_3 = tsTyp.symbol.declarations;
|
|
108
|
+
let matchResult, declarations_1;
|
|
109
|
+
if (matchValue_3 != null) {
|
|
110
|
+
if ((declarations = matchValue_3, declarations.length === 1)) {
|
|
111
|
+
matchResult = 0;
|
|
112
|
+
declarations_1 = matchValue_3;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
matchResult = 1;
|
|
116
|
+
}
|
|
66
117
|
}
|
|
67
118
|
else {
|
|
68
|
-
|
|
69
|
-
|
|
119
|
+
matchResult = 1;
|
|
120
|
+
}
|
|
121
|
+
switch (matchResult) {
|
|
122
|
+
case 0: {
|
|
123
|
+
typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](item(0, declarations_1));
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
default:
|
|
127
|
+
typ = (new GlueType(/* Primitive */ 3, [GluePrimitive.Any]));
|
|
70
128
|
}
|
|
71
129
|
}
|
|
72
130
|
else {
|
|
73
|
-
typ = (
|
|
131
|
+
typ = primitiveOfFlags(tsTyp);
|
|
74
132
|
}
|
|
75
133
|
}
|
|
76
134
|
else {
|
|
77
135
|
const typeNode = declaredTypeNode;
|
|
78
136
|
typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
|
|
79
137
|
}
|
|
80
|
-
|
|
138
|
+
const documentation = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](exportNode);
|
|
139
|
+
const isPublished = isDefaultOfVariable && (publishedName != null);
|
|
140
|
+
const name_2 = isExportEqualsOfVariable ? ("export=" + identiferNode.getText()) : (isPublished ? value_2(publishedName) : (isDefaultOfVariable ? defaultArg(packageName, identiferNode.getText()) : identiferNode.getText()));
|
|
141
|
+
const declaration_3 = (typ.tag === 15) ? (isDefaultOfVariable ? (new GlueType(/* FunctionDeclaration */ 6, [new GlueFunctionDeclaration(documentation, true, name_2, typ.fields[0].Type, typ.fields[0].Parameters, typ.fields[0].TypeParameters)])) : (new GlueType(/* Variable */ 2, [new GlueVariable(documentation, name_2, typ)]))) : (new GlueType(/* Variable */ 2, [new GlueVariable(documentation, name_2, typ)]));
|
|
142
|
+
if (isPublished) {
|
|
143
|
+
return declaration_3;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
return new GlueType(/* ExportDefault */ 25, [declaration_3]);
|
|
147
|
+
}
|
|
81
148
|
}
|
|
82
149
|
else {
|
|
83
150
|
return GlueType.Discard;
|
|
@@ -1,35 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
import { modulePathForDeclaration,
|
|
3
|
-
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
|
|
2
|
+
import { modulePathForDeclaration, resolveAlias } from "./Utils.js";
|
|
4
3
|
import { normalizePath } from "../Utils/String.js";
|
|
5
4
|
import { contains, item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
6
5
|
import { PackageContext__IsExternal_Z721C83C5 } from "./Types.js";
|
|
7
|
-
import { filter, collect, choose, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
8
|
-
import { List_distinctBy } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
9
|
-
import { newGuid } from "../../fable_modules/fable-library-js.5.17.2/Guid.js";
|
|
6
|
+
import { filter, collect, choose, cons, fold, reverse, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
10
7
|
import { GlueType, GlueReExport } from "../GlueAST.js";
|
|
11
8
|
import { toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
12
9
|
import { stringHash } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
13
10
|
|
|
14
|
-
function tryResolveAlias(checker, symbol) {
|
|
15
|
-
const matchValue = symbol.flags;
|
|
16
|
-
if ($007CHasSymbolFlags$007C_$007C(2097152, matchValue) != null) {
|
|
17
|
-
try {
|
|
18
|
-
const aliased = checker.getAliasedSymbol(symbol);
|
|
19
|
-
return Operators_IsNull(aliased) ? undefined : aliased;
|
|
20
|
-
}
|
|
21
|
-
catch (matchValue_1) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return symbol;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
11
|
function readReExport(reader, packageContext, currentFile, exportedName, symbol) {
|
|
31
12
|
let declarations;
|
|
32
|
-
const matchValue =
|
|
13
|
+
const matchValue = resolveAlias(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), symbol);
|
|
33
14
|
if (matchValue != null) {
|
|
34
15
|
const target = matchValue;
|
|
35
16
|
const matchValue_1 = target.declarations;
|
|
@@ -53,28 +34,35 @@ function readReExport(reader, packageContext, currentFile, exportedName, symbol)
|
|
|
53
34
|
return empty();
|
|
54
35
|
}
|
|
55
36
|
else {
|
|
56
|
-
return
|
|
37
|
+
return reverse(fold((tupledArg, glueType) => {
|
|
38
|
+
const kept = tupledArg[0];
|
|
39
|
+
const hasInterface = tupledArg[1];
|
|
57
40
|
let matchResult_1;
|
|
58
41
|
if (glueType.tag === 32) {
|
|
59
42
|
if (glueType.fields[0].Declaration.tag === 1) {
|
|
60
|
-
|
|
43
|
+
if (hasInterface) {
|
|
44
|
+
matchResult_1 = 0;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
matchResult_1 = 1;
|
|
48
|
+
}
|
|
61
49
|
}
|
|
62
50
|
else {
|
|
63
|
-
matchResult_1 =
|
|
51
|
+
matchResult_1 = 2;
|
|
64
52
|
}
|
|
65
53
|
}
|
|
66
54
|
else {
|
|
67
|
-
matchResult_1 =
|
|
55
|
+
matchResult_1 = 2;
|
|
68
56
|
}
|
|
69
57
|
switch (matchResult_1) {
|
|
70
58
|
case 0:
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
return [kept, true];
|
|
60
|
+
case 1:
|
|
61
|
+
return [cons(glueType, kept), true];
|
|
62
|
+
default:
|
|
63
|
+
return [cons(glueType, kept), hasInterface];
|
|
76
64
|
}
|
|
77
|
-
}, choose((declaration) => {
|
|
65
|
+
}, [empty(), false], choose((declaration) => {
|
|
78
66
|
let declaration_1;
|
|
79
67
|
let option_1;
|
|
80
68
|
const matchValue_2 = declaration.kind;
|
|
@@ -100,10 +88,7 @@ function readReExport(reader, packageContext, currentFile, exportedName, symbol)
|
|
|
100
88
|
else {
|
|
101
89
|
return undefined;
|
|
102
90
|
}
|
|
103
|
-
}, toList(declarations_1))
|
|
104
|
-
Equals: (x, y) => (x === y),
|
|
105
|
-
GetHashCode: (x) => (stringHash(x) | 0),
|
|
106
|
-
});
|
|
91
|
+
}, toList(declarations_1)))[0]);
|
|
107
92
|
}
|
|
108
93
|
}
|
|
109
94
|
default:
|
|
@@ -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
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
3
|
-
import { tryReadKeyOfConstraint, ModifierUtil_HasModifier_742AC9D } from "./Utils.js";
|
|
3
|
+
import { tryReadKeyOfConstraint, isDefaultInExportList, ModifierUtil_HasModifier_742AC9D } from "./Utils.js";
|
|
4
4
|
import { Exception } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
5
5
|
import { Report_readerError_Z19516DCE } from "./Report.js";
|
|
6
6
|
import { mapIndexed } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
@@ -11,28 +11,41 @@ export function readFunctionDeclaration(reader, declaration) {
|
|
|
11
11
|
let isDeclared;
|
|
12
12
|
const matchValue = declaration.modifiers;
|
|
13
13
|
isDeclared = ((matchValue == null) ? false : exists((modifier) => (modifier.kind === 138), matchValue));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
let isDefaultExport;
|
|
15
|
+
if (ModifierUtil_HasModifier_742AC9D(declaration.modifiers, 90)) {
|
|
16
|
+
isDefaultExport = true;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const matchValue_1 = declaration.name;
|
|
20
|
+
if (matchValue_1 == null) {
|
|
21
|
+
isDefaultExport = false;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const name = matchValue_1;
|
|
25
|
+
isDefaultExport = isDefaultInExportList(declaration, name.getText());
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let name_2;
|
|
29
|
+
const matchValue_2 = declaration.name;
|
|
30
|
+
if (matchValue_2 == null) {
|
|
18
31
|
if (isDefaultExport) {
|
|
19
|
-
|
|
32
|
+
name_2 = "defaultExport";
|
|
20
33
|
}
|
|
21
34
|
else {
|
|
22
|
-
throw new Exception(Report_readerError_Z19516DCE("function declaration", "Missing name", declaration, "/_//src/Glutinum.Converter/Reader/FunctionDeclaration.fs",
|
|
35
|
+
throw new Exception(Report_readerError_Z19516DCE("function declaration", "Missing name", declaration, "/_//src/Glutinum.Converter/Reader/FunctionDeclaration.fs", 34));
|
|
23
36
|
}
|
|
24
37
|
}
|
|
25
38
|
else {
|
|
26
|
-
const
|
|
27
|
-
|
|
39
|
+
const name_1 = matchValue_2;
|
|
40
|
+
name_2 = name_1.getText();
|
|
28
41
|
}
|
|
29
|
-
const functionDeclaration = new GlueFunctionDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromSignature61B89E55"](declaration), isDeclared,
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
42
|
+
const functionDeclaration = new GlueFunctionDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromSignature61B89E55"](declaration), isDeclared, name_2, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](declaration.type), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](declaration.parameters), mapIndexed((index, typeParameter) => {
|
|
43
|
+
const matchValue_3 = tryReadKeyOfConstraint(reader, value(declaration.typeParameters)[index]);
|
|
44
|
+
if (matchValue_3 == null) {
|
|
32
45
|
return typeParameter;
|
|
33
46
|
}
|
|
34
47
|
else {
|
|
35
|
-
return new GlueTypeParameter(typeParameter.Name,
|
|
48
|
+
return new GlueTypeParameter(typeParameter.Name, matchValue_3, typeParameter.Default);
|
|
36
49
|
}
|
|
37
50
|
}, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](declaration.typeParameters)));
|
|
38
51
|
if (isDefaultExport) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { GluePrimitive, GlueType, GlueIndexedAccessType } from "../GlueAST.js";
|
|
3
|
-
import { $007CHasTypeFlags$007C_$007C } from "./Utils.js";
|
|
3
|
+
import { typeNodeBuilderFlags, $007CHasTypeFlags$007C_$007C, enclosingDeclarationOf } from "./Utils.js";
|
|
4
4
|
import { Report_readerError_Z19516DCE } from "./Report.js";
|
|
5
5
|
import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
|
|
6
6
|
import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
|
|
@@ -12,7 +12,7 @@ export function readIndexedAccessType(reader, declaration) {
|
|
|
12
12
|
const node = declaration;
|
|
13
13
|
const tryTypeToTypeNode = (typ, flags) => {
|
|
14
14
|
try {
|
|
15
|
-
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, node, flags);
|
|
15
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, enclosingDeclarationOf(node), flags);
|
|
16
16
|
}
|
|
17
17
|
catch (matchValue) {
|
|
18
18
|
return undefined;
|
|
@@ -21,17 +21,14 @@ export function readIndexedAccessType(reader, declaration) {
|
|
|
21
21
|
const matchValue_3 = idxNodeType.kind;
|
|
22
22
|
let matchResult;
|
|
23
23
|
switch (matchValue_3) {
|
|
24
|
-
case 150:
|
|
25
|
-
matchResult = 1;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
24
|
+
case 150:
|
|
28
25
|
case 154:
|
|
29
26
|
case 184: {
|
|
30
|
-
matchResult =
|
|
27
|
+
matchResult = 3;
|
|
31
28
|
break;
|
|
32
29
|
}
|
|
33
30
|
case 194: {
|
|
34
|
-
matchResult =
|
|
31
|
+
matchResult = 4;
|
|
35
32
|
break;
|
|
36
33
|
}
|
|
37
34
|
case 199: {
|
|
@@ -40,15 +37,15 @@ export function readIndexedAccessType(reader, declaration) {
|
|
|
40
37
|
}
|
|
41
38
|
case 202: {
|
|
42
39
|
if (node.pos >= 0) {
|
|
43
|
-
matchResult =
|
|
40
|
+
matchResult = 1;
|
|
44
41
|
}
|
|
45
42
|
else {
|
|
46
|
-
matchResult =
|
|
43
|
+
matchResult = 2;
|
|
47
44
|
}
|
|
48
45
|
break;
|
|
49
46
|
}
|
|
50
47
|
default:
|
|
51
|
-
matchResult =
|
|
48
|
+
matchResult = 5;
|
|
52
49
|
}
|
|
53
50
|
switch (matchResult) {
|
|
54
51
|
case 0: {
|
|
@@ -61,7 +58,7 @@ export function readIndexedAccessType(reader, declaration) {
|
|
|
61
58
|
const typ_1 = checker.getTypeAtLocation(node);
|
|
62
59
|
const matchValue_1 = typ_1.flags;
|
|
63
60
|
if ($007CHasTypeFlags$007C_$007C(134217728, matchValue_1) != null) {
|
|
64
|
-
const matchValue_2 = tryTypeToTypeNode(typ_1,
|
|
61
|
+
const matchValue_2 = tryTypeToTypeNode(typ_1, typeNodeBuilderFlags);
|
|
65
62
|
let matchResult_1, typeNode_1;
|
|
66
63
|
if (matchValue_2 != null) {
|
|
67
64
|
if ((typeNode = matchValue_2, typeNode.kind === 193)) {
|
|
@@ -96,20 +93,17 @@ export function readIndexedAccessType(reader, declaration) {
|
|
|
96
93
|
return matchValue_4;
|
|
97
94
|
}
|
|
98
95
|
}
|
|
99
|
-
case 1:
|
|
100
|
-
return withIndexType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](idxNodeType));
|
|
101
|
-
case 2: {
|
|
96
|
+
case 1: {
|
|
102
97
|
const checker_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
103
98
|
const objectType = checker_1.getTypeAtLocation(declaration.objectType);
|
|
104
99
|
const key = idxNodeType.literal.text;
|
|
105
|
-
const flags_2 = 1 | 16384;
|
|
106
100
|
const matchValue_5 = checker_1.getPropertyOfType(objectType, key);
|
|
107
101
|
if (matchValue_5 == null) {
|
|
108
102
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
109
103
|
}
|
|
110
104
|
else {
|
|
111
105
|
const property = matchValue_5;
|
|
112
|
-
const matchValue_6 = tryTypeToTypeNode(checker_1.getTypeOfSymbol(property),
|
|
106
|
+
const matchValue_6 = tryTypeToTypeNode(checker_1.getTypeOfSymbol(property), typeNodeBuilderFlags);
|
|
113
107
|
if (matchValue_6 == null) {
|
|
114
108
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
115
109
|
}
|
|
@@ -119,14 +113,14 @@ export function readIndexedAccessType(reader, declaration) {
|
|
|
119
113
|
}
|
|
120
114
|
}
|
|
121
115
|
}
|
|
122
|
-
case
|
|
116
|
+
case 2:
|
|
123
117
|
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
124
|
-
case
|
|
118
|
+
case 3:
|
|
125
119
|
return withIndexType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](idxNodeType));
|
|
126
|
-
case
|
|
120
|
+
case 4:
|
|
127
121
|
return withIndexType(GlueType.Discard);
|
|
128
122
|
default: {
|
|
129
|
-
const warning = Report_readerError_Z19516DCE("readIndexedAccessType", concat("Unsupported node kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue_3)), idxNodeType, "/_//src/Glutinum.Converter/Reader/IndexedAccessType.fs",
|
|
123
|
+
const warning = Report_readerError_Z19516DCE("readIndexedAccessType", concat("Unsupported node kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue_3)), idxNodeType, "/_//src/Glutinum.Converter/Reader/IndexedAccessType.fs", 87);
|
|
130
124
|
void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning));
|
|
131
125
|
return withIndexType(GlueType.Discard);
|
|
132
126
|
}
|