@openpkg-ts/sdk 0.43.0 → 0.44.0
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/index.js +33 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3321,6 +3321,9 @@ function serializeClass(node, ctx) {
|
|
|
3321
3321
|
}
|
|
3322
3322
|
}
|
|
3323
3323
|
members.push(...methodsByName.values());
|
|
3324
|
+
if (signatures.length === 0) {
|
|
3325
|
+
signatures.push(...serializeInheritedConstructors(node, ctx));
|
|
3326
|
+
}
|
|
3324
3327
|
const ownMemberNames = new Set;
|
|
3325
3328
|
for (const member of node.members) {
|
|
3326
3329
|
const memberName = getMemberName(member);
|
|
@@ -3462,16 +3465,44 @@ function serializeMethod(node, ctx) {
|
|
|
3462
3465
|
}
|
|
3463
3466
|
function serializeConstructor(node, ctx) {
|
|
3464
3467
|
const { typeChecker: checker } = ctx;
|
|
3465
|
-
const { description } = getJSDocComment(node);
|
|
3466
3468
|
const sig = checker.getSignatureFromDeclaration(node);
|
|
3467
3469
|
if (!sig)
|
|
3468
3470
|
return null;
|
|
3471
|
+
return serializeConstructorSignature(node, sig, ctx);
|
|
3472
|
+
}
|
|
3473
|
+
function serializeConstructorSignature(node, sig, ctx) {
|
|
3474
|
+
const { description, tags, examples } = getJSDocComment(node);
|
|
3469
3475
|
const params = extractParameters(sig, ctx);
|
|
3470
3476
|
return {
|
|
3471
3477
|
description,
|
|
3472
|
-
parameters: params.length > 0 ? params : undefined
|
|
3478
|
+
parameters: params.length > 0 ? params : undefined,
|
|
3479
|
+
...tags.length > 0 ? { tags } : {},
|
|
3480
|
+
...examples.length > 0 ? { examples } : {}
|
|
3473
3481
|
};
|
|
3474
3482
|
}
|
|
3483
|
+
function serializeInheritedConstructors(node, ctx) {
|
|
3484
|
+
const { typeChecker: checker } = ctx;
|
|
3485
|
+
const hasExtends = node.heritageClauses?.some((c) => c.token === ts7.SyntaxKind.ExtendsKeyword);
|
|
3486
|
+
if (!hasExtends)
|
|
3487
|
+
return [];
|
|
3488
|
+
const symbol = checker.getSymbolAtLocation(node.name ?? node);
|
|
3489
|
+
if (!symbol)
|
|
3490
|
+
return [];
|
|
3491
|
+
const staticType = checker.getTypeOfSymbolAtLocation(symbol, node);
|
|
3492
|
+
const ctorSigs = staticType.getConstructSignatures().filter((sig) => {
|
|
3493
|
+
const decl = sig.getDeclaration();
|
|
3494
|
+
return decl !== undefined && ts7.isConstructorDeclaration(decl);
|
|
3495
|
+
});
|
|
3496
|
+
return ctorSigs.map((sig, index) => {
|
|
3497
|
+
const decl = sig.getDeclaration();
|
|
3498
|
+
const owner = ts7.isClassLike(decl.parent) ? decl.parent.name?.text : undefined;
|
|
3499
|
+
return {
|
|
3500
|
+
...serializeConstructorSignature(decl, sig, ctx),
|
|
3501
|
+
...owner ? { inheritedFrom: owner } : {},
|
|
3502
|
+
...ctorSigs.length > 1 ? { overloadIndex: index } : {}
|
|
3503
|
+
};
|
|
3504
|
+
});
|
|
3505
|
+
}
|
|
3475
3506
|
function serializeAccessor(node, ctx) {
|
|
3476
3507
|
const { typeChecker: checker } = ctx;
|
|
3477
3508
|
const name = getMemberName(node);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpkg-ts/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "TypeScript API extraction SDK - programmatic primitives for OpenPkg specs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openpkg",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test": "bun test"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@openpkg-ts/spec": "^0.
|
|
46
|
+
"@openpkg-ts/spec": "^0.44.0",
|
|
47
47
|
"picomatch": "4.0.3",
|
|
48
48
|
"typescript": "^5.0.0"
|
|
49
49
|
},
|