@glutinum/cli 1.0.0-beta.2 → 1.0.0-beta.4
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 +404 -424
- 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 +15 -21
- 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 -1343
- 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 +343 -28
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +3619 -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 +664 -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 +460 -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();
|
|
@@ -197,14 +253,29 @@ export function entityNameText(node) {
|
|
|
197
253
|
}
|
|
198
254
|
|
|
199
255
|
/**
|
|
200
|
-
*
|
|
256
|
+
* A node synthesized by `typeToTypeNode` has a negative position, or in TypeScript 6 a
|
|
257
|
+
* position without a source file; the checker throws when given one as enclosing declaration
|
|
201
258
|
*/
|
|
202
|
-
export function
|
|
259
|
+
export function enclosingDeclarationOf(node) {
|
|
203
260
|
if ((node.pos < 0) ? true : Operators_IsNull(node.getSourceFile())) {
|
|
204
261
|
return undefined;
|
|
205
262
|
}
|
|
206
263
|
else {
|
|
207
|
-
return
|
|
264
|
+
return node;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Identity of an anonymous type, a node synthesized by `typeToTypeNode` has none
|
|
270
|
+
*/
|
|
271
|
+
export function typeLiteralId(node) {
|
|
272
|
+
let node_1;
|
|
273
|
+
const option_1 = enclosingDeclarationOf(node);
|
|
274
|
+
if (option_1 != null) {
|
|
275
|
+
return (node_1 = option_1, `${normalizePath(node_1.getSourceFile().fileName)}:${node_1.pos}`);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
return undefined;
|
|
208
279
|
}
|
|
209
280
|
}
|
|
210
281
|
|
|
@@ -495,12 +566,47 @@ export function resolvedBaseTypeArguments(checker, expression) {
|
|
|
495
566
|
}
|
|
496
567
|
}
|
|
497
568
|
|
|
569
|
+
function readExternalBase(reader, clauseType) {
|
|
570
|
+
const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
|
|
571
|
+
if (matchValue == null) {
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
const packageContext = matchValue;
|
|
575
|
+
let option_5;
|
|
576
|
+
let option_3;
|
|
577
|
+
const option = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(clauseType.expression);
|
|
578
|
+
let mapping;
|
|
579
|
+
const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
580
|
+
mapping = ((symbol) => followAlias(checker, symbol));
|
|
581
|
+
const option_1 = option;
|
|
582
|
+
option_3 = ((option_1 != null) ? mapping(option_1) : undefined);
|
|
583
|
+
if (option_3 != null) {
|
|
584
|
+
const symbol_1 = option_3;
|
|
585
|
+
option_5 = symbol_1.declarations;
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
option_5 = undefined;
|
|
589
|
+
}
|
|
590
|
+
if (option_5 != null) {
|
|
591
|
+
iterate((declaration) => {
|
|
592
|
+
const declaration_1 = declaration;
|
|
593
|
+
if (((declaration_1.kind === 265) && !reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.HasRead6C0FD055"](declaration_1)) && (PackageContext__TryFindExternalModulePath_Z721C83C5(packageContext, declaration_1.getSourceFile().fileName) != null)) {
|
|
594
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1);
|
|
595
|
+
}
|
|
596
|
+
}, option_5);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
498
601
|
export function readHeritageClauses(reader, heritageClauses) {
|
|
499
602
|
if (heritageClauses == null) {
|
|
500
603
|
return empty();
|
|
501
604
|
}
|
|
502
605
|
else {
|
|
503
|
-
return collect_1((clause) => map_1((
|
|
606
|
+
return collect_1((clause) => map_1((clauseType) => {
|
|
607
|
+
readExternalBase(reader, clauseType);
|
|
608
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](clauseType);
|
|
609
|
+
}, toList(clause.types)), toList(heritageClauses));
|
|
504
610
|
}
|
|
505
611
|
}
|
|
506
612
|
|
|
@@ -515,11 +621,11 @@ export function isFromEs5Lib(symbolOpt) {
|
|
|
515
621
|
const matchValue = symbol.declarations;
|
|
516
622
|
if (matchValue != null) {
|
|
517
623
|
const declarations = matchValue;
|
|
518
|
-
if ((declarations.length === 0) ? true : Operators_IsNull(
|
|
624
|
+
if ((declarations.length === 0) ? true : Operators_IsNull(item_1(0, declarations).parent)) {
|
|
519
625
|
return false;
|
|
520
626
|
}
|
|
521
|
-
else if (
|
|
522
|
-
const sourceFile =
|
|
627
|
+
else if (item_1(0, declarations).parent.kind === 308) {
|
|
628
|
+
const sourceFile = item_1(0, declarations).parent;
|
|
523
629
|
return sourceFile.fileName.endsWith("/lib.es5.d.ts");
|
|
524
630
|
}
|
|
525
631
|
else {
|
|
@@ -561,7 +667,7 @@ export function isFromEsLib(symbolOpt) {
|
|
|
561
667
|
}
|
|
562
668
|
switch (matchResult) {
|
|
563
669
|
case 0: {
|
|
564
|
-
const fileName = normalizePath(
|
|
670
|
+
const fileName = normalizePath(item_1(0, declarations_1).getSourceFile().fileName);
|
|
565
671
|
return fileName.indexOf("/lib/lib.es") >= 0;
|
|
566
672
|
}
|
|
567
673
|
default:
|
|
@@ -594,7 +700,6 @@ export function resolveAlias(checker, symbol) {
|
|
|
594
700
|
}
|
|
595
701
|
|
|
596
702
|
/**
|
|
597
|
-
* Name of the declaration behind an `import { X as Y }` alias, `None` for a non-renamed symbol
|
|
598
703
|
* `Omit<LabelOption, "rotate">` where `interface LabelOption<T = Params>`: `T` is `Params`
|
|
599
704
|
*/
|
|
600
705
|
export function defaultTypeArguments(reader, typeNode) {
|
|
@@ -662,6 +767,9 @@ export function declaredName(symbol) {
|
|
|
662
767
|
}
|
|
663
768
|
}
|
|
664
769
|
|
|
770
|
+
/**
|
|
771
|
+
* Name of the declaration behind an `import { X as Y }` alias, `None` for a non-renamed symbol
|
|
772
|
+
*/
|
|
665
773
|
export function importedName(checker, symbol) {
|
|
666
774
|
let target, target_1;
|
|
667
775
|
const matchValue = symbol.flags;
|
|
@@ -959,10 +1067,10 @@ export function promotedAmbientModule(sourceFile) {
|
|
|
959
1067
|
}
|
|
960
1068
|
else {
|
|
961
1069
|
const ambientModules = map_1((statement_2) => statement_2, filter(isAmbientModule, statements));
|
|
962
|
-
const
|
|
1070
|
+
const fileName_1 = withoutDeclarationExtension(last(split(normalizePath(sourceFile.fileName), ["/"], undefined, 0)));
|
|
963
1071
|
const namedLikeTheFile = filter((moduleDeclaration_2) => {
|
|
964
1072
|
let name;
|
|
965
|
-
return ((name = removeSurroundingQuotes(moduleDeclaration_2.name.text), name.startsWith("node:") ? substring(name, "node:".length) : name)) ===
|
|
1073
|
+
return ((name = removeSurroundingQuotes(moduleDeclaration_2.name.text), name.startsWith("node:") ? substring(name, "node:".length) : name)) === fileName_1;
|
|
966
1074
|
}, ambientModules);
|
|
967
1075
|
return orElse(orElse(tryFind((moduleDeclaration_1) => {
|
|
968
1076
|
let body;
|
|
@@ -990,6 +1098,23 @@ export function promotedAmbientModule(sourceFile) {
|
|
|
990
1098
|
}
|
|
991
1099
|
}
|
|
992
1100
|
|
|
1101
|
+
/**
|
|
1102
|
+
* The names of the ambient modules the program declares, `node:fs` when declared as such
|
|
1103
|
+
*/
|
|
1104
|
+
export function ambientModuleNames(checker) {
|
|
1105
|
+
return ofSeq(map_2((symbol) => removeSurroundingQuotes(symbol.name), checker.getAmbientModules()), {
|
|
1106
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* The specifier of the ambient module a file is made of, `node:fs` when the program declares
|
|
1112
|
+
* that alias too
|
|
1113
|
+
*/
|
|
1114
|
+
export function ambientModuleSpecifier(ambientModuleNames_1, moduleDeclaration) {
|
|
1115
|
+
return ambientSpecifier(ambientModuleNames_1, removeSurroundingQuotes(moduleDeclaration.name.text));
|
|
1116
|
+
}
|
|
1117
|
+
|
|
993
1118
|
export function isPromotedAmbientModule(declaration) {
|
|
994
1119
|
const parent = declaration.parent;
|
|
995
1120
|
if (!Operators_IsNull(parent) && (parent.kind === 308)) {
|
|
@@ -1062,6 +1187,62 @@ export function isExportedDeclaration(statement, names) {
|
|
|
1062
1187
|
}
|
|
1063
1188
|
}
|
|
1064
1189
|
|
|
1190
|
+
/**
|
|
1191
|
+
* `declare class Client {}; export { Client as default }`
|
|
1192
|
+
*/
|
|
1193
|
+
export function isDefaultInExportList(statement, name) {
|
|
1194
|
+
if (statement.parent.kind === 308) {
|
|
1195
|
+
return exists((other) => {
|
|
1196
|
+
let exportClause;
|
|
1197
|
+
if (other.kind === 279) {
|
|
1198
|
+
const exportDeclaration = other;
|
|
1199
|
+
if (exportDeclaration.moduleSpecifier == null) {
|
|
1200
|
+
const matchValue_1 = exportDeclaration.exportClause;
|
|
1201
|
+
let matchResult, exportClause_1;
|
|
1202
|
+
if (matchValue_1 != null) {
|
|
1203
|
+
if ((exportClause = matchValue_1, exportClause.kind === 280)) {
|
|
1204
|
+
matchResult = 0;
|
|
1205
|
+
exportClause_1 = matchValue_1;
|
|
1206
|
+
}
|
|
1207
|
+
else {
|
|
1208
|
+
matchResult = 1;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
else {
|
|
1212
|
+
matchResult = 1;
|
|
1213
|
+
}
|
|
1214
|
+
switch (matchResult) {
|
|
1215
|
+
case 0:
|
|
1216
|
+
return exists((specifier) => {
|
|
1217
|
+
const matchValue_2 = specifier.propertyName;
|
|
1218
|
+
if (matchValue_2 == null) {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
else if (identifierText(matchValue_2) === name) {
|
|
1222
|
+
return identifierText(specifier.name) === "default";
|
|
1223
|
+
}
|
|
1224
|
+
else {
|
|
1225
|
+
return false;
|
|
1226
|
+
}
|
|
1227
|
+
}, exportClause_1.elements);
|
|
1228
|
+
default:
|
|
1229
|
+
return false;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
else {
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
else {
|
|
1237
|
+
return false;
|
|
1238
|
+
}
|
|
1239
|
+
}, statement.getSourceFile().statements);
|
|
1240
|
+
}
|
|
1241
|
+
else {
|
|
1242
|
+
return false;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1065
1246
|
/**
|
|
1066
1247
|
* `declare class Dispatcher {}; export default Dispatcher` or `export = Dispatcher`
|
|
1067
1248
|
*/
|
|
@@ -1272,10 +1453,42 @@ function namespaceChain(packageContext, declaration) {
|
|
|
1272
1453
|
else {
|
|
1273
1454
|
const moduleDeclaration = node;
|
|
1274
1455
|
const rawName = removeSurroundingQuotes(moduleDeclaration.name.getText());
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1456
|
+
const sourceFile = node.getSourceFile();
|
|
1457
|
+
let ambientModuleOfScript;
|
|
1458
|
+
let matchResult, packageContext_2;
|
|
1459
|
+
if (packageContext != null) {
|
|
1460
|
+
if (isAmbientModuleDeclaration(node) && !(ts.isExternalModule(sourceFile))) {
|
|
1461
|
+
matchResult = 0;
|
|
1462
|
+
packageContext_2 = packageContext;
|
|
1463
|
+
}
|
|
1464
|
+
else {
|
|
1465
|
+
matchResult = 1;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
else {
|
|
1469
|
+
matchResult = 1;
|
|
1470
|
+
}
|
|
1471
|
+
switch (matchResult) {
|
|
1472
|
+
case 0: {
|
|
1473
|
+
const option_1 = PackageContext__TryFindPackage_Z721C83C5(packageContext_2, sourceFile.fileName);
|
|
1474
|
+
ambientModuleOfScript = ((option_1 != null) ? PackageContext__NestedAmbientModuleSegments_32BC514A(packageContext_2, option_1, sourceFile.fileName, rawName) : undefined);
|
|
1475
|
+
break;
|
|
1476
|
+
}
|
|
1477
|
+
default:
|
|
1478
|
+
ambientModuleOfScript = undefined;
|
|
1479
|
+
}
|
|
1480
|
+
if (ambientModuleOfScript == null) {
|
|
1481
|
+
const name = isTopLevelModuleDeclaration(packageContext, node) ? sanitizeTypeName(rawName + "_") : sanitizeTypeName(rawName);
|
|
1482
|
+
node_mut = node.parent;
|
|
1483
|
+
acc_mut = cons(name, acc);
|
|
1484
|
+
continue collect;
|
|
1485
|
+
}
|
|
1486
|
+
else {
|
|
1487
|
+
const segments = ambientModuleOfScript;
|
|
1488
|
+
node_mut = node.parent;
|
|
1489
|
+
acc_mut = append(segments, acc);
|
|
1490
|
+
continue collect;
|
|
1491
|
+
}
|
|
1279
1492
|
}
|
|
1280
1493
|
}
|
|
1281
1494
|
else {
|
|
@@ -1290,11 +1503,45 @@ function namespaceChain(packageContext, declaration) {
|
|
|
1290
1503
|
return collect(declaration.parent, empty());
|
|
1291
1504
|
}
|
|
1292
1505
|
|
|
1506
|
+
function topLevelDeclarationName(declaration) {
|
|
1507
|
+
const top = (node_mut) => {
|
|
1508
|
+
top:
|
|
1509
|
+
while (true) {
|
|
1510
|
+
const node = node_mut;
|
|
1511
|
+
const matchValue = node.parent;
|
|
1512
|
+
if (equals(matchValue, defaultOf())) {
|
|
1513
|
+
return node;
|
|
1514
|
+
}
|
|
1515
|
+
else if (matchValue.kind === 308) {
|
|
1516
|
+
return node;
|
|
1517
|
+
}
|
|
1518
|
+
else {
|
|
1519
|
+
node_mut = matchValue;
|
|
1520
|
+
continue top;
|
|
1521
|
+
}
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
const top_1 = top(declaration);
|
|
1526
|
+
const matchValue_1 = top_1.name;
|
|
1527
|
+
if (equals(matchValue_1, defaultOf())) {
|
|
1528
|
+
if ((top_1.kind === 244) && (declaration.kind === 261)) {
|
|
1529
|
+
return declaration.name.getText();
|
|
1530
|
+
}
|
|
1531
|
+
else {
|
|
1532
|
+
return undefined;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
else {
|
|
1536
|
+
return matchValue_1.getText();
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1293
1540
|
/**
|
|
1294
1541
|
* The F# modules qualifying a declaration from another file: its file modules and its namespaces
|
|
1295
1542
|
*/
|
|
1296
1543
|
export function modulePathForDeclaration(packageContext, declaration) {
|
|
1297
|
-
return append(
|
|
1544
|
+
return append(PackageContext__ModulePath_Z7E147617(packageContext, normalizePath(declaration.getSourceFile().fileName), !isPackageGlobal(packageContext, declaration), topLevelDeclarationName(declaration)), namespaceChain(packageContext, declaration));
|
|
1298
1545
|
}
|
|
1299
1546
|
|
|
1300
1547
|
/**
|
|
@@ -1302,7 +1549,7 @@ export function modulePathForDeclaration(packageContext, declaration) {
|
|
|
1302
1549
|
* in package mode, and the namespaces when the reference is written qualified.
|
|
1303
1550
|
*/
|
|
1304
1551
|
export function modulePathForSymbol(checker, packageContext, isQualified, symbolOpt) {
|
|
1305
|
-
let
|
|
1552
|
+
let option_3, declaration_4;
|
|
1306
1553
|
let matchValue;
|
|
1307
1554
|
const option_1 = symbolOpt;
|
|
1308
1555
|
matchValue = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
|
|
@@ -1327,19 +1574,75 @@ export function modulePathForSymbol(checker, packageContext, isQualified, symbol
|
|
|
1327
1574
|
}
|
|
1328
1575
|
switch (matchResult) {
|
|
1329
1576
|
case 0: {
|
|
1330
|
-
filePath =
|
|
1577
|
+
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
1578
|
break;
|
|
1332
1579
|
}
|
|
1333
1580
|
default:
|
|
1334
1581
|
filePath = empty();
|
|
1335
1582
|
}
|
|
1336
|
-
return append(filePath, (declaration != null) ? ((isQualified ? true : !isEmpty(filePath)) ? ((
|
|
1583
|
+
return append(filePath, (declaration != null) ? ((isQualified ? true : !isEmpty(filePath)) ? ((declaration_4 = declaration, namespaceChain(packageContext, declaration_4))) : empty()) : empty());
|
|
1337
1584
|
}
|
|
1338
1585
|
else {
|
|
1339
1586
|
return empty();
|
|
1340
1587
|
}
|
|
1341
1588
|
}
|
|
1342
1589
|
|
|
1590
|
+
/**
|
|
1591
|
+
* The declaration is in a namespace the landing node does not see, an enclosing one is seen
|
|
1592
|
+
*/
|
|
1593
|
+
export function crossesNamespace(checker, packageContext, symbolOpt, landing) {
|
|
1594
|
+
const isEnclosing = (declared_mut, landed_mut) => {
|
|
1595
|
+
isEnclosing:
|
|
1596
|
+
while (true) {
|
|
1597
|
+
const declared = declared_mut, landed = landed_mut;
|
|
1598
|
+
let matchResult, d_1, declared_2, l_1, landed_2;
|
|
1599
|
+
if (!isEmpty(declared)) {
|
|
1600
|
+
if (!isEmpty(landed)) {
|
|
1601
|
+
if (head(declared) === head(landed)) {
|
|
1602
|
+
matchResult = 1;
|
|
1603
|
+
d_1 = head(declared);
|
|
1604
|
+
declared_2 = tail(declared);
|
|
1605
|
+
l_1 = head(landed);
|
|
1606
|
+
landed_2 = tail(landed);
|
|
1607
|
+
}
|
|
1608
|
+
else {
|
|
1609
|
+
matchResult = 2;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
else {
|
|
1613
|
+
matchResult = 2;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
else {
|
|
1617
|
+
matchResult = 0;
|
|
1618
|
+
}
|
|
1619
|
+
switch (matchResult) {
|
|
1620
|
+
case 0:
|
|
1621
|
+
return true;
|
|
1622
|
+
case 1: {
|
|
1623
|
+
declared_mut = declared_2;
|
|
1624
|
+
landed_mut = landed_2;
|
|
1625
|
+
continue isEnclosing;
|
|
1626
|
+
}
|
|
1627
|
+
default:
|
|
1628
|
+
return false;
|
|
1629
|
+
}
|
|
1630
|
+
break;
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
let matchValue_1;
|
|
1634
|
+
let option_3;
|
|
1635
|
+
const option_1 = symbolOpt;
|
|
1636
|
+
option_3 = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
|
|
1637
|
+
matchValue_1 = ((option_3 != null) ? mainDeclaration(packageContext, option_3) : undefined);
|
|
1638
|
+
if (matchValue_1 == null) {
|
|
1639
|
+
return false;
|
|
1640
|
+
}
|
|
1641
|
+
else {
|
|
1642
|
+
return !isEnclosing(namespaceChain(packageContext, matchValue_1), namespaceChain(packageContext, landing));
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1343
1646
|
export function Type_StringLiteral_$007CString$007COther$007C(literalType) {
|
|
1344
1647
|
const matchValue = literalType.flags;
|
|
1345
1648
|
if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
|
|
@@ -1367,3 +1670,15 @@ export function Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(literalType
|
|
|
1367
1670
|
}
|
|
1368
1671
|
}
|
|
1369
1672
|
|
|
1673
|
+
/**
|
|
1674
|
+
* `private x` and `#x` are both private, an F# interface has no such member
|
|
1675
|
+
*/
|
|
1676
|
+
export function isPrivateMember(modifiers, name) {
|
|
1677
|
+
if (ModifierUtil_HasModifier_742AC9D(modifiers, 123)) {
|
|
1678
|
+
return true;
|
|
1679
|
+
}
|
|
1680
|
+
else {
|
|
1681
|
+
return name.kind === 81;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
@@ -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
|
}
|