[@types/jsdom] Definitions should not depend on "dom" libdefs

Author: sliminalityCreated Feb 16, 2021Updated Sep 17, 2026

Currently, @types/jsdom must be compiled with lib: ["dom"] due to reliance on the DOM library definitions. This is confirmed by one of the authors: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/45173#issuecomment-636448591

However, jsdom is overwhelmingly used on the server/outside the browser, where the native DOM constructors aren't actually available. As a result, it's incredibly unsound to add "dom" to the lib property of tsconfig.json.

For example, the following code will typecheck if it is written in the same file using jsdom:

if (target instanceof HTMLInputElement) { ... }

However, this will fail at runtime since HTMLInputElement is not defined in the global scope on the server.

I recognize that it would be a lot of work to rewrite the definitions to not depend on the "dom" libdefs, but in the current form these types cannot be used safely.

Authors: @leonard-thieu @ExE-Boss @palmfjord

Source: DefinitelyTyped/DefinitelyTyped