fix: link tag comment with no url (#94)

This commit is contained in:
HiDeoo
2025-11-27 12:13:30 +01:00
committed by GitHub
parent a43375082b
commit e848c07cff
4 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'starlight-typedoc': patch
---
Fixes a potential error when rendering link tags in comments that reference reflections without URLs.

View File

@@ -11,3 +11,11 @@ export interface Thing {
}
export type Things = Thing[]
export type ThingWithBazAndQuux = Thing & {
baz: string
/**
* @see {@link ThingWithBazAndQuux.baz}
*/
quux: number[]
}

View File

@@ -91,6 +91,11 @@ class StarlightTypeDocThemeRenderContext extends MarkdownThemeContext {
(part.tag === '@link' || part.tag === '@linkcode' || part.tag === '@linkplain') &&
part.target instanceof Reflection
) {
if (!this.router.hasUrl(part.target)) {
const { target, ...rest } = part
return rest
}
return {
...part,
target: this.urlTo(part.target),

View File

@@ -58,7 +58,7 @@ test('should generate the proper items for for a single entry point', async ({ d
},
{
label: 'Type Aliases',
items: [{ name: 'Things' }],
items: [{ name: 'Things' }, { name: 'ThingWithBazAndQuux' }],
collapsed: true,
},
{