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

TypeDoc crashes during link resolver #2496

Closed
andyferris opened this issue Feb 6, 2024 · 7 comments
Closed

TypeDoc crashes during link resolver #2496

andyferris opened this issue Feb 6, 2024 · 7 comments
Labels
bug Functionality does not match expectation

Comments

@andyferris
Copy link

Search terms

LinkResolverPlugin, kindOf, unexpected error

Expected Behavior

My typedoc compiled fine on version 0.25.4, and I expected it to continue to work with 0.25.5.

Actual Behavior

When upgrading typedoc to 0.25.5, it now crashes with the following message:

TypeDoc exiting with unexpected error:
TypeError: Cannot read properties of undefined (reading 'kindOf')
    at /.../node_modules/typedoc/dist/lib/models/types.js:687:63
    at Array.find (<anonymous>)
    at get reflection [as reflection] (/.../node_modules/typedoc/dist/lib/models/types.js:687:43)
    at _classThis.resolveLinks (/.../node_modules/typedoc/dist/lib/converter/plugins/LinkResolverPlugin.js:102:27)
    at _classThis.onResolve (/.../node_modules/typedoc/dist/lib/converter/plugins/LinkResolverPlugin.js:85:18)
    at triggerEvents (/.../node_modules/typedoc/dist/lib/utils/events.js:191:43)
    at triggerApi (/.../node_modules/typedoc/dist/lib/utils/events.js:167:13)
    at eventsApi (/.../node_modules/typedoc/dist/lib/utils/events.js:60:18)
    at _classThis.trigger (/.../node_modules/typedoc/dist/lib/utils/events.js:389:13)
    at _classThis.resolve (/.../node_modules/typedoc/dist/lib/converter/converter.js:335:18)

The same is true for higher versions, like 0.25.7.

Steps to reproduce the bug

Upgrade from version <= 0.25.4 to version >= 0.25.5, and rerun.

In case it is useful, in version <= 0.25.4 we get warnings to the effect of X, defined in /.../example.ts, is referenced by Y but not included in the documentation. Perhaps these are causing an issue in the newer versions of TypeDoc?

I'm sorry I can't provide any more information. Our project is reasonably large (and private). I'm hoping you can identify the issue by figuring out what changed between 0.25.4 and 0.25.5.

Environment

  • Typedoc version: 0.25.5
  • TypeScript version: 5.3.3
  • Node.js version: 20.11.0
  • OS: Ubuntu 22.04
@andyferris andyferris added the bug Functionality does not match expectation label Feb 6, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 7, 2024

This is probably caused by 6370490, specifically 6370490#diff-28b49c0a2528c726938d5b8ad6f68b2b12e25994b5cfb3d55b449447e2fcc09dR255

Going to be difficult to fix the underlying issue with this without a reproduction, as that assert ought to be safe in this context. Just fixing the symptom is easy, but not the right thing to do from my current understanding of that, which is admittedly a month and a bit old now... have been lots of other problems to take up brain space.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 7, 2024

Are you running with any plugins? I looked at the reflection removal code again, and am not seeing anything obvious which would cause this issue..

@Gerrit0 Gerrit0 added the needs reproduction Needs a minimal reproducible case label Feb 9, 2024
@ebekebe
Copy link

ebekebe commented Feb 14, 2024

I get the same error message, with this little code snippet:

const f = () => 1;

/** doc
 */
export type ReturnOfF = ReturnType<typeof f>;

and when I run typedoc --excludeNotDocumented --out docs ./src/test.ts. When I omit --excludeNotDocumented the error goes away.

@andyferris
Copy link
Author

Are you running with any plugins?

We are using typedoc-plugin-markdown and typedoc-plugin-merge-modules. (But the symptom likely is related to what @ebekebe wrote above - we definitely use ReturnType and have undocumented items).

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 18, 2024

I put that snippet into a project and can't seem to reproduce still:

All of these generate docs successfully:

npx typedoc@0.25.5 src/gh2496.ts
npx typedoc@0.25.5 src/gh2496.ts --excludeNotDocumented
npx typedoc@latest src/gh2496.ts --excludeNotDocumented

I also tried exporting/not exporting f and including a link to f in ReturnOfF's documentation comment... none of these resulted in a crash.

@ebekebe
Copy link

ebekebe commented Feb 19, 2024

Apologies, I couldn't reproduce it with my above snippet either. I don't know where the mistake happened, but here is the slightly modified version that does fail:

export function f() {
    return 1
}

/** doc
 */
export type ReturnOfF = ReturnType<typeof f>;

and the command:

❯ npx typedoc@0.25.8 --excludeNotDocumented --out docs src/test.ts
TypeDoc exiting with unexpected error:
TypeError: Cannot read properties of undefined (reading 'kindOf')
...

@Gerrit0 Gerrit0 removed the needs reproduction Needs a minimal reproducible case label Feb 23, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 23, 2024

Thanks! That does it, very confused as to why I used to symbol in removeReflection now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

3 participants