Typedoc: @types/lodash 4.14.74 isn't compatible with TypeScript 2.7.1, update to later version

Created on 31 Jan 2018  ยท  14Comments  ยท  Source: TypeStrong/typedoc

Typedoc has dependency on @types/lodash and this version of lodash's .d.ts file doesn't meet all the constraints checked by the latest version of TypeScript 2.7.1. This causes packages consuming typedoc doc package to fail builds if they try to update to TypeScript 2.7.1. In other words packages using typedoc are blocked from getting the latest features of TypeScript and stuck on 2.6.x

See:
"@types/lodash": "4.14.74",
https://github.com/TypeStrong/typedoc/blob/master/package.json#L36

There are more details and example video here:
Referenced Issue: https://github.com/alexjoverm/typescript-library-starter/issues/172

There are many later version of @type/lodash available that likely have fixed this issue. Since it's such a popular library I'm sure someone else ran into this.

I think fix would be to simply update the dependency of @types/lodash to a later version which has the fix tested against TS 2.7.1 then publish new 0.9.1 version of this package so consuming projects will be unblocked.

Most helpful comment

@presto41 Have you tried [email protected]? I believe that should fix it. Typedoc bundles its own version of typescript so the version you installed does not affect it.

All 14 comments

Idk, now I'm confused because in the build output it says Typedoc uses 2.4.1

Using TypeScript 2.4.1 from D:\repos\ts-lib-starter-test-01node_modulestypedocnode_modulestypescript\lib

Maybe this isn't an issue with typescript afterall.

Either way, this should be fixed now with the v0.10.0 release. We can reopen if it is still a problem.

I'm still seeing this issue. Should we reopen the issue? I've had to lock in to @types/[email protected] for typedoc to run. Because of this, when I try and upgrade to version 0.10.0 of typedoc I get the following failure:

Using TypeScript 2.7.1 from /Users/landonpoch/source/csl/node_modules/typescript/lib Error: /Users/landonpoch/source/csl/node_modules/@types/lodash/index.d.ts(12650) Type 'T' does not satisfy the constraint 'object'.

If I upgrade lodash to the latest then the project will compile but the docs won't generate:

Using TypeScript 2.7.1 from /Users/landonpoch/source/csl/node_modules/typescript/lib /Users/landonpoch/source/csl/node_modules/typedoc/dist/lib/models/types/array.js:37 var elementTypeStr = this.elementType.toString(); TypeError: Cannot read property 'toString' of undefined

This means I can't upgrade to TS 1.7 in my project yet if I want to keep using typedoc.

@landonpoch alexjoverm/typescript-library-starter#172 seems to indicate that their errors were fixed with updating TypeDoc and doing a fresh install. Have you tried clearing your node_modules directory and reinstalling?

@aciccarello - I have indeed done a rm -rf node_modules after an upgrade to 0.10.0 in package.json. Still seeing issues with typedoc and lodash types.

@landonpoch Okay. Do you have a repo where I can reproduce the issue?

@aciccarello - I have tried creating a simple project that can reproduce the issue and I haven't been successful yet. This may actually be a different issue as I'm only seeing it in one of the repositories that we are using typedoc with. I'm going to try to do some more digging but I agree that this shouldn't be opened until I can find good reproducible steps for you.

@aciccarello - Steps to reproduce:

1) Use the latest for typedoc, typescript, lodash and [at]types/lodash
2) Make sure your tsconfig.json has "strictNullChecks": false
3) Run typedoc with --includeDeclarations flag

That should do it. I did some digging by trying to debug typedoc but I'm not all that familiar with the code. However, from what I could see there was an issue getting the type parameter name for the lodash zip function. This is what was causing the this.elementType reference to be undefined in the ArrayType class. No idea why strictNullChecks triggers the issue, but that's what was causing it.

Not sure if you want to reopen this issue or track this as a separate issue.

Closed via #692

I'm still seeing this issue. Here's the relevant portion of my tree in the repro project that I have:

[email protected] /Users/landonpoch/test/repro
โ”œโ”€โ”€ @types/[email protected]
โ””โ”€โ”ฌ [email protected]
โ””โ”€โ”€ @types/[email protected]

[email protected] /Users/landonpoch/test/repro
โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”€ [email protected] deduped
โ””โ”€โ”€ [email protected]

Does typedoc need to be using the latest lodash types for this to work? Maybe I just have a wrong version of one of those packages listed above? Please let me know. Again, I only see the issue if I haven't enabled strict null checks.

I noticed there was also a version bump of typedoc. So I updated that:

@sling/[email protected] /Users/landonpoch/test/repro2
โ”œโ”€โ”€ @types/[email protected]
โ””โ”€โ”ฌ [email protected]
โ””โ”€โ”€ @types/[email protected]

Looks like it's still failing.

`
Using TypeScript 2.7.2 from

.../repro2/node_modules/typedoc/node_modules/typescript/lib
.../repro2/node_modules/typedoc/dist/lib/models/types/array.js:37
var elementTypeStr = this.elementType.toString();
`

On my environment I installed [email protected], [email protected], [email protected] and I've got this same issue too.
The error:

var elementTypeStr = this.elementType.toString();
                                              ^
TypeError: Cannot read property 'toString' of undefined 
at ArrayType.toString (...\node_modules\typedoc\dist\lib\models\types\array.js:37:47)

when I'm trying to recompile my documentation with using includeDeclarations: true option.
I was trying restore my node_modules and I was trying to install the latest version of lodash and all of ways are without success.

Have you got a solution of that problem?

@presto41 Have you tried [email protected]? I believe that should fix it. Typedoc bundles its own version of typescript so the version you installed does not affect it.

@aciccarello thanks a lot for this tip! I didn't know that the [email protected] has been released ! So now I can recompiling my documentation with using includeDeclarations: true option. Now I have to check if it's making my documentation proper but it is not your problem now :) So about inserted the typescript version into typedoc bundle - it was very smart solution ! Thanks a lot once again !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lsagetlethias picture lsagetlethias  ยท  3Comments

nidsharm picture nidsharm  ยท  3Comments

unsafecode picture unsafecode  ยท  4Comments

goodmind picture goodmind  ยท  3Comments

atomsoftwarestudios picture atomsoftwarestudios  ยท  4Comments