-
Notifications
You must be signed in to change notification settings - Fork 712
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
Support for project references #1414
Comments
Thanks to @berickson1 for the example project! This probably still has work to be done - see #1414.
@Gerrit0 , why not using the |
I assume you mean
Having stepped away from it for a day, I think typedoc can avoid creating a program for each reference unless the tsconfig appears to be a solution style tsconfig, which should help some. interface SolutionBuilder<T extends BuilderProgram> {
build(project?: string, cancellationToken?: CancellationToken): ExitStatus;
clean(project?: string): ExitStatus;
buildReferences(project: string, cancellationToken?: CancellationToken): ExitStatus;
cleanReferences(project?: string): ExitStatus;
getNextInvalidatedProject(cancellationToken?: CancellationToken): InvalidatedProject<T> | undefined;
} |
Yes, I meant
We do something similar at Bit for compiling multiple packages. For us, it improved the performance dramatically especially when there are multiple dependencies between the packages. Not sure if it helps for your specific use case though. |
I did a bit of experimenting - and I don't think it offers much benefit for TypeDoc unfortunately. The performance increases you saw were likely because TypeScript was able to mark dependencies as complete and avoid compiling them... but for TypeDoc, even if a project has been compiled, we still need to get its program, and the solution builder won't give it to us without |
jupyterlab recently upgraded typedoc to use 0.20, which has revealed some problems with the implementation here:
I'm not sure of the fixes for either of these yet, but wanted to document them while still fresh in my mind. |
There are now docs for this on the site - https://typedoc.org/guides/project-references/ |
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 thecreateZoo
function returnsArray<Dog>
, butDog
is not linked, even thoughanimals/index.ts
exports it. The cause of this is that the root tsconfig.json looks like this:When TypeDoc looks for the entry points, it finds
animals/index.ts
in the second listed program before looking at./zoo
, while theDog
type used increateZoo
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:
./zoo
first, then TypeDoc would find./animals/index.ts
in the zoo project, and links would work.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!
Cross linking for visibility: #923, #1403, #1364
The text was updated successfully, but these errors were encountered: