-
-
Notifications
You must be signed in to change notification settings - Fork 744
Description
Search terms
exports, automatic discovery, package.json, order
Expected Behavior
I run npx typedoc
like the docs say and it should just work.
Actual Behavior
If the types
comes before default
or import
, TypeDoc doesn't find the source files and doesn't generate the docs.
Steps to reproduce the bug
Only have these three files:
package.json
{
"name": "pkg1",
"version": "1.0.0",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"files": ["dist", "src"],
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"typedoc": "^0.28.8",
"typescript": "^5.8.3"
}
}
tsconfig.json
src/index.ts
export function foo(s: string) {
console.log(s)
}
Command:
npx typedoc --skipErrorChecking
Additional Info
I tracked the issue to this line in the typedoc source and it is because it checks them in that specific order. This, combined with the fact that it can't infer the source file from the declaration file given to types
, produces this issue.
Also, I could just reorder all my exports, but the Node.js docs advise that default
should come last. Maybe that doesn't apply to types
. Also, I could set typedoc
first. But that should not be necessary for a path that is available on the next entry. Or at least all of these nuances should be specified in the docs somewhere.
Environment
- Typedoc version: 0.28.8
- TypeScript version: 5.8.3
- Node.js version: 22.16.0
- OS: WSL AlmaLinux 10 on Windows 11