Description
Version 0.20.0-beta.26 introduces an initial attempt at support for "solution style" tsconfig files, aka project references.
How this works
When TypeDoc is given a tsconfig file containing project references, it will create a ts.Program
for each of those references (in addition to the root program). To find each provided entry point, it will look at each program until it finds one that contains that file.
For the most part, this should just work, but if you have a tsconfig which only contains references, you might see unexpected behavior where types are not linked, even if another entry point exports them.
As an example, in the project-references-demo project, npx typedoc zoo/zoo.ts animals/index.ts
will result in documentation where the createZoo
function returns Array<Dog>
, but Dog
is not linked, even though animals/index.ts
exports it. The cause of this is that the root tsconfig.json looks like this:
{
"files": [],
"references": [
{
"path": "./core"
},
{
"path": "./animals"
},
{
"path": "./zoo"
}
]
}
When TypeDoc looks for the entry points, it finds animals/index.ts
in the second listed program before looking at ./zoo
, while the Dog
type used in createZoo
is from the third program. TypeDoc relies on TypeScript to link types, so is unable to resolve types across programs, resulting in a broken link.
There are a couple possible fixes for this:
- Specify the "largest" projects first - if the tsconfig specified
./zoo
first, then TypeDoc would find./animals/index.ts
in the zoo project, and links would work. - Specify the tsconfig only for the root project expected to contain all symbols
npx typedoc --tsconfig zoo/tsconfig.json zoo/zoo.ts animals/index.ts
works as expected. This is usually the better solution since it allows TypeDoc to skip creating any unnecessary projects, making the type checking potentially significantly faster.
Once 0.20 releases, I will put all of this info on the website, but for now... an issue works. Feel free to ask questions below!