mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(api-extractor): replace type parameters with their actual values on inherited members (#9939)
* refactor: use tokenRange for typeParams in heritage * fix: correct type param replacement
This commit is contained in:
@@ -24,14 +24,12 @@ export function ExcerptText({ model, excerpt }: ExcerptTextProps) {
|
||||
return (
|
||||
<span>
|
||||
{excerpt.spannedTokens.map((token, idx) => {
|
||||
// TODO: Real fix in api-extractor needed
|
||||
const text = token.text.replaceAll('\n', '').replaceAll(/\s{2}$/g, '');
|
||||
if (token.kind === ExcerptTokenKind.Reference) {
|
||||
if (text in BuiltinDocumentationLinks) {
|
||||
const href = BuiltinDocumentationLinks[text as keyof typeof BuiltinDocumentationLinks];
|
||||
if (token.text in BuiltinDocumentationLinks) {
|
||||
const href = BuiltinDocumentationLinks[token.text as keyof typeof BuiltinDocumentationLinks];
|
||||
return (
|
||||
<DocumentationLink key={`${text}-${idx}`} href={href}>
|
||||
{text}
|
||||
<DocumentationLink key={`${token.text}-${idx}`} href={href}>
|
||||
{token.text}
|
||||
</DocumentationLink>
|
||||
);
|
||||
}
|
||||
@@ -45,20 +43,22 @@ export function ExcerptText({ model, excerpt }: ExcerptTextProps) {
|
||||
// dapi-types doesn't have routes for class members
|
||||
// so we can assume this member is for an enum
|
||||
if (meaning === 'member' && path && 'parent' in path) href += `/enum/${path.parent}#${path.component}`;
|
||||
else if (meaning === 'type') href += `#${text}`;
|
||||
else href += `/${meaning}/${text}`;
|
||||
else if (meaning === 'type' || meaning === 'var') href += `#${token.text}`;
|
||||
else href += `/${meaning}/${token.text}`;
|
||||
|
||||
return (
|
||||
<DocumentationLink key={`${text}-${idx}`} href={href}>
|
||||
{text}
|
||||
<DocumentationLink key={`${token.text}-${idx}`} href={href}>
|
||||
{token.text}
|
||||
</DocumentationLink>
|
||||
);
|
||||
}
|
||||
|
||||
const item = model.resolveDeclarationReference(token.canonicalReference!, model).resolvedApiItem;
|
||||
const item = token.canonicalReference
|
||||
? model.resolveDeclarationReference(token.canonicalReference!, model).resolvedApiItem
|
||||
: null;
|
||||
|
||||
if (!item) {
|
||||
return text;
|
||||
return token.text;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -68,12 +68,12 @@ export function ExcerptText({ model, excerpt }: ExcerptTextProps) {
|
||||
key={`${item.displayName}-${item.containerKey}-${idx}`}
|
||||
packageName={item.getAssociatedPackage()?.displayName.replace('@discordjs/', '')}
|
||||
>
|
||||
{text}
|
||||
{token.text}
|
||||
</ItemLink>
|
||||
);
|
||||
}
|
||||
|
||||
return text.replace(/import\("discord-api-types(?:\/v\d+)?"\)\./, '');
|
||||
return token.text.replace(/import\("discord-api-types(?:\/v\d+)?"\)\./, '');
|
||||
})}
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -127,7 +127,7 @@ export function TableOfContentItems({ serializedMembers }: TableOfContentsItemPr
|
||||
<div className="flex flex-row place-items-center gap-4">
|
||||
<VscSymbolEvent size={20} />
|
||||
<div className="p-3 pl-0">
|
||||
<span className="font-semibold">Properties</span>
|
||||
<span className="font-semibold">Events</span>
|
||||
</div>
|
||||
</div>
|
||||
{eventItems}
|
||||
|
||||
Reference in New Issue
Block a user