Skip to content

[jsdom] Fixes to compiler errors for Window object#57466

Closed
JumpLink wants to merge 1 commit into
DefinitelyTyped:masterfrom
JumpLink:patch-1
Closed

[jsdom] Fixes to compiler errors for Window object#57466
JumpLink wants to merge 1 commit into
DefinitelyTyped:masterfrom
JumpLink:patch-1

Conversation

@JumpLink
Copy link
Copy Markdown
Contributor

@JumpLink JumpLink commented Dec 1, 2021

When I want to use @types/jsdom in my nest.js project, I get the following error messages:

node_modules/@types/jsdom/base.d.ts(192,18): error TS2411: Property '["Infinity"]' of type 'number' is not assignable to 'number' index type 'Window'.
node_modules/@types/jsdom/base.d.ts(193,18): error TS2411: Property '["NaN"]' of type 'number' is not assignable to 'number' index type 'Window'.

I am not the only one who has this problem, here is a patch that includes the same changes as this pull request: microsoft/vscode-jupyter#7986

Please fill in this template.

Select one of these and delete the others:

If adding a new definition:

  • The package does not already provide its own types, or cannot have its .d.ts files generated via --declaration
  • If this is for an npm package, match the name. If not, do not conflict with the name of an npm package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • Represents shape of module/library correctly
  • tslint.json should contain { "extends": "dtslint/dt.json" }, and no additional rules.
  • tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: <>
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.

If removing a declaration:

  • If a package was never on Definitely Typed, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
  • Delete the package's directory.
  • Add it to notNeededPackages.json.

Fix error messages:
```
node_modules/@types/jsdom/base.d.ts(192,18): error TS2411: Property '["Infinity"]' of type 'number' is not assignable to 'number' index type 'Window'.
node_modules/@types/jsdom/base.d.ts(193,18): error TS2411: Property '["NaN"]' of type 'number' is not assignable to 'number' index type 'Window'.
```
@JumpLink JumpLink closed this Dec 1, 2021
@JumpLink JumpLink deleted the patch-1 branch December 1, 2021 11:22
@paullemoine3
Copy link
Copy Markdown

Did you find a solution ? Because, we experience the same problem on our nestJs project.

@JumpLink
Copy link
Copy Markdown
Contributor Author

JumpLink commented Dec 1, 2021

@paullemoine3 not yet, I have start a discussions here: #57467

Please also let me know if you have a solution

@elovin
Copy link
Copy Markdown

elovin commented Dec 1, 2021

@paullemoine3 Do you use the module yourself or is it just a dependency of one of your dependencies ? I had this problem today but when I checked which modules use @types/jsdom only jest did use it and after I updated to jest 27.4.2 the dependency does no longer exist and I can run build again.

@Parnswir
Copy link
Copy Markdown

Parnswir commented Dec 6, 2021

It's actually v27.4.3 that drops the js-dom dependency and thus fixes the problem.

@thisismydesign
Copy link
Copy Markdown

The problem is still present for those who have to use js-dom :(

@leegee
Copy link
Copy Markdown

leegee commented May 24, 2023

node_modules/@types/jsdom/base.d.ts:194:18 - error TS2411: Property '["Infinity"]' of type 'number' is not assignable to 'number' index type 'Window'.

194         readonly ["Infinity"]: number;
                     ~~~~~~~~~~~~
node_modules/@types/jsdom/base.d.ts:195:18 - error TS2411: Property '["NaN"]' of type 'number' is not assignable to 'number' index type 'Window'.

195         readonly ["NaN"]: number;
                     ~~~~~~~

Latest JSDOM, latest types, same old error. Is there any point opening a new ticket if this one was closed without reason?

@leegee
Copy link
Copy Markdown

leegee commented May 24, 2023

Do I have to do as the VSCode Jupyter folk are doing here, and physically re-write the file in question to fix this issue, on every install?

@sagarsehwag-simpplr
Copy link
Copy Markdown

sagarsehwag-simpplr commented Jul 24, 2023

ERROR in /Users/sagar.sehwag/code/site-fe/node_modules/@types/jsdom/base.d.ts
194:17-29
[tsl] ERROR in /Users/sagar.sehwag/code/site-fe/node_modules/@types/jsdom/base.d.ts(194,18)
      TS2411: Property '["Infinity"]' of type 'number' is not assignable to 'number' index type 'Window'.
ts-loader-default_e3b0c44298fc1c14

ERROR in /Users/sagar.sehwag/code/site-fe/node_modules/@types/jsdom/base.d.ts
195:17-24
[tsl] ERROR in /Users/sagar.sehwag/code/site-fe/node_modules/@types/jsdom/base.d.ts(195,18)
      TS2411: Property '["NaN"]' of type 'number' is not assignable to 'number' index type 'Window'.
ts-loader-default_e3b0c44298fc1c14

this is what my package.json looks like

"jest": "^29.6.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6",
"@types/jest": "^29.5.3",
"jest-environment-jsdom": "^29.6.1",

I'm still facing this issue, has there been any resolution to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants