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

jest-environment-jsdom: Set @types/jsdom in dependencies #11999

Merged
merged 3 commits into from
Oct 27, 2021
Merged

jest-environment-jsdom: Set @types/jsdom in dependencies #11999

merged 3 commits into from
Oct 27, 2021

Conversation

Ayc0
Copy link
Contributor

@Ayc0 Ayc0 commented Oct 27, 2021

Summary

I'm using jest-environment-jsdom in one of my repository, but TypeScript is throwing this error when I'm using it:

.yarn/cache/jest-environment-jsdom-npm-27.3.1-2fb8134cca-669c4f417a.zip/node_modules/jest-environment-jsdom/build/index.d.ts:9:23 - error TS7016: Could not find a declaration file for module 'jsdom'. '.yarn/__virtual__/jsdom-virtual-d0a86cff2d/0/cache/jsdom-npm-16.6.0-f5f949a44e-4abf126bba.zip/node_modules/jsdom/lib/api.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/jsdom` if it exists or add a new declaration (.d.ts) file containing `declare module 'jsdom';`

import { JSDOM } from 'jsdom';

And it asks me to install @types/jsdom on my end.

But I think this is due to the fact that jsdom is imported and exposed in the declaration file (see exposed file):

image

In this case, I think that @types/jsdom should be set in the deps instead of devDeps, so that it'd be shipped to users of jest-environment-jsdom

Test plan

When setting those in my yarn berry config (which mimics the fact that @types/jsdom is marked as a dep and not a devDep), the error went away on my end:

image

@Ayc0 Ayc0 changed the title Set @types/jsdom in deps jest-environment-jsdom: Set @types/jsdom in dependencies Oct 27, 2021
@Ayc0 Ayc0 changed the title jest-environment-jsdom: Set @types/jsdom in dependencies jest-environment-jsdom: Set @types/jsdom in dependencies Oct 27, 2021
@Ayc0 Ayc0 changed the title jest-environment-jsdom: Set @types/jsdom in dependencies jest-environment-jsdom: Set @types/jsdom in dependencies Oct 27, 2021
@Ayc0 Ayc0 marked this pull request as ready for review October 27, 2021 08:58
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@SimenB SimenB merged commit 3d04f33 into jestjs:main Oct 27, 2021
@Ayc0 Ayc0 deleted the patch-1 branch October 27, 2021 09:52
@github-actions
Copy link

This pull request 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 Nov 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants