TypeStrong / typedoc

Documentation generator for TypeScript projects.
https://typedoc.org
Apache License 2.0
7.71k stars 698 forks source link

TypeDoc error: ts.isIdentifierOrPrivateIdentifier is not a function #1240

Closed Alon-L closed 4 years ago

Alon-L commented 4 years ago

Expected Behavior

TypeDoc should generate new documentation for the files in the src directory.

Actual Behavior

TypeDoc throws an error saying:

E:\Coding\nodejs\bot-generator>typedoc --out docs src

Using TypeScript 3.7.4 from E:\Coding\nodejs\bot-generator\node_modules\typescript\lib
E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\converter\context.js:194
    return node['name'] && (ts.isIdentifierOrPrivateIdentifier(node['name']) ||
                               ^

TypeError: ts.isIdentifierOrPrivateIdentifier is not a function
    at isNamedNode (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\converter\context.
js:194:32)
    at Context.getSymbolAtLocation (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\co
nverter\context.js:47:24)
    at Object.createDeclaration (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\conve
rter\factories\declaration.js:61:32)
    at ClassConverter.convert (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\convert
er\nodes\class.js:28:34)
    at Converter.convertNode (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\converte
r\converter.js:116:53)
    at E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\converter\nodes\block.js:58:32
    at Array.forEach (<anonymous>)
    at BlockConverter.convertStatements (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\l
ib\converter\nodes\block.js:56:29)
    at E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\converter\nodes\block.js:43:26
    at Context.withScope (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\converter\co
ntext.js:108:9)

Steps to reproduce the bug

Environment

Gerrit0 commented 4 years ago

TypeScript 3.7.4

This is your issue. You ignored the warning about incompatible peer dependencies. You'll need to use an older version of TypeDoc or install a newer version of TypeScript for your project.

warning " > typedoc@0.17.1" has incorrect peer dependency "typescript@>=3.8.3".

Alon-L commented 4 years ago

Okay I updated to the latest typescript version and now I'm getting this error:

E:\Coding\nodejs\bot-generator>typedoc --out docs src

Using TypeScript 3.8.3 from E:\Coding\nodejs\bot-generator\node_modules\typescript\lib
Rendering [----------------------------------------] 0%E:\Coding\nodejs\bot-generator\node_modules\
marked\src\marked.js:111
    throw e;
    ^

TypeError: this.renderer.html is not a function
Please report this to https://github.com/markedjs/marked.
    at InlineLexer.output (E:\Coding\nodejs\bot-generator\node_modules\marked\src\InlineLexer.js:85
:30)
    at Parser.tok (E:\Coding\nodejs\bot-generator\node_modules\marked\src\Parser.js:97:36)
    at Parser.parse (E:\Coding\nodejs\bot-generator\node_modules\marked\src\Parser.js:47:19)
    at Function.parse (E:\Coding\nodejs\bot-generator\node_modules\marked\src\Parser.js:30:19)
    at marked (E:\Coding\nodejs\bot-generator\node_modules\marked\src\marked.js:103:19)
    at MarkedPlugin.onParseMarkdown (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\o
utput\plugins\MarkedPlugin.js:115:28)
    at E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\utils\events.js:259:33
    at triggerApi (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\utils\events.js:110
:13)
    at Renderer.trigger (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\utils\events.
js:252:13)
    at MarkedPlugin.parseMarkdown (E:\Coding\nodejs\bot-generator\node_modules\typedoc\dist\lib\out
put\plugins\MarkedPlugin.js:87:20)
Gerrit0 commented 4 years ago

Looks like Marked broke in 0.8.1 - https://github.com/markedjs/marked/issues/1621 and since it was a patch version it was automatically pulled in.

Do you have a HTML comment in a heading somewhere? Removing that should fix this until Marked publishes a fix.

Alon-L commented 4 years ago

I couldn't find any HTML comments. I searched for characters such as - and # but I can't find anything that resembles markdown or HTML.

Edit: Is there anything I'm missing?

Gerrit0 commented 4 years ago

Hard to say, TypeDoc also reads your README.md file, so if that has HTML in it it might break. I'll publish 0.17.2 shortly pinning marked to 0.8.0 until they fix this issue.

Alon-L commented 4 years ago

After removing all content from README.md it suddenly works. Thank you for your support.

Gerrit0 commented 4 years ago

0.17.2 published, if you upgrade to that your original readme should work :)

Alon-L commented 4 years ago

Awesome, problem fixed. Thanks!

ricardobeat commented 4 years ago

You ignored the warning about incompatible peer dependencies.

@Gerrit0 not necessarily user error. There doesn't seem to be a warning for the peer deps when installing:

✭ yarn add -D typedoc
yarn add v1.16.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning " > mini-css-extract-plugin@0.9.0" has unmet peer dependency "webpack@^4.4.0".
warning " > react-loadable-ssr-addon@0.2.0" has unmet peer dependency "webpack@>=4.41.1".
warning "react-pose > popmotion-pose > pose-core > rollup-plugin-typescript2@0.25.2" has unmet peer dependency "rollup@>=1.26.3".
warning " > use-react-router@1.0.7" has unmet peer dependency "react-router@^5.0.0".
warning " > copy-webpack-plugin@5.0.5" has unmet peer dependency "webpack@^4.0.0".
warning " > jest-svg-transformer@1.0.0" has unmet peer dependency "jest@>22".
warning " > raw-loader@3.1.0" has unmet peer dependency "webpack@^4.3.0".
warning " > ts-jest@24.1.0" has unmet peer dependency "jest@>=24 <25".
warning " > workbox-webpack-plugin@4.3.1" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
[4/4] 🔨  Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ typedoc@0.17.7
info All dependencies
└─ typedoc@0.17.7
✨  Done in 12.59s.

Yet it still fails:

✭ yarn typedoc --out api-docs src
yarn run v1.16.0
$ ./frontend/node_modules/.bin/typedoc --out api-docs src

Using TypeScript 3.7.5 from ./frontend/node_modules/typescript/lib
./frontend/node_modules/typedoc/dist/lib/converter/context.js:194
    return node['name'] && (ts.isIdentifierOrPrivateIdentifier(node['name']) ||
                               ^

TypeError: ts.isIdentifierOrPrivateIdentifier is not a function
...

When I add a specific version, or re-install, then it warns:

✭ yarn add -D typedoc@0.17.1
yarn add v1.16.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning " > mini-css-extract-plugin@0.9.0" has unmet peer dependency "webpack@^4.4.0".
warning " > react-loadable-ssr-addon@0.2.0" has unmet peer dependency "webpack@>=4.41.1".
warning "react-pose > popmotion-pose > pose-core > rollup-plugin-typescript2@0.25.2" has unmet peer dependency "rollup@>=1.26.3".
warning " > use-react-router@1.0.7" has unmet peer dependency "react-router@^5.0.0".
warning " > copy-webpack-plugin@5.0.5" has unmet peer dependency "webpack@^4.0.0".
warning " > jest-svg-transformer@1.0.0" has unmet peer dependency "jest@>22".
warning " > raw-loader@3.1.0" has unmet peer dependency "webpack@^4.3.0".
warning " > ts-jest@24.1.0" has unmet peer dependency "jest@>=24 <25".
warning " > workbox-webpack-plugin@4.3.1" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
warning " > typedoc@0.17.1" has incorrect peer dependency "typescript@>=3.8.3".
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 9 new dependencies.
info Direct dependencies
└─ typedoc@0.17.1
info All dependencies
├─ backbone@1.4.0
├─ handlebars@4.7.6
├─ highlight.js@9.18.1
├─ jquery@3.5.1
├─ marked@0.8.2
├─ shelljs@0.8.4
├─ typedoc-default-themes@0.8.0
├─ typedoc@0.17.1
└─ underscore@1.10.2
✨  Done in 13.51s.
Gerrit0 commented 4 years ago

That looks like a bug with yarn ^ I'd be open to a PR that adds TS version checking before trying to convert the project to warn the user.

SaharEbrahimii commented 1 year ago

I have this warning with typedoc : DeprecationWarning: 'isIdentifierOrPrivateIdentifier' has been deprecated since v4.2.0. Use isMemberName instead. any idea?