@glutinum/cli 0.14.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 +154 -69
- package/dist/Glutinum.Converter/Generate.js +44 -23
- package/dist/Glutinum.Converter/GlueAST.js +122 -74
- package/dist/Glutinum.Converter/Hosting.js +892 -0
- package/dist/Glutinum.Converter/Merge.js +469 -301
- package/dist/Glutinum.Converter/Packages.js +403 -77
- package/dist/Glutinum.Converter/Printer.js +455 -388
- package/dist/Glutinum.Converter/Read.js +366 -104
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +9 -9
- package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
- package/dist/Glutinum.Converter/Reader/Declaration.js +24 -30
- package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
- package/dist/Glutinum.Converter/Reader/Documentation.js +56 -67
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +105 -38
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +52 -55
- package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +28 -16
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +46 -45
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +48 -5
- package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
- package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +55 -7
- package/dist/Glutinum.Converter/Reader/Node.js +23 -26
- package/dist/Glutinum.Converter/Reader/Parameters.js +39 -30
- package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
- package/dist/Glutinum.Converter/Reader/TypeNode.js +410 -1545
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +78 -51
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +116 -71
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +25 -7
- package/dist/Glutinum.Converter/Reader/Types.js +296 -16
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +21 -34
- package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
- package/dist/Glutinum.Converter/Reader/Utils.js +584 -148
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +2971 -6875
- 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 +193 -211
- package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
- package/dist/Glutinum.Converter/Utils/String.js +15 -4
- package/dist/Program.js +107 -232
- package/package.json +4 -3
- package/dist/Glutinum.Converter/TypeScript.js +0 -12
- package/src/Glutinum.Converter/js/bootstrap.js +0 -123
- package/src/Glutinum.Converter/js/host.js +0 -144
- package/src/Glutinum.Converter/js/npm.js +0 -137
- package/src/Glutinum.Converter/js/resolve.js +0 -402
|
@@ -1,22 +1,21 @@
|
|
|
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 { withoutDeclarationExtension, normalizePath } from "../Utils/String.js";
|
|
9
10
|
import { class_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
|
|
10
|
-
import { tryPick, last, toList, tryHead, exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
11
|
-
import {
|
|
12
|
-
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";
|
|
13
|
-
import { item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
14
|
-
import { normalizePath } from "../Utils/String.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__IsExternalLibFile_Z721C83C5, 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 {
|
|
17
|
+
import { substring, split } from "../../fable_modules/fable-library-js.5.17.2/String.js";
|
|
18
18
|
import { sanitizeTypeName, removeSurroundingQuotes } from "../Utils/Naming.js";
|
|
19
|
-
import { substring } from "../../fable_modules/fable-library-js.5.17.2/String.js";
|
|
20
19
|
import { ts } from "@ts-morph/bootstrap";
|
|
21
20
|
import { FSharpChoice$3, FSharpChoice$2 } from "../../fable_modules/fable-library-js.5.17.2/Choice.js";
|
|
22
21
|
|
|
@@ -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);
|
|
@@ -151,7 +205,7 @@ export function tryReadLiteral(checker, expression) {
|
|
|
151
205
|
const text_1 = expression.getText();
|
|
152
206
|
const resolvedType = checker.getTypeAtLocation(expression);
|
|
153
207
|
const matchValue_2 = resolvedType.flags;
|
|
154
|
-
if ($007CHasTypeFlags$007C_$007C(
|
|
208
|
+
if ($007CHasTypeFlags$007C_$007C(2048, matchValue_2) != null) {
|
|
155
209
|
const value = resolvedType.value;
|
|
156
210
|
if (Number.isSafeInteger(value) && !isWrittenAsFloat(text_1)) {
|
|
157
211
|
return new GlueLiteral(/* Int */ 1, [value]);
|
|
@@ -167,6 +221,13 @@ export function tryReadLiteral(checker, expression) {
|
|
|
167
221
|
}
|
|
168
222
|
}
|
|
169
223
|
|
|
224
|
+
/**
|
|
225
|
+
* An `Identifier` and a `StringLiteral` both carry the name in `text`
|
|
226
|
+
*/
|
|
227
|
+
export function moduleExportNameText(name) {
|
|
228
|
+
return name.text;
|
|
229
|
+
}
|
|
230
|
+
|
|
170
231
|
/**
|
|
171
232
|
* Nodes synthesized by <c>typeToTypeNode</c> have no source text
|
|
172
233
|
*/
|
|
@@ -183,7 +244,7 @@ export function identifierText(node) {
|
|
|
183
244
|
* The last name of `ns.Foo`, `Foo` for an identifier
|
|
184
245
|
*/
|
|
185
246
|
export function entityNameText(node) {
|
|
186
|
-
if (node.kind ===
|
|
247
|
+
if (node.kind === 167) {
|
|
187
248
|
return identifierText(node.right);
|
|
188
249
|
}
|
|
189
250
|
else {
|
|
@@ -191,6 +252,33 @@ export function entityNameText(node) {
|
|
|
191
252
|
}
|
|
192
253
|
}
|
|
193
254
|
|
|
255
|
+
/**
|
|
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
|
|
258
|
+
*/
|
|
259
|
+
export function enclosingDeclarationOf(node) {
|
|
260
|
+
if ((node.pos < 0) ? true : Operators_IsNull(node.getSourceFile())) {
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
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;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
194
282
|
/**
|
|
195
283
|
* Identifiers synthesized by <c>typeToTypeNode</c> carry their symbol, they can't be resolved by position
|
|
196
284
|
*/
|
|
@@ -198,10 +286,10 @@ export function symbolAtLocation(checker, node) {
|
|
|
198
286
|
if (!Operators_IsNull(node.symbol)) {
|
|
199
287
|
return node.symbol;
|
|
200
288
|
}
|
|
201
|
-
else if ((node.kind ===
|
|
289
|
+
else if ((node.kind === 167) && !Operators_IsNull(node.right.symbol)) {
|
|
202
290
|
return node.right.symbol;
|
|
203
291
|
}
|
|
204
|
-
else if (((node.kind ===
|
|
292
|
+
else if (((node.kind === 167) && !Operators_IsNull(node.left.symbol)) && ((node.left.symbol.flags & 384) !== 0)) {
|
|
205
293
|
return node.left.symbol;
|
|
206
294
|
}
|
|
207
295
|
else {
|
|
@@ -209,19 +297,28 @@ export function symbolAtLocation(checker, node) {
|
|
|
209
297
|
}
|
|
210
298
|
}
|
|
211
299
|
|
|
300
|
+
function followAlias(checker, symbol) {
|
|
301
|
+
if ((symbol.flags & 2097152) !== 0) {
|
|
302
|
+
return checker.getAliasedSymbol(symbol);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
return symbol;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
212
309
|
export function tryGetFullName(checker, node) {
|
|
213
310
|
if (Operators_IsNull(node.symbol)) {
|
|
214
311
|
const matchValue = checker.getSymbolAtLocation(node);
|
|
215
312
|
if (matchValue != null) {
|
|
216
313
|
const symbol = matchValue;
|
|
217
|
-
return checker.getFullyQualifiedName(symbol);
|
|
314
|
+
return checker.getFullyQualifiedName(followAlias(checker, symbol));
|
|
218
315
|
}
|
|
219
316
|
else {
|
|
220
317
|
return undefined;
|
|
221
318
|
}
|
|
222
319
|
}
|
|
223
320
|
else {
|
|
224
|
-
return checker.getFullyQualifiedName(node.symbol);
|
|
321
|
+
return checker.getFullyQualifiedName(followAlias(checker, node.symbol));
|
|
225
322
|
}
|
|
226
323
|
}
|
|
227
324
|
|
|
@@ -238,7 +335,7 @@ export function ModifierUtil_$reflection() {
|
|
|
238
335
|
return class_type("Glutinum.Converter.Reader.Utils.ModifierUtil", undefined, ModifierUtil);
|
|
239
336
|
}
|
|
240
337
|
|
|
241
|
-
export function
|
|
338
|
+
export function ModifierUtil_GetAccessor_Z1CCFC6BA(modifiers) {
|
|
242
339
|
if (modifiers == null) {
|
|
243
340
|
return GlueAccessor.ReadWrite;
|
|
244
341
|
}
|
|
@@ -250,11 +347,11 @@ export function ModifierUtil_GetAccessor_693AB805(modifiers) {
|
|
|
250
347
|
}
|
|
251
348
|
}
|
|
252
349
|
|
|
253
|
-
export function
|
|
254
|
-
return
|
|
350
|
+
export function ModifierUtil_GetAccessor_2944DA29(modifiers) {
|
|
351
|
+
return ModifierUtil_GetAccessor_Z1CCFC6BA(modifiers);
|
|
255
352
|
}
|
|
256
353
|
|
|
257
|
-
export function
|
|
354
|
+
export function ModifierUtil_HasModifier_1F95D1D2(modifiers, modifier) {
|
|
258
355
|
if (modifiers == null) {
|
|
259
356
|
return false;
|
|
260
357
|
}
|
|
@@ -263,8 +360,8 @@ export function ModifierUtil_HasModifier_Z39CCF48F(modifiers, modifier) {
|
|
|
263
360
|
}
|
|
264
361
|
}
|
|
265
362
|
|
|
266
|
-
export function
|
|
267
|
-
return
|
|
363
|
+
export function ModifierUtil_HasModifier_742AC9D(modifiers, modifier) {
|
|
364
|
+
return ModifierUtil_HasModifier_1F95D1D2(modifiers, modifier);
|
|
268
365
|
}
|
|
269
366
|
|
|
270
367
|
/**
|
|
@@ -275,7 +372,7 @@ export function tryReadKeyOfConstraint(reader, typeParameter) {
|
|
|
275
372
|
const matchValue = typeParameter.constraint;
|
|
276
373
|
let matchResult, constraintNode_1;
|
|
277
374
|
if (matchValue != null) {
|
|
278
|
-
if ((constraintNode = matchValue, constraintNode.kind ===
|
|
375
|
+
if ((constraintNode = matchValue, constraintNode.kind === 199)) {
|
|
279
376
|
matchResult = 0;
|
|
280
377
|
constraintNode_1 = matchValue;
|
|
281
378
|
}
|
|
@@ -289,13 +386,13 @@ export function tryReadKeyOfConstraint(reader, typeParameter) {
|
|
|
289
386
|
switch (matchResult) {
|
|
290
387
|
case 0: {
|
|
291
388
|
const typeOperator = constraintNode_1;
|
|
292
|
-
if ((typeOperator.operator === 143) && (typeOperator.type.kind ===
|
|
389
|
+
if ((typeOperator.operator === 143) && (typeOperator.type.kind === 184)) {
|
|
293
390
|
const typeReferenceNode = typeOperator.type;
|
|
294
391
|
if (defaultArg((option_5 = ((option_3 = ((option_1 = symbolAtLocation(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), typeReferenceNode.typeName), (option_1 != null) ? ((symbol = option_1, (matchValue_1 = symbol.flags, ($007CHasSymbolFlags$007C_$007C(2097152, matchValue_1) != null) ? reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getAliasedSymbol(symbol) : symbol))) : undefined)), (option_3 != null) ? ((symbol_1 = option_3, symbol_1.declarations)) : undefined)), (option_5 != null) ? ((declarations = option_5, ((matchValue_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), (matchValue_3 = tryHead(declarations), (matchValue_2 != null) && ((matchValue_3 != null) && ((declaration = matchValue_3, (packageContext = matchValue_2, PackageContext__TryFindPackage_Z721C83C5(packageContext, declaration.getSourceFile().fileName) == null))))))) && !exists((declaration_1) => {
|
|
295
392
|
const matchValue_5 = declaration_1.kind;
|
|
296
393
|
switch (matchValue_5) {
|
|
297
|
-
case 263:
|
|
298
394
|
case 264:
|
|
395
|
+
case 265:
|
|
299
396
|
return true;
|
|
300
397
|
default:
|
|
301
398
|
return false;
|
|
@@ -322,14 +419,38 @@ export function tryReadKeyOfConstraint(reader, typeParameter) {
|
|
|
322
419
|
}
|
|
323
420
|
}
|
|
324
421
|
|
|
422
|
+
function tryReadReferenceConstraint(reader, typeParameter) {
|
|
423
|
+
let constraintNode;
|
|
424
|
+
const matchValue = typeParameter.constraint;
|
|
425
|
+
let matchResult, constraintNode_1;
|
|
426
|
+
if (matchValue != null) {
|
|
427
|
+
if ((constraintNode = matchValue, constraintNode.kind === 184)) {
|
|
428
|
+
matchResult = 0;
|
|
429
|
+
constraintNode_1 = matchValue;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
matchResult = 1;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
matchResult = 1;
|
|
437
|
+
}
|
|
438
|
+
switch (matchResult) {
|
|
439
|
+
case 0:
|
|
440
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constraintNode_1);
|
|
441
|
+
default:
|
|
442
|
+
return undefined;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
325
446
|
/**
|
|
326
|
-
* The type parameters of a member:
|
|
447
|
+
* The type parameters of a member: a `keyof` or a reference constraint is kept
|
|
327
448
|
*/
|
|
328
449
|
export function readMemberTypeParameters(reader, typeParameters) {
|
|
329
450
|
if (typeParameters != null) {
|
|
330
451
|
return map_1((typeParameter) => {
|
|
331
|
-
let option_1, typNode;
|
|
332
|
-
return new GlueTypeParameter(identifierText(typeParameter.name), tryReadKeyOfConstraint(reader, typeParameter), (option_1 = typeParameter.default, (option_1 != null) ? ((typNode = option_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode))) : undefined));
|
|
452
|
+
let matchValue, option_1, typNode;
|
|
453
|
+
return new GlueTypeParameter(identifierText(typeParameter.name), (matchValue = tryReadKeyOfConstraint(reader, typeParameter), (matchValue == null) ? tryReadReferenceConstraint(reader, typeParameter) : matchValue), (option_1 = typeParameter.default, (option_1 != null) ? ((typNode = option_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode))) : undefined));
|
|
333
454
|
}, toList(typeParameters));
|
|
334
455
|
}
|
|
335
456
|
else {
|
|
@@ -342,7 +463,7 @@ export function readMemberTypeParameters(reader, typeParameters) {
|
|
|
342
463
|
*/
|
|
343
464
|
export function isTupleType(typ) {
|
|
344
465
|
const matchValue = typ.flags;
|
|
345
|
-
if ($007CHasTypeFlags$007C_$007C(
|
|
466
|
+
if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
|
|
346
467
|
const objectFlags = typ.objectFlags;
|
|
347
468
|
const target = typ.target;
|
|
348
469
|
if ((objectFlags & 8) !== 0) {
|
|
@@ -395,7 +516,7 @@ export function resolvedTypeArguments(checker, typ) {
|
|
|
395
516
|
default: {
|
|
396
517
|
const matchValue_2 = typ.flags;
|
|
397
518
|
let matchResult_1;
|
|
398
|
-
if ($007CHasTypeFlags$007C_$007C(
|
|
519
|
+
if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_2) != null) {
|
|
399
520
|
if ((typ.objectFlags & 4) !== 0) {
|
|
400
521
|
matchResult_1 = 0;
|
|
401
522
|
}
|
|
@@ -436,7 +557,7 @@ export function resolvedBaseTypeArguments(checker, expression) {
|
|
|
436
557
|
const matchValue_2 = symbol_1.flags;
|
|
437
558
|
isValue = ($007CHasSymbolFlags$007C_$007C(3, matchValue_2) != null);
|
|
438
559
|
}
|
|
439
|
-
if ((((Operators_IsNull(heritageClause) ? true : (heritageClause.kind !==
|
|
560
|
+
if ((((Operators_IsNull(heritageClause) ? true : (heritageClause.kind !== 299)) ? true : (heritageClause.token !== 96)) ? true : (heritageClause.parent.kind !== 264)) ? true : !isValue) {
|
|
440
561
|
return empty();
|
|
441
562
|
}
|
|
442
563
|
else {
|
|
@@ -445,82 +566,135 @@ export function resolvedBaseTypeArguments(checker, expression) {
|
|
|
445
566
|
}
|
|
446
567
|
}
|
|
447
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
|
+
|
|
448
601
|
export function readHeritageClauses(reader, heritageClauses) {
|
|
449
602
|
if (heritageClauses == null) {
|
|
450
603
|
return empty();
|
|
451
604
|
}
|
|
452
605
|
else {
|
|
453
|
-
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));
|
|
454
610
|
}
|
|
455
611
|
}
|
|
456
612
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
else if (item(0, declarations).parent.kind === 312) {
|
|
472
|
-
const sourceFile = item(0, declarations).parent;
|
|
473
|
-
return sourceFile.fileName.endsWith("lib/lib.es5.d.ts");
|
|
474
|
-
}
|
|
475
|
-
else {
|
|
476
|
-
return false;
|
|
477
|
-
}
|
|
613
|
+
function libDeclaration(symbolOpt) {
|
|
614
|
+
let option_3;
|
|
615
|
+
const option_1 = symbolOpt;
|
|
616
|
+
if (option_1 != null) {
|
|
617
|
+
const symbol = option_1;
|
|
618
|
+
option_3 = symbol.declarations;
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
option_3 = undefined;
|
|
622
|
+
}
|
|
623
|
+
if (option_3 != null) {
|
|
624
|
+
const declarations = option_3;
|
|
625
|
+
if ((declarations.length === 0) ? true : Operators_IsNull(item_1(0, declarations).parent)) {
|
|
626
|
+
return undefined;
|
|
478
627
|
}
|
|
479
628
|
else {
|
|
480
|
-
return
|
|
481
|
-
Equals: (x, y) => (x === y),
|
|
482
|
-
GetHashCode: (x) => (stringHash(x) | 0),
|
|
483
|
-
});
|
|
629
|
+
return item_1(0, declarations);
|
|
484
630
|
}
|
|
485
631
|
}
|
|
486
632
|
else {
|
|
487
|
-
return
|
|
633
|
+
return undefined;
|
|
488
634
|
}
|
|
489
635
|
}
|
|
490
636
|
|
|
491
637
|
/**
|
|
492
|
-
* `
|
|
638
|
+
* `Omit`, `Partial` and the other utility types are declared at the top of `lib.es5.d.ts`
|
|
493
639
|
*/
|
|
494
|
-
export function
|
|
495
|
-
let
|
|
640
|
+
export function isFromEs5Lib(symbolOpt) {
|
|
641
|
+
let declaration, symbol;
|
|
642
|
+
let matchResult, symbol_1;
|
|
496
643
|
if (symbolOpt != null) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
if (matchValue != null) {
|
|
501
|
-
if ((declarations = matchValue, declarations.length > 0)) {
|
|
502
|
-
matchResult = 0;
|
|
503
|
-
declarations_1 = matchValue;
|
|
504
|
-
}
|
|
505
|
-
else {
|
|
506
|
-
matchResult = 1;
|
|
507
|
-
}
|
|
644
|
+
if ((symbol = symbolOpt, symbol.declarations == null)) {
|
|
645
|
+
matchResult = 0;
|
|
646
|
+
symbol_1 = symbolOpt;
|
|
508
647
|
}
|
|
509
648
|
else {
|
|
510
649
|
matchResult = 1;
|
|
511
650
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
matchResult = 1;
|
|
654
|
+
}
|
|
655
|
+
switch (matchResult) {
|
|
656
|
+
case 0:
|
|
657
|
+
return contains(symbol_1.name, ofArray(["Iterable", "IterableIterator"]), {
|
|
658
|
+
Equals: (x, y) => (x === y),
|
|
659
|
+
GetHashCode: (x) => (stringHash(x) | 0),
|
|
660
|
+
});
|
|
661
|
+
default: {
|
|
662
|
+
const matchValue = libDeclaration(symbolOpt);
|
|
663
|
+
let matchResult_1, declaration_1;
|
|
664
|
+
if (matchValue != null) {
|
|
665
|
+
if ((declaration = matchValue, declaration.parent.kind === 308)) {
|
|
666
|
+
matchResult_1 = 0;
|
|
667
|
+
declaration_1 = matchValue;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
matchResult_1 = 1;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
matchResult_1 = 1;
|
|
675
|
+
}
|
|
676
|
+
switch (matchResult_1) {
|
|
677
|
+
case 0:
|
|
678
|
+
return declaration_1.parent.fileName.endsWith("/lib.es5.d.ts");
|
|
679
|
+
default:
|
|
680
|
+
return false;
|
|
516
681
|
}
|
|
517
|
-
default:
|
|
518
|
-
return false;
|
|
519
682
|
}
|
|
520
683
|
}
|
|
521
|
-
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* `PromiseConstructor` of `lib.es2015.promise.d.ts`: a type of the ECMAScript libraries
|
|
688
|
+
*/
|
|
689
|
+
export function isFromEsLib(symbolOpt) {
|
|
690
|
+
const matchValue = libDeclaration(symbolOpt);
|
|
691
|
+
if (matchValue == null) {
|
|
522
692
|
return false;
|
|
523
693
|
}
|
|
694
|
+
else {
|
|
695
|
+
const declaration = matchValue;
|
|
696
|
+
return normalizePath(declaration.getSourceFile().fileName).indexOf("/lib/lib.es") >= 0;
|
|
697
|
+
}
|
|
524
698
|
}
|
|
525
699
|
|
|
526
700
|
export const knownExternalTypeNames = ofSeq(["Date", "Promise", "Array", "ReadonlyArray", "Boolean", "Function", "Error", "RegExp", "Iterable", "IterableIterator", "IteratorObject", "ArrayIterator", "MapIterator", "SetIterator", "StringIterator", "Uint8Array", "Int8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array"], {
|
|
@@ -544,12 +718,24 @@ export function resolveAlias(checker, symbol) {
|
|
|
544
718
|
}
|
|
545
719
|
|
|
546
720
|
/**
|
|
547
|
-
*
|
|
721
|
+
* `type X` beside `export { x as X }` is one symbol flagged both `TypeAlias` and `Alias`
|
|
722
|
+
*/
|
|
723
|
+
export function resolveValueAlias(checker, symbol) {
|
|
724
|
+
const matchValue = symbol.flags;
|
|
725
|
+
if ($007CHasSymbolFlags$007C_$007C(788968, matchValue) != null) {
|
|
726
|
+
return symbol;
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
return resolveAlias(checker, symbol);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
548
734
|
* `Omit<LabelOption, "rotate">` where `interface LabelOption<T = Params>`: `T` is `Params`
|
|
549
735
|
*/
|
|
550
736
|
export function defaultTypeArguments(reader, typeNode) {
|
|
551
737
|
let option_16, option_7, option_5, option_3, option, binder, checker, option_1, symbol_1, declaration;
|
|
552
|
-
if (typeNode.kind !==
|
|
738
|
+
if (typeNode.kind !== 184) {
|
|
553
739
|
return empty_1({
|
|
554
740
|
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
555
741
|
});
|
|
@@ -588,7 +774,7 @@ export function declaredName(symbol) {
|
|
|
588
774
|
option_3 = ((option_1 != null) ? tryHead(option_1) : undefined);
|
|
589
775
|
if (option_3 != null) {
|
|
590
776
|
const declaration = option_3;
|
|
591
|
-
if (declaration.kind ===
|
|
777
|
+
if (declaration.kind === 278) {
|
|
592
778
|
const expression = declaration.expression;
|
|
593
779
|
if (expression.kind === 80) {
|
|
594
780
|
return identifierText(expression);
|
|
@@ -612,42 +798,63 @@ export function declaredName(symbol) {
|
|
|
612
798
|
}
|
|
613
799
|
}
|
|
614
800
|
|
|
801
|
+
/**
|
|
802
|
+
* Name of the declaration behind an `import { X as Y }` alias, `None` for a non-renamed symbol
|
|
803
|
+
*/
|
|
615
804
|
export function importedName(checker, symbol) {
|
|
616
805
|
let target, target_1;
|
|
806
|
+
let isType;
|
|
617
807
|
const matchValue = symbol.flags;
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
target_2 = matchValue_1;
|
|
625
|
-
}
|
|
626
|
-
else if ((target_1 = matchValue_1, (target_1.name !== symbol.name) && (target_1.name !== "export="))) {
|
|
627
|
-
matchResult = 1;
|
|
628
|
-
target_3 = matchValue_1;
|
|
629
|
-
}
|
|
630
|
-
else {
|
|
631
|
-
matchResult = 2;
|
|
632
|
-
}
|
|
808
|
+
isType = ($007CHasSymbolFlags$007C_$007C(788968, matchValue) != null);
|
|
809
|
+
const matchValue_1 = symbol.flags;
|
|
810
|
+
let matchResult;
|
|
811
|
+
if ($007CHasSymbolFlags$007C_$007C(2097152, matchValue_1) != null) {
|
|
812
|
+
if (!isType) {
|
|
813
|
+
matchResult = 0;
|
|
633
814
|
}
|
|
634
815
|
else {
|
|
635
|
-
matchResult =
|
|
636
|
-
}
|
|
637
|
-
switch (matchResult) {
|
|
638
|
-
case 0:
|
|
639
|
-
return declaredName(target_2);
|
|
640
|
-
case 1:
|
|
641
|
-
return target_3.name;
|
|
642
|
-
default:
|
|
643
|
-
return undefined;
|
|
816
|
+
matchResult = 1;
|
|
644
817
|
}
|
|
645
818
|
}
|
|
646
|
-
else if (symbol.name === "default") {
|
|
647
|
-
return declaredName(symbol);
|
|
648
|
-
}
|
|
649
819
|
else {
|
|
650
|
-
|
|
820
|
+
matchResult = 1;
|
|
821
|
+
}
|
|
822
|
+
switch (matchResult) {
|
|
823
|
+
case 0: {
|
|
824
|
+
const matchValue_2 = resolveAlias(checker, symbol);
|
|
825
|
+
let matchResult_1, target_2, target_3;
|
|
826
|
+
if (matchValue_2 != null) {
|
|
827
|
+
if ((target = matchValue_2, target.name === "default")) {
|
|
828
|
+
matchResult_1 = 0;
|
|
829
|
+
target_2 = matchValue_2;
|
|
830
|
+
}
|
|
831
|
+
else if ((target_1 = matchValue_2, (target_1.name !== symbol.name) && (target_1.name !== "export="))) {
|
|
832
|
+
matchResult_1 = 1;
|
|
833
|
+
target_3 = matchValue_2;
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
matchResult_1 = 2;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
else {
|
|
840
|
+
matchResult_1 = 2;
|
|
841
|
+
}
|
|
842
|
+
switch (matchResult_1) {
|
|
843
|
+
case 0:
|
|
844
|
+
return declaredName(target_2);
|
|
845
|
+
case 1:
|
|
846
|
+
return target_3.name;
|
|
847
|
+
default:
|
|
848
|
+
return undefined;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
default:
|
|
852
|
+
if (symbol.name === "default") {
|
|
853
|
+
return declaredName(symbol);
|
|
854
|
+
}
|
|
855
|
+
else {
|
|
856
|
+
return undefined;
|
|
857
|
+
}
|
|
651
858
|
}
|
|
652
859
|
}
|
|
653
860
|
|
|
@@ -658,11 +865,11 @@ function fileOfDeclaration(declaration) {
|
|
|
658
865
|
function isTypeDeclaration(declaration) {
|
|
659
866
|
const matchValue = declaration.kind;
|
|
660
867
|
switch (matchValue) {
|
|
661
|
-
case 263:
|
|
662
868
|
case 264:
|
|
663
869
|
case 265:
|
|
664
870
|
case 266:
|
|
665
871
|
case 267:
|
|
872
|
+
case 268:
|
|
666
873
|
return true;
|
|
667
874
|
default:
|
|
668
875
|
return false;
|
|
@@ -761,7 +968,7 @@ export function otherFileInterfaceDeclarations(packageContext, symbol, declarati
|
|
|
761
968
|
else {
|
|
762
969
|
const package$ = matchValue_2;
|
|
763
970
|
return map_1((other_1) => other_1, filter((other) => {
|
|
764
|
-
if ((other.kind ===
|
|
971
|
+
if ((other.kind === 265) && (fileOfDeclaration(other) !== fileOfDeclaration(declaration))) {
|
|
765
972
|
const matchValue_3 = PackageContext__TryFindPackage_Z721C83C5(packageContext_1, fileOfDeclaration(other));
|
|
766
973
|
if (matchValue_3 == null) {
|
|
767
974
|
return false;
|
|
@@ -788,7 +995,7 @@ export function isMergedInterfaceDeclaration(checker, packageContext, statement)
|
|
|
788
995
|
const matchValue = statement.kind;
|
|
789
996
|
let matchResult;
|
|
790
997
|
if (packageContext != null) {
|
|
791
|
-
if (matchValue ===
|
|
998
|
+
if (matchValue === 265) {
|
|
792
999
|
matchResult = 0;
|
|
793
1000
|
}
|
|
794
1001
|
else {
|
|
@@ -885,7 +1092,7 @@ export function isExternalToPackages(checker, packageContext, symbolOpt) {
|
|
|
885
1092
|
*/
|
|
886
1093
|
export function promotedAmbientModule(sourceFile) {
|
|
887
1094
|
const isAmbientModule = (statement) => {
|
|
888
|
-
if (statement.kind ===
|
|
1095
|
+
if (statement.kind === 268) {
|
|
889
1096
|
return statement.name.kind === 11;
|
|
890
1097
|
}
|
|
891
1098
|
else {
|
|
@@ -896,10 +1103,10 @@ export function promotedAmbientModule(sourceFile) {
|
|
|
896
1103
|
if (exists_1((statement_1) => {
|
|
897
1104
|
const matchValue = statement_1.kind;
|
|
898
1105
|
switch (matchValue) {
|
|
899
|
-
case
|
|
900
|
-
case 271:
|
|
1106
|
+
case 243:
|
|
901
1107
|
case 272:
|
|
902
|
-
case
|
|
1108
|
+
case 273:
|
|
1109
|
+
case 279:
|
|
903
1110
|
return false;
|
|
904
1111
|
default:
|
|
905
1112
|
return !isAmbientModule(statement_1);
|
|
@@ -909,17 +1116,17 @@ export function promotedAmbientModule(sourceFile) {
|
|
|
909
1116
|
}
|
|
910
1117
|
else {
|
|
911
1118
|
const ambientModules = map_1((statement_2) => statement_2, filter(isAmbientModule, statements));
|
|
912
|
-
const
|
|
1119
|
+
const fileName_1 = withoutDeclarationExtension(last(split(normalizePath(sourceFile.fileName), ["/"], undefined, 0)));
|
|
913
1120
|
const namedLikeTheFile = filter((moduleDeclaration_2) => {
|
|
914
1121
|
let name;
|
|
915
|
-
return ((name = removeSurroundingQuotes(moduleDeclaration_2.name.text), name.startsWith("node:") ? substring(name, "node:".length) : name)) ===
|
|
1122
|
+
return ((name = removeSurroundingQuotes(moduleDeclaration_2.name.text), name.startsWith("node:") ? substring(name, "node:".length) : name)) === fileName_1;
|
|
916
1123
|
}, ambientModules);
|
|
917
1124
|
return orElse(orElse(tryFind((moduleDeclaration_1) => {
|
|
918
1125
|
let body;
|
|
919
1126
|
const matchValue_1 = moduleDeclaration_1.body;
|
|
920
1127
|
let matchResult, body_1;
|
|
921
1128
|
if (matchValue_1 != null) {
|
|
922
|
-
if ((body = matchValue_1, body.kind ===
|
|
1129
|
+
if ((body = matchValue_1, body.kind === 269)) {
|
|
923
1130
|
matchResult = 0;
|
|
924
1131
|
body_1 = matchValue_1;
|
|
925
1132
|
}
|
|
@@ -932,7 +1139,7 @@ export function promotedAmbientModule(sourceFile) {
|
|
|
932
1139
|
}
|
|
933
1140
|
switch (matchResult) {
|
|
934
1141
|
case 0:
|
|
935
|
-
return exists((statement_3) => (statement_3.kind !==
|
|
1142
|
+
return exists((statement_3) => (statement_3.kind !== 279), body_1.statements);
|
|
936
1143
|
default:
|
|
937
1144
|
return false;
|
|
938
1145
|
}
|
|
@@ -940,9 +1147,26 @@ export function promotedAmbientModule(sourceFile) {
|
|
|
940
1147
|
}
|
|
941
1148
|
}
|
|
942
1149
|
|
|
1150
|
+
/**
|
|
1151
|
+
* The names of the ambient modules the program declares, `node:fs` when declared as such
|
|
1152
|
+
*/
|
|
1153
|
+
export function ambientModuleNames(checker) {
|
|
1154
|
+
return ofSeq(map_2((symbol) => removeSurroundingQuotes(symbol.name), checker.getAmbientModules()), {
|
|
1155
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* The specifier of the ambient module a file is made of, `node:fs` when the program declares
|
|
1161
|
+
* that alias too
|
|
1162
|
+
*/
|
|
1163
|
+
export function ambientModuleSpecifier(ambientModuleNames_1, moduleDeclaration) {
|
|
1164
|
+
return ambientSpecifier(ambientModuleNames_1, removeSurroundingQuotes(moduleDeclaration.name.text));
|
|
1165
|
+
}
|
|
1166
|
+
|
|
943
1167
|
export function isPromotedAmbientModule(declaration) {
|
|
944
1168
|
const parent = declaration.parent;
|
|
945
|
-
if (!Operators_IsNull(parent) && (parent.kind ===
|
|
1169
|
+
if (!Operators_IsNull(parent) && (parent.kind === 308)) {
|
|
946
1170
|
const matchValue = promotedAmbientModule(parent);
|
|
947
1171
|
if (matchValue == null) {
|
|
948
1172
|
return false;
|
|
@@ -965,17 +1189,17 @@ export function isExportedDeclaration(statement, names) {
|
|
|
965
1189
|
let hasExportModifier;
|
|
966
1190
|
const modifiers = statement.modifiers;
|
|
967
1191
|
hasExportModifier = ((modifiers == null) ? false : exists((modifier) => (modifier.kind === 95), modifiers));
|
|
968
|
-
const isInsideNamespace = statement.parent.kind ===
|
|
969
|
-
const isGlobal = (statement.parent.kind ===
|
|
970
|
-
const isInExportList = (statement.parent.kind ===
|
|
1192
|
+
const isInsideNamespace = statement.parent.kind === 269;
|
|
1193
|
+
const isGlobal = (statement.parent.kind === 308) && !(ts.isExternalModule(statement.getSourceFile()));
|
|
1194
|
+
const isInExportList = (statement.parent.kind === 308) && exists((other) => {
|
|
971
1195
|
let exportClause;
|
|
972
|
-
if (other.kind ===
|
|
1196
|
+
if (other.kind === 279) {
|
|
973
1197
|
const exportDeclaration = other;
|
|
974
1198
|
if (exportDeclaration.moduleSpecifier == null) {
|
|
975
1199
|
const matchValue_1 = exportDeclaration.exportClause;
|
|
976
1200
|
let matchResult, exportClause_1;
|
|
977
1201
|
if (matchValue_1 != null) {
|
|
978
|
-
if ((exportClause = matchValue_1, exportClause.kind ===
|
|
1202
|
+
if ((exportClause = matchValue_1, exportClause.kind === 280)) {
|
|
979
1203
|
matchResult = 0;
|
|
980
1204
|
exportClause_1 = matchValue_1;
|
|
981
1205
|
}
|
|
@@ -1012,13 +1236,69 @@ export function isExportedDeclaration(statement, names) {
|
|
|
1012
1236
|
}
|
|
1013
1237
|
}
|
|
1014
1238
|
|
|
1239
|
+
/**
|
|
1240
|
+
* `declare class Client {}; export { Client as default }`
|
|
1241
|
+
*/
|
|
1242
|
+
export function isDefaultInExportList(statement, name) {
|
|
1243
|
+
if (statement.parent.kind === 308) {
|
|
1244
|
+
return exists((other) => {
|
|
1245
|
+
let exportClause;
|
|
1246
|
+
if (other.kind === 279) {
|
|
1247
|
+
const exportDeclaration = other;
|
|
1248
|
+
if (exportDeclaration.moduleSpecifier == null) {
|
|
1249
|
+
const matchValue_1 = exportDeclaration.exportClause;
|
|
1250
|
+
let matchResult, exportClause_1;
|
|
1251
|
+
if (matchValue_1 != null) {
|
|
1252
|
+
if ((exportClause = matchValue_1, exportClause.kind === 280)) {
|
|
1253
|
+
matchResult = 0;
|
|
1254
|
+
exportClause_1 = matchValue_1;
|
|
1255
|
+
}
|
|
1256
|
+
else {
|
|
1257
|
+
matchResult = 1;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
else {
|
|
1261
|
+
matchResult = 1;
|
|
1262
|
+
}
|
|
1263
|
+
switch (matchResult) {
|
|
1264
|
+
case 0:
|
|
1265
|
+
return exists((specifier) => {
|
|
1266
|
+
const matchValue_2 = specifier.propertyName;
|
|
1267
|
+
if (matchValue_2 == null) {
|
|
1268
|
+
return false;
|
|
1269
|
+
}
|
|
1270
|
+
else if (identifierText(matchValue_2) === name) {
|
|
1271
|
+
return identifierText(specifier.name) === "default";
|
|
1272
|
+
}
|
|
1273
|
+
else {
|
|
1274
|
+
return false;
|
|
1275
|
+
}
|
|
1276
|
+
}, exportClause_1.elements);
|
|
1277
|
+
default:
|
|
1278
|
+
return false;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
else {
|
|
1282
|
+
return false;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
else {
|
|
1286
|
+
return false;
|
|
1287
|
+
}
|
|
1288
|
+
}, statement.getSourceFile().statements);
|
|
1289
|
+
}
|
|
1290
|
+
else {
|
|
1291
|
+
return false;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1015
1295
|
/**
|
|
1016
1296
|
* `declare class Dispatcher {}; export default Dispatcher` or `export = Dispatcher`
|
|
1017
1297
|
*/
|
|
1018
1298
|
export function isExportAssignmentTarget(statement, names) {
|
|
1019
|
-
if (statement.parent.kind ===
|
|
1299
|
+
if (statement.parent.kind === 308) {
|
|
1020
1300
|
return exists((other) => {
|
|
1021
|
-
if (other.kind ===
|
|
1301
|
+
if (other.kind === 278) {
|
|
1022
1302
|
const expression = other.expression;
|
|
1023
1303
|
if (expression.kind === 80) {
|
|
1024
1304
|
return contains_1(identifierText(expression), names);
|
|
@@ -1041,13 +1321,13 @@ export function isExportAssignmentTarget(statement, names) {
|
|
|
1041
1321
|
* `declare const wm: WebMidi; export { wm as WebMidi }`: the name the declaration is exported under
|
|
1042
1322
|
*/
|
|
1043
1323
|
export function exportedAlias(statement, localName) {
|
|
1044
|
-
if (statement.parent.kind !==
|
|
1324
|
+
if (statement.parent.kind !== 308) {
|
|
1045
1325
|
return undefined;
|
|
1046
1326
|
}
|
|
1047
1327
|
else {
|
|
1048
1328
|
return tryPick((other) => {
|
|
1049
1329
|
let exportClause;
|
|
1050
|
-
if (other.kind !==
|
|
1330
|
+
if (other.kind !== 279) {
|
|
1051
1331
|
return undefined;
|
|
1052
1332
|
}
|
|
1053
1333
|
else {
|
|
@@ -1055,7 +1335,7 @@ export function exportedAlias(statement, localName) {
|
|
|
1055
1335
|
const matchValue = exportDeclaration.exportClause;
|
|
1056
1336
|
let matchResult, exportClause_1;
|
|
1057
1337
|
if (matchValue != null) {
|
|
1058
|
-
if ((exportClause = matchValue, (exportDeclaration.moduleSpecifier == null) && (exportClause.kind ===
|
|
1338
|
+
if ((exportClause = matchValue, (exportDeclaration.moduleSpecifier == null) && (exportClause.kind === 280))) {
|
|
1059
1339
|
matchResult = 0;
|
|
1060
1340
|
exportClause_1 = matchValue;
|
|
1061
1341
|
}
|
|
@@ -1085,7 +1365,7 @@ export function exportedAlias(statement, localName) {
|
|
|
1085
1365
|
}
|
|
1086
1366
|
switch (matchResult_1) {
|
|
1087
1367
|
case 0:
|
|
1088
|
-
return specifier.name
|
|
1368
|
+
return moduleExportNameText(specifier.name);
|
|
1089
1369
|
default:
|
|
1090
1370
|
return undefined;
|
|
1091
1371
|
}
|
|
@@ -1111,8 +1391,8 @@ export function isGlobalScriptOfPackage(packageContext, sourceFile) {
|
|
|
1111
1391
|
}
|
|
1112
1392
|
else {
|
|
1113
1393
|
const packageContext_1 = packageContext;
|
|
1114
|
-
if (!ts.isExternalModule(sourceFile) && (promotedAmbientModule(sourceFile) == null)) {
|
|
1115
|
-
return !
|
|
1394
|
+
if ((!(ts.isExternalModule(sourceFile)) && (promotedAmbientModule(sourceFile) == null)) && !PackageContext__IsEntryFile_Z721C83C5(packageContext_1, sourceFile.fileName)) {
|
|
1395
|
+
return !PackageContext__IsExternalLibFile_Z721C83C5(packageContext_1, sourceFile.fileName);
|
|
1116
1396
|
}
|
|
1117
1397
|
else {
|
|
1118
1398
|
return false;
|
|
@@ -1121,7 +1401,7 @@ export function isGlobalScriptOfPackage(packageContext, sourceFile) {
|
|
|
1121
1401
|
}
|
|
1122
1402
|
|
|
1123
1403
|
function isAmbientModuleDeclaration(node) {
|
|
1124
|
-
if (node.kind ===
|
|
1404
|
+
if (node.kind === 268) {
|
|
1125
1405
|
return node.name.kind === 11;
|
|
1126
1406
|
}
|
|
1127
1407
|
else {
|
|
@@ -1139,7 +1419,7 @@ export function isPackageGlobal(packageContext, declaration) {
|
|
|
1139
1419
|
while (true) {
|
|
1140
1420
|
const node = node_mut;
|
|
1141
1421
|
if (!Operators_IsNull(node)) {
|
|
1142
|
-
if ((node.kind ===
|
|
1422
|
+
if ((node.kind === 268) && isGlobalAugmentation(node)) {
|
|
1143
1423
|
return true;
|
|
1144
1424
|
}
|
|
1145
1425
|
else {
|
|
@@ -1192,7 +1472,7 @@ export function isPackageGlobal(packageContext, declaration) {
|
|
|
1192
1472
|
* A module declaration at the top of a file or of the ambient module the file is made of
|
|
1193
1473
|
*/
|
|
1194
1474
|
export function isTopLevelModuleDeclaration(packageContext, node) {
|
|
1195
|
-
if (!Operators_IsNull(node.parent) && ((node.parent.kind ===
|
|
1475
|
+
if (!Operators_IsNull(node.parent) && ((node.parent.kind === 308) ? true : (((node.parent.kind === 269) && (node.parent.parent.kind === 268)) && isPromotedAmbientModule(node.parent.parent)))) {
|
|
1196
1476
|
return !isPackageGlobal(packageContext, node);
|
|
1197
1477
|
}
|
|
1198
1478
|
else {
|
|
@@ -1210,7 +1490,7 @@ function namespaceChain(packageContext, declaration) {
|
|
|
1210
1490
|
}
|
|
1211
1491
|
else {
|
|
1212
1492
|
const matchValue = node.kind;
|
|
1213
|
-
if (matchValue ===
|
|
1493
|
+
if (matchValue === 268) {
|
|
1214
1494
|
if (isPromotedAmbientModule(node)) {
|
|
1215
1495
|
node_mut = node.parent;
|
|
1216
1496
|
acc_mut = acc;
|
|
@@ -1222,10 +1502,42 @@ function namespaceChain(packageContext, declaration) {
|
|
|
1222
1502
|
else {
|
|
1223
1503
|
const moduleDeclaration = node;
|
|
1224
1504
|
const rawName = removeSurroundingQuotes(moduleDeclaration.name.getText());
|
|
1225
|
-
const
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1505
|
+
const sourceFile = node.getSourceFile();
|
|
1506
|
+
let ambientModuleOfScript;
|
|
1507
|
+
let matchResult, packageContext_2;
|
|
1508
|
+
if (packageContext != null) {
|
|
1509
|
+
if (isAmbientModuleDeclaration(node) && !(ts.isExternalModule(sourceFile))) {
|
|
1510
|
+
matchResult = 0;
|
|
1511
|
+
packageContext_2 = packageContext;
|
|
1512
|
+
}
|
|
1513
|
+
else {
|
|
1514
|
+
matchResult = 1;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
else {
|
|
1518
|
+
matchResult = 1;
|
|
1519
|
+
}
|
|
1520
|
+
switch (matchResult) {
|
|
1521
|
+
case 0: {
|
|
1522
|
+
const option_1 = PackageContext__TryFindPackage_Z721C83C5(packageContext_2, sourceFile.fileName);
|
|
1523
|
+
ambientModuleOfScript = ((option_1 != null) ? PackageContext__NestedAmbientModuleSegments_32BC514A(packageContext_2, option_1, sourceFile.fileName, rawName) : undefined);
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
1526
|
+
default:
|
|
1527
|
+
ambientModuleOfScript = undefined;
|
|
1528
|
+
}
|
|
1529
|
+
if (ambientModuleOfScript == null) {
|
|
1530
|
+
const name = isTopLevelModuleDeclaration(packageContext, node) ? sanitizeTypeName(rawName + "_") : sanitizeTypeName(rawName);
|
|
1531
|
+
node_mut = node.parent;
|
|
1532
|
+
acc_mut = cons(name, acc);
|
|
1533
|
+
continue collect;
|
|
1534
|
+
}
|
|
1535
|
+
else {
|
|
1536
|
+
const segments = ambientModuleOfScript;
|
|
1537
|
+
node_mut = node.parent;
|
|
1538
|
+
acc_mut = append(segments, acc);
|
|
1539
|
+
continue collect;
|
|
1540
|
+
}
|
|
1229
1541
|
}
|
|
1230
1542
|
}
|
|
1231
1543
|
else {
|
|
@@ -1240,11 +1552,45 @@ function namespaceChain(packageContext, declaration) {
|
|
|
1240
1552
|
return collect(declaration.parent, empty());
|
|
1241
1553
|
}
|
|
1242
1554
|
|
|
1555
|
+
function topLevelDeclarationName(declaration) {
|
|
1556
|
+
const top = (node_mut) => {
|
|
1557
|
+
top:
|
|
1558
|
+
while (true) {
|
|
1559
|
+
const node = node_mut;
|
|
1560
|
+
const matchValue = node.parent;
|
|
1561
|
+
if (equals(matchValue, defaultOf())) {
|
|
1562
|
+
return node;
|
|
1563
|
+
}
|
|
1564
|
+
else if (matchValue.kind === 308) {
|
|
1565
|
+
return node;
|
|
1566
|
+
}
|
|
1567
|
+
else {
|
|
1568
|
+
node_mut = matchValue;
|
|
1569
|
+
continue top;
|
|
1570
|
+
}
|
|
1571
|
+
break;
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
const top_1 = top(declaration);
|
|
1575
|
+
const matchValue_1 = top_1.name;
|
|
1576
|
+
if (equals(matchValue_1, defaultOf())) {
|
|
1577
|
+
if ((top_1.kind === 244) && (declaration.kind === 261)) {
|
|
1578
|
+
return declaration.name.getText();
|
|
1579
|
+
}
|
|
1580
|
+
else {
|
|
1581
|
+
return undefined;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
else {
|
|
1585
|
+
return matchValue_1.getText();
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1243
1589
|
/**
|
|
1244
1590
|
* The F# modules qualifying a declaration from another file: its file modules and its namespaces
|
|
1245
1591
|
*/
|
|
1246
1592
|
export function modulePathForDeclaration(packageContext, declaration) {
|
|
1247
|
-
return append(
|
|
1593
|
+
return append(PackageContext__ModulePath_Z7E147617(packageContext, normalizePath(declaration.getSourceFile().fileName), !isPackageGlobal(packageContext, declaration), topLevelDeclarationName(declaration)), namespaceChain(packageContext, declaration));
|
|
1248
1594
|
}
|
|
1249
1595
|
|
|
1250
1596
|
/**
|
|
@@ -1252,7 +1598,7 @@ export function modulePathForDeclaration(packageContext, declaration) {
|
|
|
1252
1598
|
* in package mode, and the namespaces when the reference is written qualified.
|
|
1253
1599
|
*/
|
|
1254
1600
|
export function modulePathForSymbol(checker, packageContext, isQualified, symbolOpt) {
|
|
1255
|
-
let
|
|
1601
|
+
let option_3, declaration_4;
|
|
1256
1602
|
let matchValue;
|
|
1257
1603
|
const option_1 = symbolOpt;
|
|
1258
1604
|
matchValue = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
|
|
@@ -1277,22 +1623,78 @@ export function modulePathForSymbol(checker, packageContext, isQualified, symbol
|
|
|
1277
1623
|
}
|
|
1278
1624
|
switch (matchResult) {
|
|
1279
1625
|
case 0: {
|
|
1280
|
-
filePath =
|
|
1626
|
+
filePath = PackageContext__ModulePath_Z7E147617(packageContext_1, fileName, (declaration == null) ? true : !isPackageGlobal(packageContext_1, declaration), (option_3 = declaration, (option_3 != null) ? topLevelDeclarationName(option_3) : undefined));
|
|
1281
1627
|
break;
|
|
1282
1628
|
}
|
|
1283
1629
|
default:
|
|
1284
1630
|
filePath = empty();
|
|
1285
1631
|
}
|
|
1286
|
-
return append(filePath, (declaration != null) ? ((isQualified ? true : !isEmpty(filePath)) ? ((
|
|
1632
|
+
return append(filePath, (declaration != null) ? ((isQualified ? true : !isEmpty(filePath)) ? ((declaration_4 = declaration, namespaceChain(packageContext, declaration_4))) : empty()) : empty());
|
|
1287
1633
|
}
|
|
1288
1634
|
else {
|
|
1289
1635
|
return empty();
|
|
1290
1636
|
}
|
|
1291
1637
|
}
|
|
1292
1638
|
|
|
1639
|
+
/**
|
|
1640
|
+
* The declaration is in a namespace the landing node does not see, an enclosing one is seen
|
|
1641
|
+
*/
|
|
1642
|
+
export function crossesNamespace(checker, packageContext, symbolOpt, landing) {
|
|
1643
|
+
const isEnclosing = (declared_mut, landed_mut) => {
|
|
1644
|
+
isEnclosing:
|
|
1645
|
+
while (true) {
|
|
1646
|
+
const declared = declared_mut, landed = landed_mut;
|
|
1647
|
+
let matchResult, d_1, declared_2, l_1, landed_2;
|
|
1648
|
+
if (!isEmpty(declared)) {
|
|
1649
|
+
if (!isEmpty(landed)) {
|
|
1650
|
+
if (head(declared) === head(landed)) {
|
|
1651
|
+
matchResult = 1;
|
|
1652
|
+
d_1 = head(declared);
|
|
1653
|
+
declared_2 = tail(declared);
|
|
1654
|
+
l_1 = head(landed);
|
|
1655
|
+
landed_2 = tail(landed);
|
|
1656
|
+
}
|
|
1657
|
+
else {
|
|
1658
|
+
matchResult = 2;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
else {
|
|
1662
|
+
matchResult = 2;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
else {
|
|
1666
|
+
matchResult = 0;
|
|
1667
|
+
}
|
|
1668
|
+
switch (matchResult) {
|
|
1669
|
+
case 0:
|
|
1670
|
+
return true;
|
|
1671
|
+
case 1: {
|
|
1672
|
+
declared_mut = declared_2;
|
|
1673
|
+
landed_mut = landed_2;
|
|
1674
|
+
continue isEnclosing;
|
|
1675
|
+
}
|
|
1676
|
+
default:
|
|
1677
|
+
return false;
|
|
1678
|
+
}
|
|
1679
|
+
break;
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
let matchValue_1;
|
|
1683
|
+
let option_3;
|
|
1684
|
+
const option_1 = symbolOpt;
|
|
1685
|
+
option_3 = ((option_1 != null) ? resolveAlias(checker, option_1) : undefined);
|
|
1686
|
+
matchValue_1 = ((option_3 != null) ? mainDeclaration(packageContext, option_3) : undefined);
|
|
1687
|
+
if (matchValue_1 == null) {
|
|
1688
|
+
return false;
|
|
1689
|
+
}
|
|
1690
|
+
else {
|
|
1691
|
+
return !isEnclosing(namespaceChain(packageContext, matchValue_1), namespaceChain(packageContext, landing));
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1293
1695
|
export function Type_StringLiteral_$007CString$007COther$007C(literalType) {
|
|
1294
1696
|
const matchValue = literalType.flags;
|
|
1295
|
-
if ($007CHasTypeFlags$007C_$007C(
|
|
1697
|
+
if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
|
|
1296
1698
|
const literalType_1 = literalType;
|
|
1297
1699
|
return new FSharpChoice$2(/* Choice1Of2 */ 0, [literalType_1.value]);
|
|
1298
1700
|
}
|
|
@@ -1303,7 +1705,7 @@ export function Type_StringLiteral_$007CString$007COther$007C(literalType) {
|
|
|
1303
1705
|
|
|
1304
1706
|
export function Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(literalType) {
|
|
1305
1707
|
const matchValue = literalType.flags;
|
|
1306
|
-
if ($007CHasTypeFlags$007C_$007C(
|
|
1708
|
+
if ($007CHasTypeFlags$007C_$007C(2048, matchValue) != null) {
|
|
1307
1709
|
const literalType_1 = literalType;
|
|
1308
1710
|
if (Number.isSafeInteger(literalType_1.value)) {
|
|
1309
1711
|
return new FSharpChoice$3(/* Choice1Of3 */ 0, [literalType_1.value]);
|
|
@@ -1317,3 +1719,37 @@ export function Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(literalType
|
|
|
1317
1719
|
}
|
|
1318
1720
|
}
|
|
1319
1721
|
|
|
1722
|
+
/**
|
|
1723
|
+
* `private x` and `#x` are both private, an F# interface has no such member
|
|
1724
|
+
*/
|
|
1725
|
+
export function isPrivateMember(modifiers, name) {
|
|
1726
|
+
if (ModifierUtil_HasModifier_742AC9D(modifiers, 123)) {
|
|
1727
|
+
return true;
|
|
1728
|
+
}
|
|
1729
|
+
else {
|
|
1730
|
+
return name.kind === 81;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
/**
|
|
1735
|
+
* The node a reference lands at, the reference itself unless members are read for another declaration
|
|
1736
|
+
*/
|
|
1737
|
+
export function landingOf(reader, node) {
|
|
1738
|
+
if (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing.length === 0) {
|
|
1739
|
+
return node;
|
|
1740
|
+
}
|
|
1741
|
+
else {
|
|
1742
|
+
return item_1(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing.length - 1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().Landing);
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
export function isLibraryName(reader, name) {
|
|
1747
|
+
const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
|
|
1748
|
+
if (matchValue == null) {
|
|
1749
|
+
return false;
|
|
1750
|
+
}
|
|
1751
|
+
else {
|
|
1752
|
+
return matchValue.IsLibraryName(name);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
|