jest: typedoc throws "Cannot find module '@babel/types'." errors with jest 24

đź’Ą Regression Report

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<...>)'.

Last working version

Worked up to version: ^23.0.0

Stopped working in version: ^24.0.0

To Reproduce

Steps to reproduce the behavior:

$ npm init -y
$ npm install --save-dev typedoc jest
$ npm ls jest typedoc
tests-20190326@1.0.0 /Users/okuryu/work/tests/tests-20190326
├── jest@24.5.0
└── typedoc@0.14.2

$ npx typedoc --out docs index.ts

index.ts

function main () {
}

Expected behavior

The typedoc works well.

Link to repl or repo (highly encouraged)

Please see the repro in “To Reproduce”.

Run 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

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

@okuryu what’s your tsconfig? I think I ran into problems like this because I forgot to set "moduleResolution": "node" at one point

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.

@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…

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.