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

doc: Update ExpectAPI.md #11211

Merged
merged 1 commit into from Mar 25, 2021
Merged

doc: Update ExpectAPI.md #11211

merged 1 commit into from Mar 25, 2021

Conversation

ajubin
Copy link
Contributor

@ajubin ajubin commented Mar 18, 2021

Update doc to add types for custom matchers

Fix : #10642

Summary

Motivation : Copy pasting documentation doesn't work, as mentioned here, #10642

Test plan

@facebook-github-bot
Copy link
Contributor

Hi @ajubin!

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!

@ajubin ajubin marked this pull request as ready for review March 18, 2021 17:27
@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!

@ajubin
Copy link
Contributor Author

ajubin commented Mar 18, 2021

Hi, the CI failed for Node v15.x on windows-latest on install step and for facebook.jest on step macos >run tests whereas it seems ok for every other actions, is it a problem ?

@ajubin ajubin changed the title Update ExpectAPI.md doc: Update ExpectAPI.md Mar 19, 2021
@SimenB
Copy link
Member

SimenB commented Mar 20, 2021

@orta is this correct? I keep getting confused byt how to properly do this 🙈

@orta
Copy link
Member

orta commented Mar 20, 2021

This originally was based on my work in svg-snapshots - it's possible that the Jest types have moved on since but I think the key difference is that mine is in a .ts file and the not working example in #10642 (comment) is in a .d.ts file. They do have different semantics in the type system.

Mine assumes that you will have an import "dep" in each file where you use the matcher. This makes that file get the modification, the new version I think would be a change everywhere (if the .d.ts is in the right spot) which could not be true in the runtime depending on your config

@orta orta closed this Mar 20, 2021
@orta orta reopened this Mar 20, 2021
@ajubin
Copy link
Contributor Author

ajubin commented Mar 24, 2021

Hi, actually on the doc it's a bit unclear how to do it.

@orta
Copy link
Member

orta commented Mar 24, 2021

Sure, then I'd recommend switching the code back, and adding something like:

- _Note_: In TypeScript, when using `@types/jest` for example, you can declare the new `toBeWithinRange` matcher like this:
+ _Note_: In TypeScript, when using `@types/jest` for example, you can declare the new `toBeWithinRange` matcher in the imported module like this:

Which I think makes it clearer overall

@ajubin
Copy link
Contributor Author

ajubin commented Mar 24, 2021

I'll do this :) What about the failing checks ?
And should I update the versionned documentation also ?

@orta
Copy link
Member

orta commented Mar 25, 2021

The fail is unrelated, this should be fine 👍🏻

@orta orta merged commit 1afabf5 into jestjs:master Mar 25, 2021
@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 May 10, 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.

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