@xlr-lib/xlr-utils 0.1.1-next.4 → 0.1.1-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +3 -505
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +2 -476
- package/dist/index.mjs +2 -476
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
- package/src/__tests__/{ts-helpers.test.ts → xlr-helpers.test.ts} +3 -337
- package/src/index.ts +1 -3
- package/src/type-checks.ts +0 -72
- package/src/validation-helpers.ts +1 -1
- package/src/{ts-helpers.ts → xlr-helpers.ts} +0 -176
- package/types/index.d.ts +1 -3
- package/types/type-checks.d.ts +0 -27
- package/types/xlr-helpers.d.ts +13 -0
- package/src/__tests__/annotations.test.ts +0 -40
- package/src/__tests__/documentation.test.ts +0 -116
- package/src/__tests__/type-check.test.ts +0 -39
- package/src/annotations.ts +0 -237
- package/src/documentation.ts +0 -243
- package/types/annotations.d.ts +0 -7
- package/types/documentation.d.ts +0 -14
- package/types/ts-helpers.d.ts +0 -54
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/index.ts
|
|
@@ -33,224 +23,32 @@ __export(src_exports, {
|
|
|
33
23
|
applyExcludeToNodeType: () => applyExcludeToNodeType,
|
|
34
24
|
applyPartialOrRequiredToNodeType: () => applyPartialOrRequiredToNodeType,
|
|
35
25
|
applyPickOrOmitToNodeType: () => applyPickOrOmitToNodeType,
|
|
36
|
-
buildTemplateRegex: () => buildTemplateRegex,
|
|
37
26
|
computeEffectiveObject: () => computeEffectiveObject,
|
|
38
27
|
computeExtends: () => computeExtends,
|
|
39
|
-
createDocString: () => createDocString,
|
|
40
|
-
createTSDocString: () => createTSDocString,
|
|
41
|
-
decorateNode: () => decorateNode,
|
|
42
28
|
fillInGenerics: () => fillInGenerics,
|
|
43
|
-
getReferencedType: () => getReferencedType,
|
|
44
|
-
getStringLiteralsFromUnion: () => getStringLiteralsFromUnion,
|
|
45
29
|
isAndType: () => isAndType,
|
|
46
30
|
isArrayType: () => isArrayType,
|
|
47
31
|
isBooleanType: () => isBooleanType,
|
|
48
|
-
isExportedDeclaration: () => isExportedDeclaration,
|
|
49
|
-
isExportedModuleDeclaration: () => isExportedModuleDeclaration,
|
|
50
|
-
isGenericInterfaceDeclaration: () => isGenericInterfaceDeclaration,
|
|
51
32
|
isGenericNamedType: () => isGenericNamedType,
|
|
52
33
|
isGenericNodeType: () => isGenericNodeType,
|
|
53
|
-
isGenericTypeDeclaration: () => isGenericTypeDeclaration,
|
|
54
34
|
isNamedType: () => isNamedType,
|
|
55
35
|
isNode: () => isNode,
|
|
56
|
-
isNodeExported: () => isNodeExported,
|
|
57
36
|
isNonNullable: () => isNonNullable,
|
|
58
37
|
isNumberType: () => isNumberType,
|
|
59
38
|
isObjectType: () => isObjectType,
|
|
60
|
-
isOptionalProperty: () => isOptionalProperty,
|
|
61
39
|
isOrType: () => isOrType,
|
|
62
40
|
isPrimitiveTypeNode: () => isPrimitiveTypeNode,
|
|
63
41
|
isRecordType: () => isRecordType,
|
|
64
42
|
isRefType: () => isRefType,
|
|
65
43
|
isStringType: () => isStringType,
|
|
66
|
-
isTopLevelDeclaration: () => isTopLevelDeclaration,
|
|
67
|
-
isTopLevelNode: () => isTopLevelNode,
|
|
68
|
-
isTypeReferenceGeneric: () => isTypeReferenceGeneric,
|
|
69
|
-
isTypeScriptLibType: () => isTypeScriptLibType,
|
|
70
44
|
makePropertyMap: () => makePropertyMap,
|
|
71
45
|
propertyToTuple: () => propertyToTuple,
|
|
72
46
|
resolveConditional: () => resolveConditional,
|
|
73
|
-
resolveReferenceNode: () => resolveReferenceNode
|
|
74
|
-
symbolDisplayToString: () => symbolDisplayToString,
|
|
75
|
-
tsStripOptionalType: () => tsStripOptionalType
|
|
47
|
+
resolveReferenceNode: () => resolveReferenceNode
|
|
76
48
|
});
|
|
77
49
|
module.exports = __toCommonJS(src_exports);
|
|
78
50
|
|
|
79
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/annotations.ts
|
|
80
|
-
var import_typescript = __toESM(require("typescript"));
|
|
81
|
-
function extractDescription(text) {
|
|
82
|
-
if (!text) {
|
|
83
|
-
return {};
|
|
84
|
-
}
|
|
85
|
-
return { description: text };
|
|
86
|
-
}
|
|
87
|
-
function parentIsNonObjectPath(node) {
|
|
88
|
-
return node.parent && (import_typescript.default.isArrayTypeNode(node.parent) || import_typescript.default.isTupleTypeNode(node.parent) || import_typescript.default.isOptionalTypeNode(node.parent) || import_typescript.default.isRestTypeNode(node.parent) || import_typescript.default.isUnionTypeNode(node.parent));
|
|
89
|
-
}
|
|
90
|
-
function recurseTypeChain(node, child) {
|
|
91
|
-
if (!node) {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
if (import_typescript.default.isArrayTypeNode(node) && node.parent && import_typescript.default.isRestTypeNode(node.parent)) {
|
|
95
|
-
return recurseTypeChain(node.parent, node);
|
|
96
|
-
}
|
|
97
|
-
if (import_typescript.default.isRestTypeNode(node)) {
|
|
98
|
-
return recurseTypeChain(node.parent, node);
|
|
99
|
-
}
|
|
100
|
-
if (import_typescript.default.isOptionalTypeNode(node)) {
|
|
101
|
-
return recurseTypeChain(node.parent, node);
|
|
102
|
-
}
|
|
103
|
-
if (import_typescript.default.isUnionTypeNode(node)) {
|
|
104
|
-
return recurseTypeChain(node.parent, node);
|
|
105
|
-
}
|
|
106
|
-
if (import_typescript.default.isParenthesizedTypeNode(node)) {
|
|
107
|
-
return recurseTypeChain(node.parent, node);
|
|
108
|
-
}
|
|
109
|
-
if (import_typescript.default.isTypeLiteralNode(node)) {
|
|
110
|
-
return recurseTypeChain(node.parent, node);
|
|
111
|
-
}
|
|
112
|
-
if (import_typescript.default.isArrayTypeNode(node)) {
|
|
113
|
-
return ["[]", ...recurseTypeChain(node.parent, node)];
|
|
114
|
-
}
|
|
115
|
-
if (import_typescript.default.isTupleTypeNode(node)) {
|
|
116
|
-
const pos = node.elements.indexOf(child);
|
|
117
|
-
return [
|
|
118
|
-
...pos === -1 ? [] : [`${pos}`],
|
|
119
|
-
...recurseTypeChain(node.parent, node)
|
|
120
|
-
];
|
|
121
|
-
}
|
|
122
|
-
if (import_typescript.default.isTypeAliasDeclaration(node) || import_typescript.default.isInterfaceDeclaration(node) || import_typescript.default.isPropertySignature(node)) {
|
|
123
|
-
return [node.name.getText(), ...recurseTypeChain(node.parent, node)];
|
|
124
|
-
}
|
|
125
|
-
if (parentIsNonObjectPath(node)) {
|
|
126
|
-
return recurseTypeChain(node.parent, node);
|
|
127
|
-
}
|
|
128
|
-
return [];
|
|
129
|
-
}
|
|
130
|
-
function extractTitle(node) {
|
|
131
|
-
const typeNames = recurseTypeChain(node, void 0).reverse().join(".");
|
|
132
|
-
if (!typeNames.length) {
|
|
133
|
-
return {};
|
|
134
|
-
}
|
|
135
|
-
return { title: typeNames };
|
|
136
|
-
}
|
|
137
|
-
function stringifyDoc(docString) {
|
|
138
|
-
if (typeof docString === "undefined" || typeof docString === "string") {
|
|
139
|
-
return docString;
|
|
140
|
-
}
|
|
141
|
-
return docString.map(({ text }) => text).join(" ");
|
|
142
|
-
}
|
|
143
|
-
function extractTags(tags) {
|
|
144
|
-
const descriptions = [];
|
|
145
|
-
const examples = [];
|
|
146
|
-
const _default = [];
|
|
147
|
-
const see = [];
|
|
148
|
-
const meta = {};
|
|
149
|
-
const extractSee = (tag) => {
|
|
150
|
-
return `${tag.tagName ? `${tag.tagName?.getText()} ` : ""}${stringifyDoc(tag.comment)?.trim() ?? ""}`;
|
|
151
|
-
};
|
|
152
|
-
tags.forEach((tag) => {
|
|
153
|
-
if (!tag.comment) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
if (tag.tagName.text === "example") {
|
|
157
|
-
examples.push(stringifyDoc(tag.comment)?.trim() ?? "");
|
|
158
|
-
} else if (tag.tagName.text === "default") {
|
|
159
|
-
_default.push(stringifyDoc(tag.comment)?.trim() ?? "");
|
|
160
|
-
} else if (tag.tagName.text === "see") {
|
|
161
|
-
see.push(extractSee(tag));
|
|
162
|
-
} else if (tag.tagName.text === "meta") {
|
|
163
|
-
const [key, value] = tag.comment.toString().split(/:(.*)/);
|
|
164
|
-
meta[key] = value?.trim() ?? "";
|
|
165
|
-
} else {
|
|
166
|
-
const text = stringifyDoc(tag.comment)?.trim() ?? "";
|
|
167
|
-
descriptions.push(`@${tag.tagName.text} ${text}`);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
return {
|
|
171
|
-
...descriptions.length === 0 ? {} : { description: descriptions.join("\n") },
|
|
172
|
-
...examples.length === 0 ? {} : { examples },
|
|
173
|
-
..._default.length === 0 ? {} : { default: _default.join("\n") },
|
|
174
|
-
...see.length === 0 ? {} : { see },
|
|
175
|
-
...meta && Object.keys(meta).length === 0 ? {} : { meta }
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function join(t, separator = "\n") {
|
|
179
|
-
const unique = new Set(t).values();
|
|
180
|
-
return Array.from(unique).filter((s) => s !== void 0).join(separator).trim();
|
|
181
|
-
}
|
|
182
|
-
function mergeAnnotations(nodes) {
|
|
183
|
-
const name = nodes.find((n) => n.name)?.name;
|
|
184
|
-
const title = join(
|
|
185
|
-
nodes.map((n) => n.title),
|
|
186
|
-
", "
|
|
187
|
-
);
|
|
188
|
-
const description = join(nodes.map((n) => n.description));
|
|
189
|
-
const _default = join(nodes.map((n) => n.default));
|
|
190
|
-
const comment = join(nodes.map((n) => n.comment));
|
|
191
|
-
const examples = join(
|
|
192
|
-
nodes.map(
|
|
193
|
-
(n) => Array.isArray(n.examples) ? join(n.examples) : n.examples
|
|
194
|
-
)
|
|
195
|
-
);
|
|
196
|
-
const see = join(
|
|
197
|
-
nodes.map((n) => Array.isArray(n.see) ? join(n.see) : n.see)
|
|
198
|
-
);
|
|
199
|
-
const meta = nodes.find((n) => n.meta)?.meta;
|
|
200
|
-
return {
|
|
201
|
-
...name ? { name } : {},
|
|
202
|
-
...title ? { title } : {},
|
|
203
|
-
...description ? { description } : {},
|
|
204
|
-
...examples ? { examples } : {},
|
|
205
|
-
..._default ? { default: _default } : {},
|
|
206
|
-
...see ? { see } : {},
|
|
207
|
-
...comment ? { comment } : {},
|
|
208
|
-
...meta ? { meta } : {}
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
function decorateNode(node) {
|
|
212
|
-
const { jsDoc } = node;
|
|
213
|
-
const titleAnnotation = extractTitle(node);
|
|
214
|
-
if (jsDoc && jsDoc.length) {
|
|
215
|
-
const first = jsDoc[0];
|
|
216
|
-
return mergeAnnotations([
|
|
217
|
-
extractDescription(stringifyDoc(first.comment)),
|
|
218
|
-
titleAnnotation,
|
|
219
|
-
extractTags(first.tags ?? [])
|
|
220
|
-
]);
|
|
221
|
-
}
|
|
222
|
-
return titleAnnotation;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/ts-helpers.ts
|
|
226
|
-
var import_typescript3 = __toESM(require("typescript"));
|
|
227
|
-
|
|
228
51
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/type-checks.ts
|
|
229
|
-
var import_typescript2 = __toESM(require("typescript"));
|
|
230
|
-
function isOptionalProperty(node) {
|
|
231
|
-
return node.questionToken?.kind === import_typescript2.default.SyntaxKind.QuestionToken;
|
|
232
|
-
}
|
|
233
|
-
function isGenericInterfaceDeclaration(node) {
|
|
234
|
-
const length = node.typeParameters?.length;
|
|
235
|
-
return length ? length > 0 : false;
|
|
236
|
-
}
|
|
237
|
-
function isGenericTypeDeclaration(node) {
|
|
238
|
-
const length = node.typeParameters?.length;
|
|
239
|
-
return length ? length > 0 : false;
|
|
240
|
-
}
|
|
241
|
-
function isTypeReferenceGeneric(node, typeChecker) {
|
|
242
|
-
const symbol = typeChecker.getSymbolAtLocation(node.typeName);
|
|
243
|
-
if (symbol && symbol.declarations) {
|
|
244
|
-
return symbol.declarations[0].kind === import_typescript2.default.SyntaxKind.TypeParameter;
|
|
245
|
-
}
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
function isTopLevelDeclaration(node) {
|
|
249
|
-
return node.kind === import_typescript2.default.SyntaxKind.InterfaceDeclaration || node.kind === import_typescript2.default.SyntaxKind.TypeAliasDeclaration;
|
|
250
|
-
}
|
|
251
|
-
function isTopLevelNode(node) {
|
|
252
|
-
return node.kind === import_typescript2.default.SyntaxKind.InterfaceDeclaration || node.kind === import_typescript2.default.SyntaxKind.TypeAliasDeclaration || node.kind === import_typescript2.default.SyntaxKind.VariableStatement;
|
|
253
|
-
}
|
|
254
52
|
function isGenericNodeType(nt) {
|
|
255
53
|
return nt.genericTokens?.length > 0;
|
|
256
54
|
}
|
|
@@ -432,88 +230,7 @@ function computeEffectiveObject(base, operand, errorOnOverlap = true) {
|
|
|
432
230
|
return newObject;
|
|
433
231
|
}
|
|
434
232
|
|
|
435
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/
|
|
436
|
-
function tsStripOptionalType(node) {
|
|
437
|
-
return import_typescript3.default.isOptionalTypeNode(node) ? node.type : node;
|
|
438
|
-
}
|
|
439
|
-
function isExportedDeclaration(node) {
|
|
440
|
-
const modifiers = import_typescript3.default.canHaveModifiers(node) ? import_typescript3.default.getModifiers(node) : void 0;
|
|
441
|
-
if (modifiers) {
|
|
442
|
-
return modifiers.some((m) => m.kind === import_typescript3.default.SyntaxKind.ExportKeyword);
|
|
443
|
-
}
|
|
444
|
-
return false;
|
|
445
|
-
}
|
|
446
|
-
function isExportedModuleDeclaration(node) {
|
|
447
|
-
return isExportedDeclaration(node) && import_typescript3.default.isModuleDeclaration(node);
|
|
448
|
-
}
|
|
449
|
-
function isNodeExported(node) {
|
|
450
|
-
return (import_typescript3.default.getCombinedModifierFlags(node) & import_typescript3.default.ModifierFlags.Export) !== 0 || !!node.parent && node.parent.kind === import_typescript3.default.SyntaxKind.SourceFile;
|
|
451
|
-
}
|
|
452
|
-
function getReferencedType(node, typeChecker) {
|
|
453
|
-
let symbol = typeChecker.getSymbolAtLocation(node.typeName);
|
|
454
|
-
if (symbol && (symbol.flags & import_typescript3.default.SymbolFlags.Alias) === import_typescript3.default.SymbolFlags.Alias) {
|
|
455
|
-
symbol = typeChecker.getAliasedSymbol(symbol);
|
|
456
|
-
}
|
|
457
|
-
const varDecl = symbol?.declarations?.[0];
|
|
458
|
-
if (varDecl && (import_typescript3.default.isInterfaceDeclaration(varDecl) || import_typescript3.default.isTypeAliasDeclaration(varDecl))) {
|
|
459
|
-
return { declaration: varDecl, exported: isNodeExported(varDecl) };
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
function isTypeScriptLibType(node, typeChecker) {
|
|
463
|
-
let symbol = typeChecker.getSymbolAtLocation(node.typeName);
|
|
464
|
-
if (!symbol) return false;
|
|
465
|
-
if ((symbol.flags & import_typescript3.default.SymbolFlags.Alias) === import_typescript3.default.SymbolFlags.Alias) {
|
|
466
|
-
symbol = typeChecker.getAliasedSymbol(symbol);
|
|
467
|
-
}
|
|
468
|
-
const declarations = symbol.getDeclarations();
|
|
469
|
-
if (!declarations || declarations.length === 0) return false;
|
|
470
|
-
return declarations.some((decl) => {
|
|
471
|
-
const sourceFile = decl.getSourceFile();
|
|
472
|
-
if (!sourceFile) return false;
|
|
473
|
-
const filePath = sourceFile.fileName;
|
|
474
|
-
return filePath.includes("/typescript/lib/") || filePath.includes("\\typescript\\lib\\") || filePath.endsWith(".d.ts") && filePath.includes("lib.");
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
function getStringLiteralsFromUnion(node) {
|
|
478
|
-
if (import_typescript3.default.isUnionTypeNode(node)) {
|
|
479
|
-
return new Set(
|
|
480
|
-
node.types.map((type) => {
|
|
481
|
-
if (import_typescript3.default.isLiteralTypeNode(type) && import_typescript3.default.isStringLiteral(type.literal)) {
|
|
482
|
-
return type.literal.text;
|
|
483
|
-
}
|
|
484
|
-
return "";
|
|
485
|
-
})
|
|
486
|
-
);
|
|
487
|
-
}
|
|
488
|
-
if (import_typescript3.default.isLiteralTypeNode(node) && import_typescript3.default.isStringLiteral(node.literal)) {
|
|
489
|
-
return /* @__PURE__ */ new Set([node.literal.text]);
|
|
490
|
-
}
|
|
491
|
-
return /* @__PURE__ */ new Set();
|
|
492
|
-
}
|
|
493
|
-
function buildTemplateRegex(node, typeChecker) {
|
|
494
|
-
let regex = node.head.text;
|
|
495
|
-
node.templateSpans.forEach((span) => {
|
|
496
|
-
let type = span.type.kind;
|
|
497
|
-
if (import_typescript3.default.isTypeReferenceNode(span.type)) {
|
|
498
|
-
let symbol = typeChecker.getSymbolAtLocation(
|
|
499
|
-
span.type.typeName
|
|
500
|
-
);
|
|
501
|
-
if (symbol && (symbol.flags & import_typescript3.default.SymbolFlags.Alias) === import_typescript3.default.SymbolFlags.Alias) {
|
|
502
|
-
symbol = typeChecker.getAliasedSymbol(symbol);
|
|
503
|
-
}
|
|
504
|
-
type = (symbol?.declarations?.[0]).type.kind;
|
|
505
|
-
}
|
|
506
|
-
if (type === import_typescript3.default.SyntaxKind.StringKeyword) {
|
|
507
|
-
regex += ".*";
|
|
508
|
-
} else if (type === import_typescript3.default.SyntaxKind.NumberKeyword) {
|
|
509
|
-
regex += "[0-9]*";
|
|
510
|
-
} else if (type === import_typescript3.default.SyntaxKind.BooleanKeyword) {
|
|
511
|
-
regex += "true|false";
|
|
512
|
-
}
|
|
513
|
-
regex += span.literal.text;
|
|
514
|
-
});
|
|
515
|
-
return regex;
|
|
516
|
-
}
|
|
233
|
+
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/xlr-helpers.ts
|
|
517
234
|
function fillInGenerics(xlrNode, generics, preferLocalGenerics = false) {
|
|
518
235
|
let localGenerics;
|
|
519
236
|
if (generics) {
|
|
@@ -759,251 +476,32 @@ function applyExcludeToNodeType(baseObject, filters) {
|
|
|
759
476
|
or: remainingMembers
|
|
760
477
|
};
|
|
761
478
|
}
|
|
762
|
-
|
|
763
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/documentation.ts
|
|
764
|
-
var import_typescript4 = __toESM(require("typescript"));
|
|
765
|
-
var { SymbolDisplayPartKind, displayPartsToString } = import_typescript4.default;
|
|
766
|
-
function insertBetweenElements(array, separator) {
|
|
767
|
-
return array.reduce((acc, item, index) => {
|
|
768
|
-
if (index === 0) {
|
|
769
|
-
return [item];
|
|
770
|
-
}
|
|
771
|
-
return [...acc, separator, item];
|
|
772
|
-
}, []);
|
|
773
|
-
}
|
|
774
|
-
function createTSDocString(node) {
|
|
775
|
-
if (node.type === "ref") {
|
|
776
|
-
return [
|
|
777
|
-
{
|
|
778
|
-
text: node.ref,
|
|
779
|
-
kind: SymbolDisplayPartKind.keyword
|
|
780
|
-
}
|
|
781
|
-
];
|
|
782
|
-
}
|
|
783
|
-
if (node.type === "or" || node.type === "and") {
|
|
784
|
-
const items = node.type === "and" ? node.and : node.or;
|
|
785
|
-
return insertBetweenElements(
|
|
786
|
-
items.map((subnode) => createTSDocString(subnode)),
|
|
787
|
-
[
|
|
788
|
-
{
|
|
789
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
790
|
-
text: node.type === "and" ? " & " : " | "
|
|
791
|
-
}
|
|
792
|
-
]
|
|
793
|
-
).flat();
|
|
794
|
-
}
|
|
795
|
-
if (node.type === "function") {
|
|
796
|
-
return [
|
|
797
|
-
{
|
|
798
|
-
kind: SymbolDisplayPartKind.keyword,
|
|
799
|
-
text: "function"
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
kind: SymbolDisplayPartKind.space,
|
|
803
|
-
text: " "
|
|
804
|
-
},
|
|
805
|
-
...node.name ? [{ text: node.name, kind: SymbolDisplayPartKind.methodName }] : [],
|
|
806
|
-
{
|
|
807
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
808
|
-
text: "("
|
|
809
|
-
},
|
|
810
|
-
...insertBetweenElements(
|
|
811
|
-
node.parameters.map((p) => {
|
|
812
|
-
if (p.name) {
|
|
813
|
-
return [
|
|
814
|
-
{
|
|
815
|
-
kind: SymbolDisplayPartKind.parameterName,
|
|
816
|
-
text: p.name
|
|
817
|
-
},
|
|
818
|
-
{
|
|
819
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
820
|
-
text: p.optional ? "?" : ""
|
|
821
|
-
},
|
|
822
|
-
{
|
|
823
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
824
|
-
text: ": "
|
|
825
|
-
},
|
|
826
|
-
...createTSDocString(p.type)
|
|
827
|
-
];
|
|
828
|
-
}
|
|
829
|
-
return createTSDocString(p.type);
|
|
830
|
-
}),
|
|
831
|
-
[
|
|
832
|
-
{
|
|
833
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
834
|
-
text: ", "
|
|
835
|
-
}
|
|
836
|
-
]
|
|
837
|
-
).flat(),
|
|
838
|
-
{
|
|
839
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
840
|
-
text: ")"
|
|
841
|
-
},
|
|
842
|
-
...node.returnType ? [
|
|
843
|
-
{
|
|
844
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
845
|
-
text: ": "
|
|
846
|
-
},
|
|
847
|
-
...createTSDocString(node.returnType)
|
|
848
|
-
] : []
|
|
849
|
-
];
|
|
850
|
-
}
|
|
851
|
-
if (node.type === "tuple") {
|
|
852
|
-
return [
|
|
853
|
-
{
|
|
854
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
855
|
-
text: "["
|
|
856
|
-
},
|
|
857
|
-
...insertBetweenElements(
|
|
858
|
-
node.elementTypes.map((t) => {
|
|
859
|
-
if (t.name) {
|
|
860
|
-
return [
|
|
861
|
-
{
|
|
862
|
-
kind: SymbolDisplayPartKind.propertyName,
|
|
863
|
-
text: t.name
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
867
|
-
text: ": "
|
|
868
|
-
},
|
|
869
|
-
...createTSDocString(t.type)
|
|
870
|
-
];
|
|
871
|
-
}
|
|
872
|
-
return createTSDocString(t.type);
|
|
873
|
-
}),
|
|
874
|
-
[
|
|
875
|
-
{
|
|
876
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
877
|
-
text: ", "
|
|
878
|
-
}
|
|
879
|
-
]
|
|
880
|
-
).flat(),
|
|
881
|
-
{
|
|
882
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
883
|
-
text: "]"
|
|
884
|
-
}
|
|
885
|
-
];
|
|
886
|
-
}
|
|
887
|
-
if (node.type === "array") {
|
|
888
|
-
return [
|
|
889
|
-
{
|
|
890
|
-
kind: SymbolDisplayPartKind.interfaceName,
|
|
891
|
-
text: "Array"
|
|
892
|
-
},
|
|
893
|
-
{
|
|
894
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
895
|
-
text: "<"
|
|
896
|
-
},
|
|
897
|
-
...createTSDocString(node.elementType),
|
|
898
|
-
{
|
|
899
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
900
|
-
text: ">"
|
|
901
|
-
}
|
|
902
|
-
];
|
|
903
|
-
}
|
|
904
|
-
if (node.type === "record") {
|
|
905
|
-
return [
|
|
906
|
-
{
|
|
907
|
-
kind: SymbolDisplayPartKind.interfaceName,
|
|
908
|
-
text: "Record"
|
|
909
|
-
},
|
|
910
|
-
{
|
|
911
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
912
|
-
text: "<"
|
|
913
|
-
},
|
|
914
|
-
...createTSDocString(node.keyType),
|
|
915
|
-
{
|
|
916
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
917
|
-
text: ", "
|
|
918
|
-
},
|
|
919
|
-
...createTSDocString(node.valueType),
|
|
920
|
-
{
|
|
921
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
922
|
-
text: ">"
|
|
923
|
-
}
|
|
924
|
-
];
|
|
925
|
-
}
|
|
926
|
-
if ((node.type === "string" || node.type === "boolean" || node.type === "number") && node.const !== void 0) {
|
|
927
|
-
return [
|
|
928
|
-
{
|
|
929
|
-
kind: SymbolDisplayPartKind.keyword,
|
|
930
|
-
text: typeof node.const === "string" ? `"${node.const}"` : String(node.const)
|
|
931
|
-
}
|
|
932
|
-
];
|
|
933
|
-
}
|
|
934
|
-
if (isPrimitiveTypeNode(node) && node.type !== "null") {
|
|
935
|
-
return [
|
|
936
|
-
{
|
|
937
|
-
kind: SymbolDisplayPartKind.keyword,
|
|
938
|
-
text: node.type
|
|
939
|
-
}
|
|
940
|
-
];
|
|
941
|
-
}
|
|
942
|
-
if (node.type === "object" && node.name) {
|
|
943
|
-
return [
|
|
944
|
-
{
|
|
945
|
-
kind: SymbolDisplayPartKind.interfaceName,
|
|
946
|
-
text: node.name
|
|
947
|
-
}
|
|
948
|
-
];
|
|
949
|
-
}
|
|
950
|
-
return [
|
|
951
|
-
{
|
|
952
|
-
kind: SymbolDisplayPartKind.localName,
|
|
953
|
-
text: node.type
|
|
954
|
-
}
|
|
955
|
-
];
|
|
956
|
-
}
|
|
957
|
-
function symbolDisplayToString(displayParts) {
|
|
958
|
-
return displayPartsToString(displayParts);
|
|
959
|
-
}
|
|
960
|
-
function createDocString(node) {
|
|
961
|
-
return symbolDisplayToString(createTSDocString(node));
|
|
962
|
-
}
|
|
963
479
|
// Annotate the CommonJS export names for ESM import in node:
|
|
964
480
|
0 && (module.exports = {
|
|
965
481
|
applyExcludeToNodeType,
|
|
966
482
|
applyPartialOrRequiredToNodeType,
|
|
967
483
|
applyPickOrOmitToNodeType,
|
|
968
|
-
buildTemplateRegex,
|
|
969
484
|
computeEffectiveObject,
|
|
970
485
|
computeExtends,
|
|
971
|
-
createDocString,
|
|
972
|
-
createTSDocString,
|
|
973
|
-
decorateNode,
|
|
974
486
|
fillInGenerics,
|
|
975
|
-
getReferencedType,
|
|
976
|
-
getStringLiteralsFromUnion,
|
|
977
487
|
isAndType,
|
|
978
488
|
isArrayType,
|
|
979
489
|
isBooleanType,
|
|
980
|
-
isExportedDeclaration,
|
|
981
|
-
isExportedModuleDeclaration,
|
|
982
|
-
isGenericInterfaceDeclaration,
|
|
983
490
|
isGenericNamedType,
|
|
984
491
|
isGenericNodeType,
|
|
985
|
-
isGenericTypeDeclaration,
|
|
986
492
|
isNamedType,
|
|
987
493
|
isNode,
|
|
988
|
-
isNodeExported,
|
|
989
494
|
isNonNullable,
|
|
990
495
|
isNumberType,
|
|
991
496
|
isObjectType,
|
|
992
|
-
isOptionalProperty,
|
|
993
497
|
isOrType,
|
|
994
498
|
isPrimitiveTypeNode,
|
|
995
499
|
isRecordType,
|
|
996
500
|
isRefType,
|
|
997
501
|
isStringType,
|
|
998
|
-
isTopLevelDeclaration,
|
|
999
|
-
isTopLevelNode,
|
|
1000
|
-
isTypeReferenceGeneric,
|
|
1001
|
-
isTypeScriptLibType,
|
|
1002
502
|
makePropertyMap,
|
|
1003
503
|
propertyToTuple,
|
|
1004
504
|
resolveConditional,
|
|
1005
|
-
resolveReferenceNode
|
|
1006
|
-
symbolDisplayToString,
|
|
1007
|
-
tsStripOptionalType
|
|
505
|
+
resolveReferenceNode
|
|
1008
506
|
});
|
|
1009
507
|
//# sourceMappingURL=index.cjs.map
|