Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 27.4.0 TypeScript typechecking fails for @types/jsdom when run without DOM lib #12098

Closed
ryanvanoss opened this issue Nov 29, 2021 · 20 comments · Fixed by #12107
Closed

Comments

@ryanvanoss
Copy link

ryanvanoss commented Nov 29, 2021

Version

27.4.0

Steps to reproduce

See repo at https://github.com/ryanvanoss/jest-27.4-types:

git clone git@github.com:ryanvanoss/jest-27.4-types.git
npm i .
# The main branch pins @jest/* and jest* to 27.3.1; typechecking succeeds
npm run types

# This branch uses jest@27.4.0; typechecking fails
git checkout jest-27.4
git clean -dfx
npm i .
npm run types

# This branch uses jest@27.4.0 and adds ["DOM"] to tsconfig.json's lib configuration; typechecking succeeds
git checkout jest-27.4-with-DOM
git clean -dfx
npm i .
npm run types

Expected behavior

Typechecking should succeed

Actual behavior

Typechecking fails due to missing DOM types:

Click to view failiures
node_modules/@types/jsdom/base.d.ts:24:40 - error TS2304: Cannot find name 'DocumentFragment'.

24         static fragment(html: string): DocumentFragment;
                                          ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:41:28 - error TS2304: Cannot find name 'Node'.

41         nodeLocation(node: Node): ElementLocation | null;
                              ~~~~

node_modules/@types/jsdom/base.d.ts:172:19 - error TS2304: Cannot find name 'HTMLScriptElement'.

172         element?: HTMLScriptElement | HTMLLinkElement | HTMLIFrameElement | HTMLImageElement | undefined;
                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:172:39 - error TS2304: Cannot find name 'HTMLLinkElement'.

172         element?: HTMLScriptElement | HTMLLinkElement | HTMLIFrameElement | HTMLImageElement | undefined;
                                          ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:172:57 - error TS2304: Cannot find name 'HTMLIFrameElement'.

172         element?: HTMLScriptElement | HTMLLinkElement | HTMLIFrameElement | HTMLImageElement | undefined;
                                                            ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:172:77 - error TS2304: Cannot find name 'HTMLImageElement'.

172         element?: HTMLScriptElement | HTMLLinkElement | HTMLIFrameElement | HTMLImageElement | undefined;
                                                                                ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:181:38 - error TS2304: Cannot find name 'Window'.

181     interface DOMWindow extends Omit<Window, "top" | "self" | "window"> {
                                         ~~~~~~

node_modules/@types/jsdom/base.d.ts:185:24 - error TS2304: Cannot find name 'Window'.

185         Window: typeof Window;
                           ~~~~~~

node_modules/@types/jsdom/base.d.ts:250:29 - error TS2304: Cannot find name 'WebAssembly'.

250         WebAssembly: typeof WebAssembly;
                                ~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:253:30 - error TS2304: Cannot find name 'DOMException'.

253         DOMException: typeof DOMException;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:255:21 - error TS2304: Cannot find name 'URL'.

255         URL: typeof URL;
                        ~~~

node_modules/@types/jsdom/base.d.ts:256:33 - error TS2304: Cannot find name 'URLSearchParams'.

256         URLSearchParams: typeof URLSearchParams;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:258:29 - error TS2304: Cannot find name 'EventTarget'.

258         EventTarget: typeof EventTarget;
                                ~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:260:30 - error TS2304: Cannot find name 'NamedNodeMap'.

260         NamedNodeMap: typeof NamedNodeMap;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:261:22 - error TS2304: Cannot find name 'Node'.

261         Node: typeof Node;
                         ~~~~

node_modules/@types/jsdom/base.d.ts:262:22 - error TS2304: Cannot find name 'Attr'.

262         Attr: typeof Attr;
                         ~~~~

node_modules/@types/jsdom/base.d.ts:263:25 - error TS2304: Cannot find name 'Element'.

263         Element: typeof Element;
                            ~~~~~~~

node_modules/@types/jsdom/base.d.ts:264:34 - error TS2304: Cannot find name 'DocumentFragment'.

264         DocumentFragment: typeof DocumentFragment;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:265:35 - error TS2304: Cannot find name 'DOMImplementation'.

265         DOMImplementation: typeof DOMImplementation;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:266:26 - error TS2304: Cannot find name 'Document'.

266         Document: typeof Document;
                             ~~~~~~~~

node_modules/@types/jsdom/base.d.ts:267:30 - error TS2304: Cannot find name 'HTMLDocument'.

267         HTMLDocument: typeof HTMLDocument;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:268:29 - error TS2304: Cannot find name 'XMLDocument'.

268         XMLDocument: typeof XMLDocument;
                                ~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:269:31 - error TS2304: Cannot find name 'CharacterData'.

269         CharacterData: typeof CharacterData;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:270:22 - error TS2304: Cannot find name 'Text'.

270         Text: typeof Text;
                         ~~~~

node_modules/@types/jsdom/base.d.ts:271:30 - error TS2304: Cannot find name 'CDATASection'.

271         CDATASection: typeof CDATASection;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:272:39 - error TS2304: Cannot find name 'ProcessingInstruction'.

272         ProcessingInstruction: typeof ProcessingInstruction;
                                          ~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:273:25 - error TS2304: Cannot find name 'Comment'.

273         Comment: typeof Comment;
                            ~~~~~~~

node_modules/@types/jsdom/base.d.ts:274:30 - error TS2304: Cannot find name 'DocumentType'.

274         DocumentType: typeof DocumentType;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:275:26 - error TS2304: Cannot find name 'NodeList'.

275         NodeList: typeof NodeList;
                             ~~~~~~~~

node_modules/@types/jsdom/base.d.ts:276:32 - error TS2304: Cannot find name 'HTMLCollection'.

276         HTMLCollection: typeof HTMLCollection;
                                   ~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:277:39 - error TS2304: Cannot find name 'HTMLOptionsCollection'.

277         HTMLOptionsCollection: typeof HTMLOptionsCollection;
                                          ~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:278:30 - error TS2304: Cannot find name 'DOMStringMap'.

278         DOMStringMap: typeof DOMStringMap;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:279:30 - error TS2304: Cannot find name 'DOMTokenList'.

279         DOMTokenList: typeof DOMTokenList;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:281:32 - error TS2304: Cannot find name 'StyleSheetList'.

281         StyleSheetList: typeof StyleSheetList;
                                   ~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:283:29 - error TS2304: Cannot find name 'HTMLElement'.

283         HTMLElement: typeof HTMLElement;
                                ~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:284:33 - error TS2304: Cannot find name 'HTMLHeadElement'.

284         HTMLHeadElement: typeof HTMLHeadElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:285:34 - error TS2304: Cannot find name 'HTMLTitleElement'.

285         HTMLTitleElement: typeof HTMLTitleElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:286:33 - error TS2304: Cannot find name 'HTMLBaseElement'.

286         HTMLBaseElement: typeof HTMLBaseElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:287:33 - error TS2304: Cannot find name 'HTMLLinkElement'.

287         HTMLLinkElement: typeof HTMLLinkElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:288:33 - error TS2304: Cannot find name 'HTMLMetaElement'.

288         HTMLMetaElement: typeof HTMLMetaElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:289:34 - error TS2304: Cannot find name 'HTMLStyleElement'.

289         HTMLStyleElement: typeof HTMLStyleElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:290:33 - error TS2304: Cannot find name 'HTMLBodyElement'.

290         HTMLBodyElement: typeof HTMLBodyElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:291:36 - error TS2304: Cannot find name 'HTMLHeadingElement'.

291         HTMLHeadingElement: typeof HTMLHeadingElement;
                                       ~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:292:38 - error TS2304: Cannot find name 'HTMLParagraphElement'.

292         HTMLParagraphElement: typeof HTMLParagraphElement;
                                         ~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:293:31 - error TS2304: Cannot find name 'HTMLHRElement'.

293         HTMLHRElement: typeof HTMLHRElement;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:294:32 - error TS2304: Cannot find name 'HTMLPreElement'.

294         HTMLPreElement: typeof HTMLPreElement;
                                   ~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:295:34 - error TS2304: Cannot find name 'HTMLUListElement'.

295         HTMLUListElement: typeof HTMLUListElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:296:34 - error TS2304: Cannot find name 'HTMLOListElement'.

296         HTMLOListElement: typeof HTMLOListElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:297:31 - error TS2304: Cannot find name 'HTMLLIElement'.

297         HTMLLIElement: typeof HTMLLIElement;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:298:33 - error TS2304: Cannot find name 'HTMLMenuElement'.

298         HTMLMenuElement: typeof HTMLMenuElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:299:34 - error TS2304: Cannot find name 'HTMLDListElement'.

299         HTMLDListElement: typeof HTMLDListElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:300:32 - error TS2304: Cannot find name 'HTMLDivElement'.

300         HTMLDivElement: typeof HTMLDivElement;
                                   ~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:301:35 - error TS2304: Cannot find name 'HTMLAnchorElement'.

301         HTMLAnchorElement: typeof HTMLAnchorElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:302:33 - error TS2304: Cannot find name 'HTMLAreaElement'.

302         HTMLAreaElement: typeof HTMLAreaElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:303:31 - error TS2304: Cannot find name 'HTMLBRElement'.

303         HTMLBRElement: typeof HTMLBRElement;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:304:35 - error TS2304: Cannot find name 'HTMLButtonElement'.

304         HTMLButtonElement: typeof HTMLButtonElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:305:35 - error TS2304: Cannot find name 'HTMLCanvasElement'.

305         HTMLCanvasElement: typeof HTMLCanvasElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:306:33 - error TS2304: Cannot find name 'HTMLDataElement'.

306         HTMLDataElement: typeof HTMLDataElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:307:37 - error TS2304: Cannot find name 'HTMLDataListElement'.

307         HTMLDataListElement: typeof HTMLDataListElement;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:308:36 - error TS2304: Cannot find name 'HTMLDetailsElement'.

308         HTMLDetailsElement: typeof HTMLDetailsElement;
                                       ~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:310:20 - error TS2304: Cannot find name 'HTMLDialogElement'.

310             new(): HTMLDialogElement;
                       ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:311:33 - error TS2304: Cannot find name 'HTMLDialogElement'.

311             readonly prototype: HTMLDialogElement;
                                    ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:313:38 - error TS2304: Cannot find name 'HTMLDirectoryElement'.

313         HTMLDirectoryElement: typeof HTMLDirectoryElement;
                                         ~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:314:37 - error TS2304: Cannot find name 'HTMLFieldSetElement'.

314         HTMLFieldSetElement: typeof HTMLFieldSetElement;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:315:33 - error TS2304: Cannot find name 'HTMLFontElement'.

315         HTMLFontElement: typeof HTMLFontElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:316:33 - error TS2304: Cannot find name 'HTMLFormElement'.

316         HTMLFormElement: typeof HTMLFormElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:317:33 - error TS2304: Cannot find name 'HTMLHtmlElement'.

317         HTMLHtmlElement: typeof HTMLHtmlElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:318:34 - error TS2304: Cannot find name 'HTMLImageElement'.

318         HTMLImageElement: typeof HTMLImageElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:319:34 - error TS2304: Cannot find name 'HTMLInputElement'.

319         HTMLInputElement: typeof HTMLInputElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:320:34 - error TS2304: Cannot find name 'HTMLLabelElement'.

320         HTMLLabelElement: typeof HTMLLabelElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:321:35 - error TS2304: Cannot find name 'HTMLLegendElement'.

321         HTMLLegendElement: typeof HTMLLegendElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:322:32 - error TS2304: Cannot find name 'HTMLMapElement'.

322         HTMLMapElement: typeof HTMLMapElement;
                                   ~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:323:36 - error TS2304: Cannot find name 'HTMLMarqueeElement'.

323         HTMLMarqueeElement: typeof HTMLMarqueeElement;
                                       ~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:324:34 - error TS2304: Cannot find name 'HTMLMediaElement'.

324         HTMLMediaElement: typeof HTMLMediaElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:325:34 - error TS2304: Cannot find name 'HTMLMeterElement'.

325         HTMLMeterElement: typeof HTMLMeterElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:326:32 - error TS2304: Cannot find name 'HTMLModElement'.

326         HTMLModElement: typeof HTMLModElement;
                                   ~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:327:37 - error TS2304: Cannot find name 'HTMLOptGroupElement'.

327         HTMLOptGroupElement: typeof HTMLOptGroupElement;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:328:35 - error TS2304: Cannot find name 'HTMLOptionElement'.

328         HTMLOptionElement: typeof HTMLOptionElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:329:35 - error TS2304: Cannot find name 'HTMLOutputElement'.

329         HTMLOutputElement: typeof HTMLOutputElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:330:36 - error TS2304: Cannot find name 'HTMLPictureElement'.

330         HTMLPictureElement: typeof HTMLPictureElement;
                                       ~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:331:37 - error TS2304: Cannot find name 'HTMLProgressElement'.

331         HTMLProgressElement: typeof HTMLProgressElement;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:332:34 - error TS2304: Cannot find name 'HTMLQuoteElement'.

332         HTMLQuoteElement: typeof HTMLQuoteElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:333:35 - error TS2304: Cannot find name 'HTMLScriptElement'.

333         HTMLScriptElement: typeof HTMLScriptElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:334:35 - error TS2304: Cannot find name 'HTMLSelectElement'.

334         HTMLSelectElement: typeof HTMLSelectElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:335:33 - error TS2304: Cannot find name 'HTMLSlotElement'.

335         HTMLSlotElement: typeof HTMLSlotElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:336:35 - error TS2304: Cannot find name 'HTMLSourceElement'.

336         HTMLSourceElement: typeof HTMLSourceElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:337:33 - error TS2304: Cannot find name 'HTMLSpanElement'.

337         HTMLSpanElement: typeof HTMLSpanElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:338:41 - error TS2304: Cannot find name 'HTMLTableCaptionElement'.

338         HTMLTableCaptionElement: typeof HTMLTableCaptionElement;
                                            ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:339:38 - error TS2304: Cannot find name 'HTMLTableCellElement'.

339         HTMLTableCellElement: typeof HTMLTableCellElement;
                                         ~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:340:37 - error TS2304: Cannot find name 'HTMLTableColElement'.

340         HTMLTableColElement: typeof HTMLTableColElement;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:341:34 - error TS2304: Cannot find name 'HTMLTableElement'.

341         HTMLTableElement: typeof HTMLTableElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:342:33 - error TS2304: Cannot find name 'HTMLTimeElement'.

342         HTMLTimeElement: typeof HTMLTimeElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:343:37 - error TS2304: Cannot find name 'HTMLTableRowElement'.

343         HTMLTableRowElement: typeof HTMLTableRowElement;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:344:41 - error TS2304: Cannot find name 'HTMLTableSectionElement'.

344         HTMLTableSectionElement: typeof HTMLTableSectionElement;
                                            ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:345:37 - error TS2304: Cannot find name 'HTMLTemplateElement'.

345         HTMLTemplateElement: typeof HTMLTemplateElement;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:346:37 - error TS2304: Cannot find name 'HTMLTextAreaElement'.

346         HTMLTextAreaElement: typeof HTMLTextAreaElement;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:347:36 - error TS2304: Cannot find name 'HTMLUnknownElement'.

347         HTMLUnknownElement: typeof HTMLUnknownElement;
                                       ~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:348:34 - error TS2304: Cannot find name 'HTMLFrameElement'.

348         HTMLFrameElement: typeof HTMLFrameElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:349:37 - error TS2304: Cannot find name 'HTMLFrameSetElement'.

349         HTMLFrameSetElement: typeof HTMLFrameSetElement;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:350:35 - error TS2304: Cannot find name 'HTMLIFrameElement'.

350         HTMLIFrameElement: typeof HTMLIFrameElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:351:34 - error TS2304: Cannot find name 'HTMLEmbedElement'.

351         HTMLEmbedElement: typeof HTMLEmbedElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:352:35 - error TS2304: Cannot find name 'HTMLObjectElement'.

352         HTMLObjectElement: typeof HTMLObjectElement;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:353:34 - error TS2304: Cannot find name 'HTMLParamElement'.

353         HTMLParamElement: typeof HTMLParamElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:354:34 - error TS2304: Cannot find name 'HTMLVideoElement'.

354         HTMLVideoElement: typeof HTMLVideoElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:355:34 - error TS2304: Cannot find name 'HTMLAudioElement'.

355         HTMLAudioElement: typeof HTMLAudioElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:356:34 - error TS2304: Cannot find name 'HTMLTrackElement'.

356         HTMLTrackElement: typeof HTMLTrackElement;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:358:28 - error TS2304: Cannot find name 'SVGElement'.

358         SVGElement: typeof SVGElement;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:359:36 - error TS2304: Cannot find name 'SVGGraphicsElement'.

359         SVGGraphicsElement: typeof SVGGraphicsElement;
                                       ~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:360:31 - error TS2304: Cannot find name 'SVGSVGElement'.

360         SVGSVGElement: typeof SVGSVGElement;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:361:33 - error TS2304: Cannot find name 'SVGTitleElement'.

361         SVGTitleElement: typeof SVGTitleElement;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:362:35 - error TS2304: Cannot find name 'SVGAnimatedString'.

362         SVGAnimatedString: typeof SVGAnimatedString;
                                      ~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:363:27 - error TS2304: Cannot find name 'SVGNumber'.

363         SVGNumber: typeof SVGNumber;
                              ~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:364:31 - error TS2304: Cannot find name 'SVGStringList'.

364         SVGStringList: typeof SVGStringList;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:366:23 - error TS2304: Cannot find name 'Event'.

366         Event: typeof Event;
                          ~~~~~

node_modules/@types/jsdom/base.d.ts:367:28 - error TS2304: Cannot find name 'CloseEvent'.

367         CloseEvent: typeof CloseEvent;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:368:29 - error TS2304: Cannot find name 'CustomEvent'.

368         CustomEvent: typeof CustomEvent;
                                ~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:369:30 - error TS2304: Cannot find name 'MessageEvent'.

369         MessageEvent: typeof MessageEvent;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:370:28 - error TS2304: Cannot find name 'ErrorEvent'.

370         ErrorEvent: typeof ErrorEvent;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:371:33 - error TS2304: Cannot find name 'HashChangeEvent'.

371         HashChangeEvent: typeof HashChangeEvent;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:372:31 - error TS2304: Cannot find name 'PopStateEvent'.

372         PopStateEvent: typeof PopStateEvent;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:373:30 - error TS2304: Cannot find name 'StorageEvent'.

373         StorageEvent: typeof StorageEvent;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:374:31 - error TS2304: Cannot find name 'ProgressEvent'.

374         ProgressEvent: typeof ProgressEvent;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:375:37 - error TS2304: Cannot find name 'PageTransitionEvent'.

375         PageTransitionEvent: typeof PageTransitionEvent;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:377:25 - error TS2304: Cannot find name 'UIEvent'.

377         UIEvent: typeof UIEvent;
                            ~~~~~~~

node_modules/@types/jsdom/base.d.ts:378:28 - error TS2304: Cannot find name 'FocusEvent'.

378         FocusEvent: typeof FocusEvent;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:379:28 - error TS2304: Cannot find name 'MouseEvent'.

379         MouseEvent: typeof MouseEvent;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:380:31 - error TS2304: Cannot find name 'KeyboardEvent'.

380         KeyboardEvent: typeof KeyboardEvent;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:381:28 - error TS2304: Cannot find name 'TouchEvent'.

381         TouchEvent: typeof TouchEvent;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:382:34 - error TS2304: Cannot find name 'CompositionEvent'.

382         CompositionEvent: typeof CompositionEvent;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:383:28 - error TS2304: Cannot find name 'WheelEvent'.

383         WheelEvent: typeof WheelEvent;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:385:25 - error TS2304: Cannot find name 'BarProp'.

385         BarProp: typeof BarProp;
                            ~~~~~~~

node_modules/@types/jsdom/base.d.ts:386:26 - error TS2304: Cannot find name 'Location'.

386         Location: typeof Location;
                             ~~~~~~~~

node_modules/@types/jsdom/base.d.ts:387:25 - error TS2304: Cannot find name 'History'.

387         History: typeof History;
                            ~~~~~~~

node_modules/@types/jsdom/base.d.ts:388:24 - error TS2304: Cannot find name 'Screen'.

388         Screen: typeof Screen;
                           ~~~~~~

node_modules/@types/jsdom/base.d.ts:389:29 - error TS2304: Cannot find name 'Performance'.

389         Performance: typeof Performance;
                                ~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:390:27 - error TS2304: Cannot find name 'Navigator'.

390         Navigator: typeof Navigator;
                              ~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:392:29 - error TS2304: Cannot find name 'PluginArray'.

392         PluginArray: typeof PluginArray;
                                ~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:393:31 - error TS2304: Cannot find name 'MimeTypeArray'.

393         MimeTypeArray: typeof MimeTypeArray;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:394:24 - error TS2304: Cannot find name 'Plugin'.

394         Plugin: typeof Plugin;
                           ~~~~~~

node_modules/@types/jsdom/base.d.ts:395:26 - error TS2304: Cannot find name 'MimeType'.

395         MimeType: typeof MimeType;
                             ~~~~~~~~

node_modules/@types/jsdom/base.d.ts:397:28 - error TS2304: Cannot find name 'FileReader'.

397         FileReader: typeof FileReader;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:398:22 - error TS2693: 'Blob' only refers to a type, but is being used as a value here.

398         Blob: typeof Blob;
                         ~~~~

node_modules/@types/jsdom/base.d.ts:399:22 - error TS2304: Cannot find name 'File'.

399         File: typeof File;
                         ~~~~

node_modules/@types/jsdom/base.d.ts:400:26 - error TS2304: Cannot find name 'FileList'.

400         FileList: typeof FileList;
                             ~~~~~~~~

node_modules/@types/jsdom/base.d.ts:401:31 - error TS2304: Cannot find name 'ValidityState'.

401         ValidityState: typeof ValidityState;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:403:27 - error TS2304: Cannot find name 'DOMParser'.

403         DOMParser: typeof DOMParser;
                              ~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:404:31 - error TS2304: Cannot find name 'XMLSerializer'.

404         XMLSerializer: typeof XMLSerializer;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:406:26 - error TS2304: Cannot find name 'FormData'.

406         FormData: typeof FormData;
                             ~~~~~~~~

node_modules/@types/jsdom/base.d.ts:407:43 - error TS2304: Cannot find name 'XMLHttpRequestEventTarget'.

407         XMLHttpRequestEventTarget: typeof XMLHttpRequestEventTarget;
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:408:38 - error TS2304: Cannot find name 'XMLHttpRequestUpload'.

408         XMLHttpRequestUpload: typeof XMLHttpRequestUpload;
                                         ~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:409:32 - error TS2304: Cannot find name 'XMLHttpRequest'.

409         XMLHttpRequest: typeof XMLHttpRequest;
                                   ~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:410:27 - error TS2304: Cannot find name 'WebSocket'.

410         WebSocket: typeof WebSocket;
                              ~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:412:28 - error TS2304: Cannot find name 'NodeFilter'.

412         NodeFilter: typeof NodeFilter;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:413:30 - error TS2304: Cannot find name 'NodeIterator'.

413         NodeIterator: typeof NodeIterator;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:414:28 - error TS2304: Cannot find name 'TreeWalker'.

414         TreeWalker: typeof TreeWalker;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:416:31 - error TS2304: Cannot find name 'AbstractRange'.

416         AbstractRange: typeof AbstractRange;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:417:23 - error TS2304: Cannot find name 'Range'.

417         Range: typeof Range;
                          ~~~~~

node_modules/@types/jsdom/base.d.ts:418:29 - error TS2304: Cannot find name 'StaticRange'.

418         StaticRange: typeof StaticRange;
                                ~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:419:27 - error TS2304: Cannot find name 'Selection'.

419         Selection: typeof Selection;
                              ~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:421:25 - error TS2304: Cannot find name 'Storage'.

421         Storage: typeof Storage;
                            ~~~~~~~

node_modules/@types/jsdom/base.d.ts:423:39 - error TS2304: Cannot find name 'CustomElementRegistry'.

423         CustomElementRegistry: typeof CustomElementRegistry;
                                          ~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:424:28 - error TS2304: Cannot find name 'ShadowRoot'.

424         ShadowRoot: typeof ShadowRoot;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:426:34 - error TS2304: Cannot find name 'MutationObserver'.

426         MutationObserver: typeof MutationObserver;
                                     ~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:427:32 - error TS2304: Cannot find name 'MutationRecord'.

427         MutationRecord: typeof MutationRecord;
                                   ~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:429:25 - error TS2304: Cannot find name 'Headers'.

429         Headers: typeof Headers;
                            ~~~~~~~

node_modules/@types/jsdom/base.d.ts:434:28 - error TS2304: Cannot find name 'StyleSheet'.

434         StyleSheet: typeof StyleSheet;
                               ~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:435:27 - error TS2304: Cannot find name 'MediaList'.

435         MediaList: typeof MediaList;
                              ~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:436:31 - error TS2304: Cannot find name 'CSSStyleSheet'.

436         CSSStyleSheet: typeof CSSStyleSheet;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:437:25 - error TS2304: Cannot find name 'CSSRule'.

437         CSSRule: typeof CSSRule;
                            ~~~~~~~

node_modules/@types/jsdom/base.d.ts:438:30 - error TS2304: Cannot find name 'CSSStyleRule'.

438         CSSStyleRule: typeof CSSStyleRule;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:439:30 - error TS2304: Cannot find name 'CSSMediaRule'.

439         CSSMediaRule: typeof CSSMediaRule;
                                 ~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:440:31 - error TS2304: Cannot find name 'CSSImportRule'.

440         CSSImportRule: typeof CSSImportRule;
                                  ~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:441:37 - error TS2304: Cannot find name 'CSSStyleDeclaration'.

441         CSSStyleDeclaration: typeof CSSStyleDeclaration;
                                        ~~~~~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:445:33 - error TS2304: Cannot find name 'XPathExpression'.

445         XPathExpression: typeof XPathExpression;
                                    ~~~~~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:446:29 - error TS2304: Cannot find name 'XPathResult'.

446         XPathResult: typeof XPathResult;
                                ~~~~~~~~~~~

node_modules/@types/jsdom/base.d.ts:447:32 - error TS2304: Cannot find name 'XPathEvaluator'.

447         XPathEvaluator: typeof XPathEvaluator;
                                   ~~~~~~~~~~~~~~

node_modules/@types/jsdom/ts4.0/index.d.ts:7:28 - error TS2304: Cannot find name 'InputEvent'.

7         InputEvent: typeof InputEvent;
                             ~~~~~~~~~~

node_modules/@types/jsdom/ts4.0/index.d.ts:8:26 - error TS2304: Cannot find name 'External'.

8         External: typeof External;
                           ~~~~~~~~


Found 178 errors.

Additional context

No response

Environment

For the main branch:

  System:
    OS: macOS 12.0.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  npmPackages:
    jest: 27.3.1 => 27.4.0

For the jest-27.4 branch:

  System:
    OS: macOS 12.0.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  npmPackages:
    jest: 27.4.0 => 27.4.0

For the jest-27.4-with-DOM branch:

System:
    OS: macOS 12.0.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  npmPackages:
    jest: 27.4.0 => 27.4.0 
@ryanvanoss
Copy link
Author

Most likely due to #11999 and #12073

@ansgarm
Copy link

ansgarm commented Nov 29, 2021

One possible dependency chain: jest > @jest/core > jest-runner > jest-environment-jsdom > @types/jsdom which causes the types to be installed.
(introduced in #11999)

@ryanvanoss ryanvanoss changed the title [Bug]: 27.4.0 types require DOM lib [Bug]: 27.4.0 TypeScript typechecking fails for @types/jsdom when run without DOM lib Nov 29, 2021
DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 29, 2021
DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 29, 2021
DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 29, 2021
@ryanvanoss
Copy link
Author

ryanvanoss commented Nov 29, 2021

@DanielMSchmidt, I suspect your typechecking fails because you only pinned jest. jest and its related dependencies use the caret range for @jest/* and jest* dependencies, so you're probably still picking up 27.4.0 dependencies even though you're pinning the jest package to a lower version.

https://github.com/ryanvanoss/jest-27.4-types/blob/ae8b692cab2d038126698627a0ec6a0c7f050b6f/package.json#L5

https://github.com/ryanvanoss/jest-27.4-types/blob/ae8b692cab2d038126698627a0ec6a0c7f050b6f/package.json#L8-L12

That's a minimal example, so you may need to pin other Jest-related deps...

@favna
Copy link

favna commented Nov 29, 2021

Temporary work around I applied in the mentioned PR above that will work for Yarn users that also do not even need JSDom (i.e. you only need Node environment), you can add this to your package.json:

{
	"resolutions": {
		"jest-environment-jsdom": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.3.tgz"
	},
}

It's something I made long ago to force skip pesky dependencies that thankfully works in this case.

@Zheoden
Copy link

Zheoden commented Nov 29, 2021

@favna That work around only works for node version >= 14.18.0.

error jest-environment-jsdom@1.1.2: The engine "node" is incompatible with this module. Expected version ">=v14.18.0". Got "14.17.2"
error Found incompatible module.

@favna
Copy link

favna commented Nov 29, 2021

@Zheoden My bad, change the URL to 1.1.3 and you won't get that anymore. That was still a leftover from some bad Renovate Bot config I had a few months ago. I now changed it to >= 14 so it'll allow anything in the major 14 range.

@ravshansbox
Copy link
Contributor

Add "jest-environment-jsdom": "~27.3.1" to resolutions field if you use yarn for a temporary fix.

DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 29, 2021
nex3 added a commit to sass/embedded-host-node that referenced this issue Nov 30, 2021
This is necessary because Jest transitively depends on jsdom, which
won't compile without DOM types ambiently available.

See jestjs/jest#12098
scheibo added a commit to pkmn/smogon that referenced this issue Nov 30, 2021
scheibo added a commit to pkmn/smogon that referenced this issue Nov 30, 2021
@p0vidl0
Copy link

p0vidl0 commented Nov 30, 2021

Add "jest-environment-jsdom": "~27.3.1" to resolutions field if you use yarn for a temporary fix.

Worked with pnpm also, thanks.

DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 30, 2021
DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 30, 2021
DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 30, 2021
DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 30, 2021
DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 30, 2021
@SimenB
Copy link
Member

SimenB commented Nov 30, 2021

DefinitelyTyped/DefinitelyTyped#57432 should solve it. If they don't accept it we can revert here

DanielMSchmidt added a commit to hashicorp/terraform-cdk that referenced this issue Nov 30, 2021
@ryanvanoss
Copy link
Author

Adding dom to tsconfig.json is not an option. Node.js projects don't use it at all, so why add an unused lib?

I think this makes sense for @types/jsdom since it does indeed require a DOM environment. I agree it doesn't make sense to add it at your project level, but adding to jsdom feels like the right way to go.

Thanks @SimenB

@ryanvanoss
Copy link
Author

To clarify, I don't think jest-environment-jsdom should be a transitive dependency for jest (at least not in 27.x). It was pretty confusing seeing jsdom typechecking come into play at all. That said, addressing at the @types/jsdom level feels like a viable bandaid, as I expect removing it would cause regressions and/or warrant a new major.

@SimenB
Copy link
Member

SimenB commented Nov 30, 2021

jest-environment-jsdom will be removed from default dependency tree in Jest 28

@oleggl8
Copy link

oleggl8 commented Nov 30, 2021

Is their any solution for npm users?

dtieber added a commit to dtieber/plain-either that referenced this issue Nov 30, 2021
it's not actually needed but this bug got introduced with jest 27.4: jestjs/jest#12098
@favna
Copy link

favna commented Nov 30, 2021

Is their any solution for npm users?

You can try using https://www.npmjs.com/package/npm-force-resolutions

@wassimoo
Copy link

I temporarily downgraded to "jest": "^26.6.3"

@SimenB
Copy link
Member

SimenB commented Dec 1, 2021

Please give https://github.com/facebook/jest/releases/tag/v27.4.3 a whirl

skorfmann added a commit to hashicorp/terraform-cdk that referenced this issue Dec 1, 2021
* chore(release): Bump version

* chore(release): Update changelog

* Install all npm packges at once

* chore(deps): Try pinning jest as mentioned in jestjs/jest#12098 (comment)

* Drop ts-jest

* Build tsc

* tsc

* .

* evert "."

This reverts commit 1068326.

* tsconfig

* Does it make a difference?

* Revert "tsconfig"

This reverts commit 1789f3d.

* Revert "tsc"

This reverts commit 2092129.

* Revert "Build tsc"

This reverts commit c956aef.

* Revert "Drop ts-jest"

This reverts commit dfa0a97.

* set node options on windows as well

* Update changelog

* Make sure release jobs have similar memory settings /cc @jsteinich

* jest fix

Co-authored-by: Daniel Schmidt <danielmschmidt92@gmail.com>
@ryanvanoss
Copy link
Author

27.4.3 does the trick. Thanks again @SimenB :)

akash1810 added a commit to guardian/cdk that referenced this issue Dec 1, 2021
dtieber added a commit to dtieber/plain-either that referenced this issue Dec 1, 2021
it's not actually needed but this bug got introduced with jest 27.4: jestjs/jest#12098
dtieber added a commit to dtieber/plain-either that referenced this issue Dec 2, 2021
it's not actually needed but this bug got introduced with jest 27.4: jestjs/jest#12098
mergify bot pushed a commit to projen/projen that referenced this issue Dec 2, 2021
Closes #1264

Issue has been fixed upstream in jest@27.4.3 (ref: jestjs/jest#12098)

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
@github-actions
Copy link

github-actions bot commented Jan 1, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants