Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

very specific entry point path requirements on Windows #2918

Open
electrovir opened this issue Mar 24, 2025 · 1 comment
Open

very specific entry point path requirements on Windows #2918

electrovir opened this issue Mar 24, 2025 · 1 comment

Comments

@electrovir
Copy link

Search terms

  • "Try replacing Windows path separators"
  • "did not match any files"
  • "is not referenced by the 'files' or 'include' option in your tsconfig"

Expected Behavior

Can easily run typedoc on Windows file paths.

Actual Behavior

Most formats simply don't work.

First attempt (Windows path entry point)

typedoc --options typedoc.js with:

// typedoc.js
import {join} from 'node:path';

const indexTsFile = join(import.meta.dirname, 'src', 'index.ts');

export default {
    entryPoints: [
        indexTsFile
    ],
}

errors out with the following:

[warning] The glob ./src/index.ts did not match any files
[info] Try replacing Windows path separators (\) with posix path separators (/)
[error] Unable to find any entry points. See previous warnings
[error] Found 1 errors and 1 warnings

Second attempt (posix path entry point)

So I used node:path/posix instead:

// typedoc.js
import {join} from 'node:path/posix';

const indexTsFile = join(import.meta.dirname, 'src', 'index.ts');

export default {
    entryPoints: [
        indexTsFile
    ],
}

This errors out as well:

[warning] The glob ./src/index.ts did not match any files
[error] Unable to find any entry points. See previous warnings
[error] Found 1 errors and 1 warnings

Though this failure is not really typedoc's fault because this results in a path like C:\Users\electrovir\repo/src/index.ts since import.meta.dirname reports the path in Windows format.

Actual working version

After this I tried dozens of different path construction and conversion techniques. I finally ended up with one that works:

// typedoc.js
import { dirname, join } from 'node:path/posix';
import { fileURLToPath } from 'node:url';

const indexTsFile = join(dirname(fileURLToPath(import.meta.url)), 'src', 'index.ts');

export default {
    entryPoints: [
        indexTsFile
    ],
}

Steps to reproduce the bug

https://github.com/electrovir/typedoc-windows-path-issue/blob/dev/typedoc.js

Environment

  • Typedoc version: 0.28.1
  • TypeScript version: 5.8.2
  • Node.js version: 22.12.0
  • OS: Windows 11
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 25, 2025

Relative locations originating in a config file are considered relative to the config file, I suggest:

export default {
    entryPoints: [
        "src/index.ts"
    ],
}

When printing errors about path separators, typedoc definitely shouldn't normalize the path.

Requiring / path separators is necessary because entryPoints (and some other options) are not arrays of paths, but arrays of globs, and \ is an escape character there. Without this breaking change in 0.28, it isn't possible to properly escape special characters in globs - #2825.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants