-
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
Strange behavior in complicated hybrid (esm/cjs) workspaces doc generation #2360
Comments
Other declaration reference styles I tried that also don't work:
In all cases, the link created has a |
I should be able to take a look this weekend - at first glance, looks like your configuration ought to work... |
Sweet. I'm in the process of migrating everything to be esm-by-default (ie, putting That corrects the "defined in" links, which suggests to me that it's either not using the tsconfig I'm telling it to use (seems less likely), or it's looking up the imported dep using require.resolve instead of import resolution. If it's the second one, and it's your code calling |
The only places in TypeDoc where Do I need to do something special to get a working install? On 3bfcd96, with a fresh clone and
I really don't like |
Yeah, run The issue is that I have some "impossible" circular links in order to support the code generated |
Hum
…On Sun, Aug 13, 2023, 2:39 PM isaacs ***@***.***> wrote:
Yeah, run npm run bootstrap.
The issue is that I have some "impossible" circular links in order to
support the code generated Test class without typescript getting confused.
—
Reply to this email directly, view it on GitHub
<#2360 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWMIKFNYINNLIGGC6TFUBYLXVEUQBANCNFSM6AAAAAA3GJIGEY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Turns out this one was just that I forgot to handle qualified names when asking TS to resolve a link.
If TypeScript can't resolve a link, TypeDoc's link resolution works by searching the current "scope" for a reflection matching the name, then going up to the parent scope and checking that one... so taking the TestBase link in Waiter as an example, TypeDoc looks for a member called
The declaration references page should probably have a couple examples of this to make this clearer...
The warnings I'm seeing on 3bfcd960deebf6e2235d5093c998e1d0a8d1b0b3 are printing esm paths, I took a look at the code that prints those declaration warnings, however, and I'm getting that path directly from TypeScript, so however your project was set up before, it was actually using the cjs types. |
The only thing I can think of is that the root
Using the latest master branch of TypeStrong/typedoc, when I use <a href="../modules/_tapjs_core.waiter.html" class="tsd-kind-module">@tapjs/core.test-base.TestBase.waitOn</a> But, using <a href="_tapjs_core.test_base.TestBase.html#waitOn" class="tsd-kind-method">waitOn</a> |
I commented that out, and also experimented with removing the
Sorry for the misdirection! I had forgotten that
|
Closing this as I believe we've worked through most of the issues, and I was never able to reproduce the CJS paths one |
Search terms
Expected Behavior
A bit of context at first. This is a somewhat complicated scenario and frankly, I'm surprised it works at all, so I'm quite impressed with TypeDoc's ability to handle it as well as it does.
Repo: https://github.com/tapjs/tapjs
Docs output: https://tapjs.github.io/tapjs/
The project is a collection of workspace packages, almost all of which are dual-built as ESM and CJS into separate folders, usually
dist/cjs
for commonjs, anddist/mjs
for ESM. Example tsconfig for the esm build:tsconfig/esm.json
tsconfig/build.json
tsconfig.json
The
@tapjs/test
package at./src/test
has a generated implementation class, which extends theTestBase
class defined in@tapjs/core
atsrc/core/src/test-base.ts
. ThatTest
class is in turn extended by theTAP
class in@tapjs/core
, atsrc/core/src/tap.ts
.So there's quite a bit of weird cycling and bootstrap problems, but the end result is dynamic types that work based on configurable plugins, and also are fully statically analyzable, so tsserver can provide the right code hints including all the plugins when writing tests. In order to get it to build properly and get around the bootstrap issues, the
@tapjs/core
and@tapjs/test
keep their builds checked into git, and there's a script that will bootstrap the whole thing from a fresh checkout vianpm run bootstrap
.I'm attempting to generate documentation for all of the workspaces in the project. My root tsconfig.json has a reference to all the workspaces. In each workspace, I have a typedoc.json which I think should be telling it to use the
tsconfig/esm.json
configuration, and only include entry point files that are built as esm.My expectations are that it should effectively document the entire project as if it was ESM-only, and be able to follow the references using entirely
{"type":"module"}
styleimport()
resolution.Actual Behavior
src/core
, it prints these for nearly everything in theTAP
class:The confusing thing is that it's looking in
dist/cjs
, rather thandist/mjs
, even though the tsconfig in effect should be such that this module would only ever load the esm versions.{@link}
references are just not resolved, but only in some cases. For example, in the comment for the definition of theTAP.timeout
method, the link toTestBase#timeout
is not resolved. However, when the class is re-exported as part of the maintap
package, it does resolve.I've tried specifying the links with the full namespaced package and module path, like
{@link @tapjs/core.test-base.TestBase#timeout}
, or without the module name like{@link @tapjs/core.TestBase#timeout}
since that seems to be allowed by the tsdoc specs, but it seems like anything I add just ends up never resolving at all.Steps to reproduce the bug
I've tried creating a more minimal example to reproduce this bug, but I haven't yet been able to. I think it's likely that I'm just finding some edge cases that only happen when you have a combination of cyclic references, hybrid builds, and interlinked workspaces.
Any clues or thoughts would be much appreciated, even if this is just a case that typedoc shouldn't be expected to handle. It would be nice to be able to leverage typedoc as much as possible in tap's API docs, but I'm starting to wonder if the answer might be to just have typedoc output json, and then build up the site using that as a data source somehow.
Environment
The text was updated successfully, but these errors were encountered: