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

fix(jest-types): compat with @types/node v16 #11645

Merged
merged 4 commits into from Aug 27, 2021
Merged

Conversation

splincode
Copy link
Contributor

@facebook-github-bot
Copy link
Contributor

Hi @splincode!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@splincode
Copy link
Contributor Author

CLA signed

@codecov-commenter
Copy link

codecov-commenter commented Jul 6, 2021

Codecov Report

Merging #11645 (3652958) into master (315784d) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #11645   +/-   ##
=======================================
  Coverage   69.01%   69.01%           
=======================================
  Files         312      312           
  Lines       16335    16335           
  Branches     4734     4734           
=======================================
  Hits        11273    11273           
  Misses       5034     5034           
  Partials       28       28           
Impacted Files Coverage Δ
packages/jest-fake-timers/src/legacyFakeTimers.ts 94.95% <ø> (ø)
packages/jest-fake-timers/src/modernFakeTimers.ts 85.96% <ø> (ø)
packages/jest-jasmine2/src/pTimeout.ts 100.00% <ø> (ø)
packages/jest-jasmine2/src/queueRunner.ts 100.00% <ø> (ø)
packages/jest-mock/src/index.ts 84.98% <ø> (ø)
packages/jest-util/src/setGlobal.ts 0.00% <ø> (ø)
packages/jest-console/src/BufferedConsole.ts 75.32% <100.00%> (ø)
packages/jest-console/src/CustomConsole.ts 81.69% <100.00%> (ø)
packages/jest-runtime/src/index.ts 58.77% <100.00%> (ø)
packages/jest-util/src/installCommonGlobals.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 315784d...3652958. Read the comment docs.

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Copy link

@72636c 72636c left a comment

Choose a reason for hiding this comment

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

Our CI picked up a few other references across the packages:

node_modules/@jest/console/build/BufferedConsole.d.ts(15,21): error TS2694: Namespace 'NodeJS' has no exported member 'ConsoleConstructor'.
node_modules/@jest/console/build/BufferedConsole.d.ts(23,45): error TS2694: Namespace 'NodeJS' has no exported member 'InspectOptions'.
node_modules/@jest/console/build/CustomConsole.d.ts(18,21): error TS2694: Namespace 'NodeJS' has no exported member 'ConsoleConstructor'.
node_modules/@jest/console/build/CustomConsole.d.ts(26,45): error TS2694: Namespace 'NodeJS' has no exported member 'InspectOptions'.
node_modules/@jest/fake-timers/build/legacyFakeTimers.d.ts(15,43): error TS2694: Namespace 'NodeJS' has no exported member 'Global'.
node_modules/@jest/fake-timers/build/modernFakeTimers.d.ts(17,24): error TS2694: Namespace 'NodeJS' has no exported member 'Global'.
node_modules/@jest/types/build/Config.d.ts(312,38): error TS2694: Namespace 'NodeJS' has no exported member 'Global'.
node_modules/@jest/types/build/Global.d.ts(93,62): error TS2694: Namespace 'NodeJS' has no exported member 'Global'.
node_modules/jest-mock/build/index.d.ts(8,30): error TS2694: Namespace 'NodeJS' has no exported member 'Global'.

packages/jest-types/src/Global.ts Outdated Show resolved Hide resolved
packages/jest-types/src/Config.ts Show resolved Hide resolved
@splincode
Copy link
Contributor Author

@72636c hi, fixed ))

@splincode
Copy link
Contributor Author

@SimenB please, help me about problem with #11640

@mrcnski
Copy link

mrcnski commented Jul 12, 2021

Can a maintainer please provide an update on this? This is causing ecosystem-wide disruption. I've documented only a few instances here.

Also, what is being done to ensure that this does not occur again in the future?

@JustFly1984
Copy link

Having issues with ts checking too with errors:

Namespace 'NodeJS' has no exported member 'ConsoleConstructor'
Namespace 'NodeJS' has no exported member 'InspectOptions'

@rkesters
Copy link

@SimenB @jest-bot Please review

@rkesters
Copy link

@SimenB bump, status?

@rkesters
Copy link

@cpojer please review.

@artekr
Copy link

artekr commented Jul 26, 2021

Any updates for this fix?

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! Could you add a changelog entry?

Also, weird that GH Actions hasn't triggered... Maybe a new commit with a changelog fixes it 🙂

@splincode
Copy link
Contributor Author

Could you add a changelog entry? I didn't quite understand what needs to be done)

@SimenB
Copy link
Member

SimenB commented Aug 13, 2021

Add an entry here describing your change: https://github.com/facebook/jest/blob/master/CHANGELOG.md

@sburba sburba mentioned this pull request Aug 17, 2021
3 tasks
@splincode splincode force-pushed the patch-1 branch 5 times, most recently from ae8f09c to cd4511d Compare August 24, 2021 08:28
@splincode
Copy link
Contributor Author

@SimenB hello, I was updated branch, please review me

@splincode
Copy link
Contributor Author

@SimenB hello, I was updated branch after review))

@splincode splincode requested a review from SimenB August 26, 2021 18:17
@SimenB SimenB merged commit 39190ea into jestjs:master Aug 27, 2021
@SimenB
Copy link
Member

SimenB commented Aug 27, 2021

Thanks @splincode!

@SimenB
Copy link
Member

SimenB commented Aug 27, 2021

https://github.com/facebook/jest/releases/tag/v27.1.0

@breautek

This comment has been minimized.

@SimenB

This comment has been minimized.

@splincode splincode deleted the patch-1 branch August 28, 2021 10:39
@harelmo
Copy link
Contributor

harelmo commented Sep 1, 2021

Is this a breaking change? it seems like Global is now defined as:

export interface Global extends GlobalAdditions, Omit<typeof globalThis, keyof GlobalAdditions> {
    [extras: string]: unknown;
}

breaking our existing declaration of variables set to this.global of the NodeEnvironment:

declare global {
  namespace NodeJS {
    interface Global {
      driver: TestDriver;
      reset(): Promise<void>;
    }
  }
}

class ITEnvironment extends NodeEnvironment {
  async setup(): Promise<void> {
    await super.setup();

    this.global.driver = new TestDriver(...);

    this.global.reset = async () => {
      await this.global.driver.reset();
    };
  }
}
...

that used to work fine until now, but now we're getting:

error TS2571: Object is of type 'unknown'.

           await this.global.driver.reset();
                 ~~~~~~~~~~~~~~~~~~

with jest ~27.1.0 and @types/node at 14.14.0.

Is this by design? are typed exports from global not supported anymore?

@github-actions
Copy link

github-actions bot commented Oct 2, 2021

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 Oct 2, 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.

Getting an Namespace 'NodeJS' has no exported member 'Global' error