@glutinum/cli 1.0.0-beta.2 → 1.0.0-beta.3
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 +34 -21
- package/dist/Glutinum.Converter/GlueAST.js +79 -41
- package/dist/Glutinum.Converter/Hosting.js +132 -157
- package/dist/Glutinum.Converter/Merge.js +369 -337
- package/dist/Glutinum.Converter/Packages.js +391 -92
- package/dist/Glutinum.Converter/Printer.js +396 -423
- package/dist/Glutinum.Converter/Read.js +387 -88
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
- package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
- 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/FunctionDeclaration.js +26 -13
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +14 -20
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
- package/dist/Glutinum.Converter/Reader/Node.js +8 -11
- package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
- package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1342
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
- 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 +290 -15
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
- package/dist/Glutinum.Converter/Reader/Utils.js +325 -25
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +3568 -8456
- 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 +1149 -0
- package/dist/Glutinum.Converter/Transformer/Context.js +666 -0
- package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +596 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
- package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -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 +18 -10
- package/package.json +1 -1
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
import { orElse, defaultArg, some } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
3
|
+
import { GlueTypeParameter, GlueAccessor, GlueLiteral, GlueType, GluePrimitive } from "../GlueAST.js";
|
|
3
4
|
import { tryParse } from "../../fable_modules/fable-library-js.5.17.2/Int32.js";
|
|
4
5
|
import { FSharpRef } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
5
|
-
import { GlueTypeParameter, GlueType, GlueAccessor, GlueLiteral } from "../GlueAST.js";
|
|
6
6
|
import { tryParse as tryParse_1 } from "../../fable_modules/fable-library-js.5.17.2/Double.js";
|
|
7
|
-
import { comparePrimitives, stringHash, defaultOf } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
7
|
+
import { equals, comparePrimitives, stringHash, defaultOf } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
8
8
|
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
|
|
9
|
-
import { normalizePath } from "../Utils/String.js";
|
|
9
|
+
import { withoutDeclarationExtension, normalizePath } from "../Utils/String.js";
|
|
10
10
|
import { class_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
|
|
11
|
-
import { tryPick, last, toList, tryHead, exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
12
|
-
import {
|
|
13
|
-
import { append, cons, tryHead as tryHead_1, exists as exists_1, tryFind, isEmpty, filter, head, tryItem, mapIndexed, choose, ofArray, contains, collect as collect_1, empty, map as map_1 } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
14
|
-
import { item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
11
|
+
import { tryPick, map as map_2, last, iterate, toList, tryHead, exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
12
|
+
import { PackageContext__ModulePath_Z7E147617, PackageContext__NestedAmbientModuleSegments_32BC514A, PackageContext__IsEntryFile_Z721C83C5, ambientSpecifier, PackageContext__IsExternal_Z721C83C5, PackageContext__TryFindExternalModulePath_Z721C83C5, PackageContext__TryFindPackage_Z721C83C5 } from "./Types.js";
|
|
13
|
+
import { tail, append, cons, tryHead as tryHead_1, exists as exists_1, tryFind, isEmpty, filter, head, tryItem, mapIndexed, choose, ofArray, contains, collect as collect_1, empty, map as map_1 } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
14
|
+
import { item as item_1 } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
15
15
|
import { contains as contains_1, ofSeq } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
|
|
16
16
|
import { ofList, empty as empty_1 } from "../../fable_modules/fable-library-js.5.17.2/Map.js";
|
|
17
|
-
import { replace } from "../../fable_modules/fable-library-js.5.17.2/RegExp.js";
|
|
18
17
|
import { substring, split } from "../../fable_modules/fable-library-js.5.17.2/String.js";
|
|
19
18
|
import { sanitizeTypeName, removeSurroundingQuotes } from "../Utils/Naming.js";
|
|
20
19
|
import { ts } from "@ts-morph/bootstrap";
|
|
@@ -29,6 +28,61 @@ export function $007CHasTypeFlags$007C_$007C(flag, flags) {
|
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
|
|
31
|
+
export const typeNodeBuilderFlags = 1 | 16384;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The primitive a type resolves to by its flags, `obj` for the others
|
|
35
|
+
*/
|
|
36
|
+
export function primitiveOfFlags(typ) {
|
|
37
|
+
const matchValue = typ.flags;
|
|
38
|
+
if ($007CHasTypeFlags$007C_$007C(32, matchValue) != null) {
|
|
39
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.String$]);
|
|
40
|
+
}
|
|
41
|
+
else if ($007CHasTypeFlags$007C_$007C(64, matchValue) != null) {
|
|
42
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Number$]);
|
|
43
|
+
}
|
|
44
|
+
else if ($007CHasTypeFlags$007C_$007C(256, matchValue) != null) {
|
|
45
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Bool]);
|
|
46
|
+
}
|
|
47
|
+
else if ($007CHasTypeFlags$007C_$007C(1, matchValue) != null) {
|
|
48
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
49
|
+
}
|
|
50
|
+
else if ($007CHasTypeFlags$007C_$007C(16, matchValue) != null) {
|
|
51
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Unit]);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function removeParenthesizedType(node_mut) {
|
|
59
|
+
removeParenthesizedType:
|
|
60
|
+
while (true) {
|
|
61
|
+
const node = node_mut;
|
|
62
|
+
if (node.kind === 197) {
|
|
63
|
+
node_mut = node.type;
|
|
64
|
+
continue removeParenthesizedType;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return node;
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Read with `item` among the ones in progress, so that a declaration reaching itself is detected
|
|
75
|
+
*/
|
|
76
|
+
export function withInProgress(inProgress, item, read) {
|
|
77
|
+
void (inProgress.push(item));
|
|
78
|
+
try {
|
|
79
|
+
return read();
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
inProgress.splice(inProgress.length - 1, 1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
32
86
|
export function $007CHasSymbolFlags$007C_$007C(flag, flags) {
|
|
33
87
|
if ((flags & flag) !== 0) {
|
|
34
88
|
return some(undefined);
|
|
@@ -168,13 +222,15 @@ export function tryReadLiteral(checker, expression) {
|
|
|
168
222
|
}
|
|
169
223
|
|
|
170
224
|
/**
|
|
171
|
-
* Nodes synthesized by <c>typeToTypeNode</c> have no source text
|
|
172
225
|
* An `Identifier` and a `StringLiteral` both carry the name in `text`
|
|
173
226
|
*/
|
|
174
227
|
export function moduleExportNameText(name) {
|
|
175
228
|
return name.text;
|
|
176
229
|
}
|
|
177
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Nodes synthesized by <c>typeToTypeNode</c> have no source text
|
|
233
|
+
*/
|
|
178
234
|
export function identifierText(node) {
|
|
179
235
|
if (Operators_IsNull(node.text)) {
|
|
180
236
|
return node.getText();
|
|
@@ -495,12 +551,47 @@ export function resolvedBaseTypeArguments(checker, expression) {
|
|
|
495
551
|
}
|
|
496
552
|
}
|
|
497
553
|
|
|
554
|
+
function readExternalBase(reader, clauseType) {
|
|
555
|
+
const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
|
|
556
|
+
if (matchValue == null) {
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
const packageContext = matchValue;
|
|
560
|
+
let option_5;
|
|
561
|
+
let option_3;
|
|
562
|
+
const option = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(clauseType.expression);
|
|
563
|
+
let mapping;
|
|
564
|
+
const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
565
|
+
mapping = ((symbol) => followAlias(checker, symbol));
|
|
566
|
+
const option_1 = option;
|
|
567
|
+
option_3 = ((option_1 != null) ? mapping(option_1) : undefined);
|
|
568
|
+
if (option_3 != null) {
|
|
569
|
+
const symbol_1 = option_3;
|
|
570
|
+
option_5 = symbol_1.declarations;
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
option_5 = undefined;
|
|
574
|
+
}
|
|
575
|
+
if (option_5 != null) {
|
|
576
|
+
iterate((declaration) => {
|
|
577
|
+
const declaration_1 = declaration;
|
|
578
|
+
if (((declaration_1.kind === 265) && !reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.HasRead6C0FD055"](declaration_1)) && (PackageContext__TryFindExternalModulePath_Z721C83C5(packageContext, declaration_1.getSourceFile().fileName) != null)) {
|
|
579
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1);
|
|
580
|
+
}
|
|
581
|
+
}, option_5);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
498
586
|
export function readHeritageClauses(reader, heritageClauses) {
|
|
499
587
|
if (heritageClauses == null) {
|
|
500
588
|
return empty();
|
|
501
589
|
}
|
|
502
590
|
else {
|
|
503
|
-
return collect_1((clause) => map_1((
|
|
591
|
+
return collect_1((clause) => map_1((clauseType) => {
|
|
592
|
+
readExternalBase(reader, clauseType);
|
|
593
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](clauseType);
|
|
594
|
+
}, toList(clause.types)), toList(heritageClauses));
|
|
504
595
|
}
|
|
505
596
|
}
|
|
506
597
|
|
|
@@ -515,11 +606,11 @@ export function isFromEs5Lib(symbolOpt) {
|
|
|
515
606
|
const matchValue = symbol.declarations;
|
|
516
607
|
if (matchValue != null) {
|
|
517
608
|
const declarations = matchValue;
|
|
518
|
-
if ((declarations.length === 0) ? true : Operators_IsNull(
|
|
609
|
+
if ((declarations.length === 0) ? true : Operators_IsNull(item_1(0, declarations).parent)) {
|
|
519
610
|
return false;
|
|
520
611
|
}
|
|
521
|
-
else if (
|
|
522
|
-
const sourceFile =
|
|
612
|
+
else if (item_1(0, declarations).parent.kind === 308) {
|
|
613
|
+
const sourceFile = item_1(0, declarations).parent;
|
|
523
614
|
return sourceFile.fileName.endsWith("/lib.es5.d.ts");
|
|
524
615
|
}
|
|
525
616
|
else {
|
|
@@ -561,7 +652,7 @@ export function isFromEsLib(symbolOpt) {
|
|
|
561
652
|
}
|
|
562
653
|
switch (matchResult) {
|
|
563
654
|
case 0: {
|
|
564
|
-
const fileName = normalizePath(
|
|
655
|
+
const fileName = normalizePath(item_1(0, declarations_1).getSourceFile().fileName);
|
|
565
656
|
return fileName.indexOf("/lib/lib.es") >= 0;
|
|
566
657
|
}
|
|
567
658
|
default:
|
|
@@ -594,7 +685,6 @@ export function resolveAlias(checker, symbol) {
|
|
|
594
685
|
}
|
|
595
686
|
|
|
596
687
|
/**
|
|
597
|
-
* Name of the declaration behind an `import { X as Y }` alias, `None` for a non-renamed symbol
|
|
598
688
|
* `Omit<LabelOption, "rotate">` where `interface LabelOption<T = Params>`: `T` is `Params`
|
|
599
689
|
*/
|
|
600
690
|
export function defaultTypeArguments(reader, typeNode) {
|
|
@@ -662,6 +752,9 @@ export function declaredName(symbol) {
|
|
|
662
752
|
}
|
|
663
753
|
}
|
|
664
754
|
|
|
755
|
+
/**
|
|
756
|
+
* Name of the declaration behind an `import { X as Y }` alias, `None` for a non-renamed symbol
|
|
757
|
+
*/
|
|
665
758
|
export function importedName(checker, symbol) {
|
|
666
759
|
let target, target_1;
|
|
667
760
|
const matchValue = symbol.flags;
|
|
@@ -959,10 +1052,10 @@ export function promotedAmbientModule(sourceFile) {
|
|
|
959
1052
|
}
|
|
960
1053
|
else {
|
|
961
1054
|
const ambientModules = map_1((statement_2) => statement_2, filter(isAmbientModule, statements));
|
|
962
|
-
const
|
|
1055
|
+
const fileName_1 = withoutDeclarationExtension(last(split(normalizePath(sourceFile.fileName), ["/"], undefined, 0)));
|
|
963
1056
|
const namedLikeTheFile = filter((moduleDeclaration_2) => {
|
|
964
1057
|
let name;
|
|
965
|
-
return ((name = removeSurroundingQuotes(moduleDeclaration_2.name.text), name.startsWith("node:") ? substring(name, "node:".length) : name)) ===
|
|
1058
|
+
return ((name = removeSurroundingQuotes(moduleDeclaration_2.name.text), name.startsWith("node:") ? substring(name, "node:".length) : name)) === fileName_1;
|
|
966
1059
|
}, ambientModules);
|
|
967
1060
|
return orElse(orElse(tryFind((moduleDeclaration_1) => {
|
|
968
1061
|
let body;
|
|
@@ -990,6 +1083,23 @@ export function promotedAmbientModule(sourceFile) {
|
|
|
990
1083
|
}
|
|
991
1084
|
}
|
|
992
1085
|
|
|
1086
|
+
/**
|
|
1087
|
+
* The names of the ambient modules the program declares, `node:fs` when declared as such
|
|
1088
|
+
*/
|
|
1089
|
+
export function ambientModuleNames(checker) {
|
|
1090
|
+
return ofSeq(map_2((symbol) => removeSurroundingQuotes(symbol.name), checker.getAmbientModules()), {
|
|
1091
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* The specifier of the ambient module a file is made of, `node:fs` when the program declares
|
|
1097
|
+
* that alias too
|
|
1098
|
+
*/
|
|
1099
|
+
export function ambientModuleSpecifier(ambientModuleNames_1, moduleDeclaration) {
|
|
1100
|
+
return ambientSpecifier(ambientModuleNames_1, removeSurroundingQuotes(moduleDeclaration.name.text));
|
|
1101
|
+
}
|
|
1102
|
+
|
|
993
1103
|
export function isPromotedAmbientModule(declaration) {
|
|
994
1104
|
const parent = declaration.parent;
|
|
995
1105
|
if (!Operators_IsNull(parent) && (parent.kind === 308)) {
|
|
@@ -1062,6 +1172,62 @@ export function isExportedDeclaration(statement, names) {
|
|
|
1062
1172
|
}
|
|
1063
1173
|
}
|
|
1064
1174
|
|
|
1175
|
+
/**
|
|
1176
|
+
* `declare class Client {}; export { Client as default }`
|
|
1177
|
+
*/
|
|
1178
|
+
export function isDefaultInExportList(statement, name) {
|
|
1179
|
+
if (statement.parent.kind === 308) {
|
|
1180
|
+
return exists((other) => {
|
|
1181
|
+
let exportClause;
|
|
1182
|
+
if (other.kind === 279) {
|
|
1183
|
+
const exportDeclaration = other;
|
|
1184
|
+
if (exportDeclaration.moduleSpecifier == null) {
|
|
1185
|
+
const matchValue_1 = exportDeclaration.exportClause;
|
|
1186
|
+
let matchResult, exportClause_1;
|
|
1187
|
+
if (matchValue_1 != null) {
|
|
1188
|
+
if ((exportClause = matchValue_1, exportClause.kind === 280)) {
|
|
1189
|
+
matchResult = 0;
|
|
1190
|
+
exportClause_1 = matchValue_1;
|
|
1191
|
+
}
|
|
1192
|
+
else {
|
|
1193
|
+
matchResult = 1;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
else {
|
|
1197
|
+
matchResult = 1;
|
|
1198
|
+
}
|
|
1199
|
+
switch (matchResult) {
|
|
1200
|
+
case 0:
|
|
1201
|
+
return exists((specifier) => {
|
|
1202
|
+
const matchValue_2 = specifier.propertyName;
|
|
1203
|
+
if (matchValue_2 == null) {
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
else if (identifierText(matchValue_2) === name) {
|
|
1207
|
+
return identifierText(specifier.name) === "default";
|
|
1208
|
+
}
|
|
1209
|
+
else {
|
|
1210
|
+
return false;
|
|
1211
|
+
}
|
|
1212
|
+
}, exportClause_1.elements);
|
|
1213
|
+
default:
|
|
1214
|
+
return false;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
return false;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
else {
|
|
1222
|
+
return false;
|
|
1223
|
+
}
|
|
1224
|
+
}, statement.getSourceFile().statements);
|
|
1225
|
+
}
|
|
1226
|
+
else {
|
|
1227
|
+
return false;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1065
1231
|
/**
|
|
1066
1232
|
* `declare class Dispatcher {}; export default Dispatcher` or `export = Dispatcher`
|
|
1067
1233
|
*/
|
|
@@ -1272,10 +1438,42 @@ function namespaceChain(packageContext, declaration) {
|
|
|
1272
1438
|
else {
|
|
1273
1439
|
const moduleDeclaration = node;
|
|
1274
1440
|
const rawName = removeSurroundingQuotes(moduleDeclaration.name.getText());
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1441
|
+
const sourceFile = node.getSourceFile();
|
|
1442
|
+
let ambientModuleOfScript;
|
|
1443
|
+
let matchResult, packageContext_2;
|
|
1444
|
+
if (packageContext != null) {
|
|
1445
|
+
if (isAmbientModuleDeclaration(node) && !(ts.isExternalModule(sourceFile))) {
|
|
1446
|
+
matchResult = 0;
|
|
1447
|
+
packageContext_2 = packageContext;
|
|
1448
|
+
}
|
|
1449
|
+
else {
|
|
1450
|
+
matchResult = 1;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
else {
|
|
1454
|
+
matchResult = 1;
|
|
1455
|
+
}
|
|
1456
|
+
switch (matchResult) {
|
|
1457
|
+
case 0: {
|
|
1458
|
+
const option_1 = PackageContext__TryFindPackage_Z721C83C5(packageContext_2, sourceFile.fileName);
|
|
1459
|
+
ambientModuleOfScript = ((option_1 != null) ? PackageContext__NestedAmbientModuleSegments_32BC514A(packageContext_2, option_1, sourceFile.fileName, rawName) : undefined);
|
|
1460
|
+
break;
|
|
1461
|
+
}
|
|
1462
|
+
default:
|
|
1463
|
+
ambientModuleOfScript = undefined;
|
|
1464
|
+
}
|
|
1465
|
+
if (ambientModuleOfScript == null) {
|
|
1466
|
+
const name = isTopLevelModuleDeclaration(packageContext, node) ? sanitizeTypeName(rawName + "_") : sanitizeTypeName(rawName);
|
|
1467
|
+
node_mut = node.parent;
|
|
1468
|
+
acc_mut = cons(name, acc);
|
|
1469
|
+
continue collect;
|
|
1470
|
+
}
|
|
1471
|
+
else {
|
|
1472
|
+
const segments = ambientModuleOfScript;
|
|
1473
|
+
node_mut = node.parent;
|
|
1474
|
+
acc_mut = append(segments, acc);
|
|
1475
|
+
continue collect;
|
|
1476
|
+
}
|
|
1279
1477
|
}
|
|
1280
1478
|
}
|
|
1281
1479
|
else {
|
|
@@ -1290,11 +1488,45 @@ function namespaceChain(packageContext, declaration) {
|
|
|
1290
1488
|
return collect(declaration.parent, empty());
|
|
1291
1489
|
}
|
|
1292
1490
|
|
|
1491
|
+
function topLevelDeclarationName(declaration) {
|
|
1492
|
+
const top = (node_mut) => {
|
|
1493
|
+
top:
|
|
1494
|
+
while (true) {
|
|
1495
|
+
const node = node_mut;
|
|
1496
|
+
const matchValue = node.parent;
|
|
1497
|
+
if (equals(matchValue, defaultOf())) {
|
|
1498
|
+
return node;
|
|
1499
|
+
}
|
|
1500
|
+
else if (matchValue.kind === 308) {
|
|
1501
|
+
return node;
|
|
1502
|
+
}
|
|
1503
|
+
else {
|
|
1504
|
+
node_mut = matchValue;
|
|
1505
|
+
continue top;
|
|
1506
|
+
}
|
|
1507
|
+
break;
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
const top_1 = top(declaration);
|
|
1511
|
+
const matchValue_1 = top_1.name;
|
|
1512
|
+
if (equals(matchValue_1, defaultOf())) {
|
|
1513
|
+
if ((top_1.kind === 244) && (declaration.kind === 261)) {
|
|
1514
|
+
return declaration.name.getText();
|
|
1515
|
+
}
|
|
1516
|
+
else {
|
|
1517
|
+
return undefined;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
else {
|
|
1521
|
+
return matchValue_1.getText();
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1293
1525
|
/**
|
|
1294
1526
|
* The F# modules qualifying a declaration from another file: its file modules and its namespaces
|
|
1295
1527
|
*/
|
|
1296
1528
|
export function modulePathForDeclaration(packageContext, declaration) {
|
|
1297
|
-
return append(
|
|
1529
|
+
return append(PackageContext__ModulePath_Z7E147617(packageContext, normalizePath(declaration.getSourceFile().fileName), !isPackageGlobal(packageContext, declaration), topLevelDeclarationName(declaration)), namespaceChain(packageContext, declaration));
|
|
1298
1530
|
}
|
|
1299
1531
|
|
|
1300
1532
|
/**
|
|
@@ -1302,7 +1534,7 @@ export function modulePathForDeclaration(packageContext, declaration) {
|
|
|
1302
1534
|
* in package mode, and the namespaces when the reference is written qualified.
|
|
1303
1535
|
*/
|
|
1304
1536
|
export function modulePathForSymbol(checker, packageContext, isQualified, symbolOpt) {
|
|
1305
|
-
let
|
|
1537
|
+
let option_3, declaration_4;
|
|
1306
1538
|
let matchValue;
|
|
1307
1539
|
const option_1 = symbolOpt;
|
|
1308
1540
|
matchValue = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
|
|
@@ -1327,19 +1559,75 @@ export function modulePathForSymbol(checker, packageContext, isQualified, symbol
|
|
|
1327
1559
|
}
|
|
1328
1560
|
switch (matchResult) {
|
|
1329
1561
|
case 0: {
|
|
1330
|
-
filePath =
|
|
1562
|
+
filePath = PackageContext__ModulePath_Z7E147617(packageContext_1, fileName, (declaration == null) ? true : !isPackageGlobal(packageContext_1, declaration), (option_3 = declaration, (option_3 != null) ? topLevelDeclarationName(option_3) : undefined));
|
|
1331
1563
|
break;
|
|
1332
1564
|
}
|
|
1333
1565
|
default:
|
|
1334
1566
|
filePath = empty();
|
|
1335
1567
|
}
|
|
1336
|
-
return append(filePath, (declaration != null) ? ((isQualified ? true : !isEmpty(filePath)) ? ((
|
|
1568
|
+
return append(filePath, (declaration != null) ? ((isQualified ? true : !isEmpty(filePath)) ? ((declaration_4 = declaration, namespaceChain(packageContext, declaration_4))) : empty()) : empty());
|
|
1337
1569
|
}
|
|
1338
1570
|
else {
|
|
1339
1571
|
return empty();
|
|
1340
1572
|
}
|
|
1341
1573
|
}
|
|
1342
1574
|
|
|
1575
|
+
/**
|
|
1576
|
+
* The declaration is in a namespace the landing node does not see, an enclosing one is seen
|
|
1577
|
+
*/
|
|
1578
|
+
export function crossesNamespace(checker, packageContext, symbolOpt, landing) {
|
|
1579
|
+
const isEnclosing = (declared_mut, landed_mut) => {
|
|
1580
|
+
isEnclosing:
|
|
1581
|
+
while (true) {
|
|
1582
|
+
const declared = declared_mut, landed = landed_mut;
|
|
1583
|
+
let matchResult, d_1, declared_2, l_1, landed_2;
|
|
1584
|
+
if (!isEmpty(declared)) {
|
|
1585
|
+
if (!isEmpty(landed)) {
|
|
1586
|
+
if (head(declared) === head(landed)) {
|
|
1587
|
+
matchResult = 1;
|
|
1588
|
+
d_1 = head(declared);
|
|
1589
|
+
declared_2 = tail(declared);
|
|
1590
|
+
l_1 = head(landed);
|
|
1591
|
+
landed_2 = tail(landed);
|
|
1592
|
+
}
|
|
1593
|
+
else {
|
|
1594
|
+
matchResult = 2;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
else {
|
|
1598
|
+
matchResult = 2;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
else {
|
|
1602
|
+
matchResult = 0;
|
|
1603
|
+
}
|
|
1604
|
+
switch (matchResult) {
|
|
1605
|
+
case 0:
|
|
1606
|
+
return true;
|
|
1607
|
+
case 1: {
|
|
1608
|
+
declared_mut = declared_2;
|
|
1609
|
+
landed_mut = landed_2;
|
|
1610
|
+
continue isEnclosing;
|
|
1611
|
+
}
|
|
1612
|
+
default:
|
|
1613
|
+
return false;
|
|
1614
|
+
}
|
|
1615
|
+
break;
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
1618
|
+
let matchValue_1;
|
|
1619
|
+
let option_3;
|
|
1620
|
+
const option_1 = symbolOpt;
|
|
1621
|
+
option_3 = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
|
|
1622
|
+
matchValue_1 = ((option_3 != null) ? mainDeclaration(packageContext, option_3) : undefined);
|
|
1623
|
+
if (matchValue_1 == null) {
|
|
1624
|
+
return false;
|
|
1625
|
+
}
|
|
1626
|
+
else {
|
|
1627
|
+
return !isEnclosing(namespaceChain(packageContext, matchValue_1), namespaceChain(packageContext, landing));
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1343
1631
|
export function Type_StringLiteral_$007CString$007COther$007C(literalType) {
|
|
1344
1632
|
const matchValue = literalType.flags;
|
|
1345
1633
|
if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
|
|
@@ -1367,3 +1655,15 @@ export function Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(literalType
|
|
|
1367
1655
|
}
|
|
1368
1656
|
}
|
|
1369
1657
|
|
|
1658
|
+
/**
|
|
1659
|
+
* `private x` and `#x` are both private, an F# interface has no such member
|
|
1660
|
+
*/
|
|
1661
|
+
export function isPrivateMember(modifiers, name) {
|
|
1662
|
+
if (ModifierUtil_HasModifier_742AC9D(modifiers, 123)) {
|
|
1663
|
+
return true;
|
|
1664
|
+
}
|
|
1665
|
+
else {
|
|
1666
|
+
return name.kind === 81;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { exportedAlias, identifierText, isExportedDeclaration } from "./Utils.js";
|
|
2
|
+
import { exportedAlias, typeNodeBuilderFlags, identifierText, isExportedDeclaration } from "./Utils.js";
|
|
3
3
|
import { ofSeq } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
|
|
4
4
|
import { toList, choose } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
5
5
|
import { Exception, comparePrimitives } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
@@ -50,13 +50,12 @@ export function readVariableStatement(reader, statement) {
|
|
|
50
50
|
}
|
|
51
51
|
switch (matchResult) {
|
|
52
52
|
case 0: {
|
|
53
|
-
const flags = 1 | 16384;
|
|
54
53
|
let typNode;
|
|
55
54
|
let typ;
|
|
56
55
|
const type = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeAtLocation(declaration_1);
|
|
57
56
|
const objectArg = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
58
57
|
typ = objectArg.getBaseTypeOfLiteralType(type);
|
|
59
|
-
typNode = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined,
|
|
58
|
+
typNode = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, undefined, typeNodeBuilderFlags);
|
|
60
59
|
typ_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](typNode);
|
|
61
60
|
break;
|
|
62
61
|
}
|