doc-typecheck-paths.ts 521 B

1234567891011
  1. /** Map one workspace source alias target to its declaration-build target. */
  2. export function builtDeclarationPath(candidate: string): string {
  3. if (candidate.endsWith('/src')) {
  4. return `${candidate.slice(0, -'/src'.length)}/lib/types`
  5. }
  6. const sourceFile = /^(.*)\/src\/(.+)\.ts$/.exec(candidate)
  7. if (sourceFile?.[1] && sourceFile[2]) {
  8. return `${sourceFile[1]}/lib/types/${sourceFile[2]}.d.ts`
  9. }
  10. throw new Error(`doc-typecheck: cannot map workspace source path to built declarations: ${candidate}`)
  11. }