fix(docs): map exact source aliases in built checks

This commit is contained in:
Tianyi Cui
2026-07-19 19:26:38 +08:00
parent adf4531c71
commit 2c7822ddee
3 changed files with 30 additions and 6 deletions
+11
View File
@@ -0,0 +1,11 @@
/** Map one workspace source alias target to its declaration-build target. */
export function builtDeclarationPath(candidate: string): string {
if (candidate.endsWith('/src')) {
return `${candidate.slice(0, -'/src'.length)}/lib/types`
}
const sourceFile = /^(.*)\/src\/(.+)\.ts$/.exec(candidate)
if (sourceFile?.[1] && sourceFile[2]) {
return `${sourceFile[1]}/lib/types/${sourceFile[2]}.d.ts`
}
throw new Error(`doc-typecheck: cannot map workspace source path to built declarations: ${candidate}`)
}