Running typedoc is fails with following errors after install jest 24. It works well with jest 23.
npx typedoc --out docs index.ts
Using TypeScript 3.2.4 from /Users/okuryu/work/tests/tests-20190326/node_modules/typescript/lib
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__core/index.d.ts(12)
Cannot find module '@babel/types'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__core/index.d.ts(13)
Cannot find module '@babel/parser'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__generator/index.d.ts(8)
Cannot find module '@babel/types'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__template/index.d.ts(8)
Cannot find module '@babel/parser'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__template/index.d.ts(9)
Cannot find module '@babel/types'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__traverse/index.d.ts(9)
Cannot find module '@babel/types'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__traverse/index.d.ts(17)
Property 'scope' of type 'Scope' is not assignable to string index type '(VisitNodeFunction<S, any> & VisitNodeObject<S, any>) | (VisitNodeFunction<S, any> & VisitNodeFunction<S, any>) | (VisitNodeObject<S, any> & VisitNodeObject<S, any>) | (VisitNodeObject<...> & VisitNodeFunction<...>)'.
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__traverse/index.d.ts(18)
Property 'noScope' of type 'boolean' is not assignable to string index type '(VisitNodeFunction<S, any> & VisitNodeObject<S, any>) | (VisitNodeFunction<S, any> & VisitNodeFunction<S, any>) | (VisitNodeObject<S, any> & VisitNodeObject<S, any>) | (VisitNodeObject<...> & VisitNodeFunction<...>)'.
Worked up to version: ^23.0.0
Stopped working in version: ^24.0.0
Steps to reproduce the behavior:
$ npm init -y
$ npm install --save-dev typedoc jest
$ npm ls jest typedoc
[email protected] /Users/okuryu/work/tests/tests-20190326
├── [email protected]
└── [email protected]
$ npx typedoc --out docs index.ts
index.ts
function main () {
}
The typedoc works well.
Please see the repro in "To Reproduce".
npx envinfo --preset jest
Paste the results here:
System:
OS: macOS 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
npmPackages:
jest: ^24.5.0 => 24.5.0
It still occurs with jest 24.6.0 and 24.7.0.
seems to be an issue with @types/babel__core
, not jest?
I cannot determine where the cause of this problem is (typedoc, jest, babel, and typescript) for now.. 😭It worked well at least in older jest v23. Please let me know if you can understand something.
Just look at the error you posted
Error: /Users/okuryu/work/tests/tests-20190326/node_modules/@types/babel__core/index.d.ts(12)
Cannot find module '@babel/types'.
Not sure why though, it seems to be listed correctly in dependencies
https://www.npmjs.com/package/@types/babel__core?activeTab=dependencies
I've never heard of typedoc
maybe they have some bug? If somebody can tell me what Jest is doing wrong, I'm happy to attempt to fix it, but this doesn't seem actionable as is?
I verified this error occurs on installing typedoc
and @types/babel__core
. It may be issue with @types/babel__core
.
I'm not sure details but I found a similar issue about @types/babel__core
's dependencies..
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/27729
Hi,
I have this same error and found this issue when Googling for the string:
Property 'scope' of type 'Scope | undefined' is not assignable to string index type 'VisitNodeObject
As @okuryu suggests it looks like an issue with @types/babel__core
For me a temp fix is to just roll back to both v23:
npm i -D jest@23 babel-jest@23
I hope this helps other until the v24 issue is resolved.
Thanks.
Yup, jest v23 works. I haven't found any fixes yet.
Has anyone reported this upstream?
I just commented on the https://github.com/DefinitelyTyped/DefinitelyTyped/issues/27729#issuecomment-486271169.
@okuryu what’s your tsconfig? I think I ran into problems like this because I forgot to set "moduleResolution": "node"
at one point
@brainkim Thanks for your suggestion!
Hmm, It certainly works when I put the following tsconfig.json
file.
$ cat tsconfig.json
{
"compilerOptions": {
"moduleResolution": "node"
}
}
Is this mean that I need this setting to use the typedoc and jest? I feel a little strange..
@okuryu Yep. I don’t really understand how ts-jest works but I do know there‘s a lot of legacy cruft in the tsconfig.json
for which the defaults don’t make sense. I suggest using the config file provided by running the command tsc --init
just to make sure you understand the options you have available to you.
Not an issue with jest then, so closing. Not sure how to best handle it...
Okay, this is a note for who have encountered the same error. I'm not sure which is the best way, but I confirmed that it works well by using three workarounds.
Option 1. put a small tsconfig.json
file which have a "moduleResolution": "node"
option
$ cat tsconfig.json
{
"compilerOptions": {
"moduleResolution": "node"
}
}
Option 2. put default tsconfig.json
file
$ npm install --save-dev typescript
$ npx tsc --init
note: The moduleResolution
option of the tsconfig.json
seems to be commented out.
Option 3. pass a --moduleResolution node
option for typedoc
like this
$ npx typedoc --out docs --moduleResolution node index.ts
This also works well to me.
@SimenB @brainkim Anyway, thanks a lot for your helps.
"moduleResolution": "node"
in tsconfig.json worked for me 👍
Most helpful comment
@okuryu what’s your tsconfig? I think I ran into problems like this because I forgot to set
"moduleResolution": "node"
at one point