Definitelytyped: @types/jsdom 11.0.5 causes an error

Created on 7 Jun 2018  ยท  20Comments  ยท  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/jsdom package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript (2.9.1)
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @leonard-thieu

@types/jsdom 11.0.5 causes an following error, 11.0.4 is OK:

node_modules/@types/jsdom/index.d.ts:10:10 - error TS2305: Module '"C:/Users/xxxx/Documents/yyyy/node_modules/@types/jsdom/node_modules/parse5/lib/index"' has no exported member 'ElementLocation'.

10 import { ElementLocation } from 'parse5';
            ~~~~~~~~~~~~~~~

Most helpful comment

i am using the jsdom 16.2 and have the same type import compile error

image

image

any suggestion?

thank you

All 20 comments

+1๏ผŒ rollback to 11.0.4

Not sure how we missed this issue this morning.. We fell into this trap with last night, breaking our build systems. We've temporarily resolved our problems by rolling back to @types/[email protected] but that's not a real solution.

I had a look into this and it seems the issue is with the update to 11.0.5 by @inikulin here: https://github.com/DefinitelyTyped/DefinitelyTyped/commit/f33a9352395f79e968e1c5a1b27640fa6ed73b58#diff-fafb97eb9756a7977e59e4ad8a54b849

I think part of the problem is that the index.d.ts within parse5 v3 and v4 is not valid?

In any case I think the solution to this issue is to rollback the commit, as [email protected] (latest) uses v4.0.0 which contains the MarkupData.ElementLocation definition.

@inikulin any ideas? ๐Ÿ˜ฌ

I have no idea how breaking changes should be managed in TS typings. Note that this will break typings for those who use latest jsdom, since they've updated to last parse5.

I might be missing something but latest [email protected] uses [email protected] which still contains the MarkupData.ElementLocation?
https://github.com/inikulin/parse5/blob/v4.0.0/lib/index.d.ts#L9-L10

So actually the change that was made in f33a935 isn't valid for any current versions of jsdom? Unless perhaps @types/parser5 is installed..

@antonyoneill My bad, it hasn't be merged yet: https://github.com/jsdom/jsdom/pull/2242.

๐Ÿ™Œ Ah! OK perfect. I'm happy to keep my types version locked until jsdom is upgraded to the parse5@5

Will keep an eye on that issue

Ok guys, so which version should I use now becouse I tried a lot of combinations of jsdom, @types/jsdom etc and none is working...

Looks like that didn't work out.

Submitted a PR to try to fix this (https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26421).

I'm not sure if it's a proper fix. The alternative would be to introduce parse5 v3 type declarations and follow https://github.com/DefinitelyTyped/DefinitelyTyped#i-want-to-update-a-package-to-a-new-major-version.

I am still facing this issue. I have rolled back to "jsdom": "^11.5.1" and "@types/jsdom": "^11.0.4" ?

@dhruv2204 #26439 hasn't been merged yet.

11.0.6 works!!
I thank everyone involved in the fix.

@c-yan I'm still having the same problem with 11.0.6. It only works with 11.0.4 or below.

Note that I don't have jsdom as a direct dep., it's a dep. of another 3rd party lib.

@rolandjitsu If you do not use jsdom directly, I think that it is not necessary to install @type/jsdom.

I needed the typings. Even though I don't directly install jsdom, I still can access the jsdom object exposed by jest-environment-jsdom-global package.

Not sure how this could be fixed.

I understand.
Your dependency is "jsdom": "^11.5.1", but latest jsdom is 11.11.0.
I think you need to use old @type/jsdom.

@c-yan I figured, that's why I use 11.0.4 at the moment. Thanks.

i am using the jsdom 16.2 and have the same type import compile error

image

image

any suggestion?

thank you

same issue

@AliRam81 @eugeneshemonaev Downgrading to "@types/jsdom": "^12.2.4" is a workaround for me.

I have been hitting this as well and the problem turns out to be that enzyme is installing cheerio which itself installs parse5@3:

$ npm list parse5
[email protected] /home/alecf/XXX
โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”ฌ [email protected]
โ”‚   โ””โ”€โ”€ [email protected] 
โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”€ [email protected] 
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”ฌ [email protected]
    โ””โ”€โ”€ [email protected] 

and when I look at where stuff actually gets installed (using relative paths just to match the error output)

$ jq .version node_modules/@types/jsdom/../../parse5/package.json
"3.0.3"

I think the problem is that @types/jsdom only depends on @types/parse5, allowing parse5 itself to be out of date:

$ grep parse5 node_modules/@types/jsdom/package.json 
    "@types/parse5": "*",

so one workaround here is to require parse5 directly in your project, which forces the resolution to be parse5, instead of the outdated one from enzyme/cheerio:

$ npm install --save-dev parse5@5
Was this page helpful?
0 / 5 - 0 ratings

Related issues

victor-guoyu picture victor-guoyu  ยท  3Comments

variousauthors picture variousauthors  ยท  3Comments

alisabzevari picture alisabzevari  ยท  3Comments

JudeAlquiza picture JudeAlquiza  ยท  3Comments

jrmcdona picture jrmcdona  ยท  3Comments