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

expect: Export expect as default export #11490

Closed
wants to merge 1 commit into from

Conversation

NaridaL
Copy link

@NaridaL NaridaL commented May 30, 2021

This allows types to be exported as well.
Fixes #11487
Strictly speaking a breaking change, as expect = require('expect') not longer works, but as this is usually used as a global, this shouldn't be much of an issue.

Summary

To recap #11487 , the "expect" doesn't export the actual Matchers interface which the expect() function returns, but rather an interface which extends Matchers. This means that you can't extend the returned interface with typescript's declaration merging.

This the cleaner solution, which replaces the export = with export default which allows re-exporting types.

Test plan

Is it possible to test the types? packages/expect/src/__tests__/extend.test.ts has TS errors, but still shows up green.

@facebook-github-bot
Copy link
Contributor

Hi @NaridaL!

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!

@NaridaL NaridaL force-pushed the expect-default-export branch 2 times, most recently from 89fffa8 to 0523c5a Compare May 30, 2021 16:22
@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!

This allows types to be exported as well.
Fixes jestjs#11487
Strictly speaking a breaking change, as expect = require('expect') not longer works, but as this is usually used as a global, this shouldn't be much of an issue.
@codecov-commenter
Copy link

Codecov Report

Merging #11490 (70bb15f) into master (82d1a1a) will decrease coverage by 0.00%.
The diff coverage is 9.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11490      +/-   ##
==========================================
- Coverage   68.95%   68.95%   -0.01%     
==========================================
  Files         312      312              
  Lines       16310    16309       -1     
  Branches     4722     4722              
==========================================
- Hits        11247    11246       -1     
  Misses       5035     5035              
  Partials       28       28              
Impacted Files Coverage Δ
...us/src/legacy-code-todo-rewrite/jestAdapterInit.ts 0.00% <0.00%> (ø)
...-circus/src/legacy-code-todo-rewrite/jestExpect.ts 0.00% <ø> (ø)
packages/jest-globals/src/index.ts 100.00% <ø> (ø)
packages/jest-jasmine2/src/jestExpect.ts 0.00% <ø> (ø)
packages/jest-jasmine2/src/setup_jest_globals.ts 0.00% <0.00%> (ø)
packages/expect/src/index.ts 91.83% <100.00%> (-0.06%) ⬇️

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 82d1a1a...70bb15f. Read the comment docs.

@SimenB
Copy link
Member

SimenB commented May 31, 2021

As you note, this is a breaking change so we cannot land it until Jest 28.

@NaridaL
Copy link
Author

NaridaL commented Jun 1, 2021

@SimenB OK, apart from that, is this good to be merged as-is?

@mrazauskas
Copy link
Contributor

Similar refactor already landed with #12344

@SimenB Seems like this PR can be closed. (And related issue as well?)

@SimenB
Copy link
Member

SimenB commented Feb 22, 2022

Good point, thanks! 👍

@SimenB SimenB closed this Feb 22, 2022
@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 Mar 25, 2022
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.

expect.extend: not possible to correctly extend corresponding TypeScript types
5 participants