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

feat: add sync way of requiring and transpiling module #8808

Merged
merged 2 commits into from
Aug 14, 2019

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Aug 11, 2019

Summary

Builds on #8756 by adding an override that does not require you to handle a promise unless you pass your own function which returns a promise. This is needed for #8330.

I'm not sure I got the type info correct here, can somebody who actually knows TS tell me if this is correct? 😅 If it's hard with overrides, I'm happy to have another go with 2 different methods rather than if (isPromise).

/cc @M4rk9696 @G-Rath

Test plan

Still green CI

(purposefully no changelog entry as it's conceptually part of the unreleased #8756)

Copy link
Contributor

@G-Rath G-Rath left a comment

Choose a reason for hiding this comment

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

If it's passing, I say ship it - I'd also say be careful w/ this pattern, as it's very easy to cause problems w/ things like tooling (in particular b/c you've not got a discriminating parameter i.e usePromise: true).

I'll find out pretty quickly if it's going to cause trouble 😄


I'm a little surprised that compiles:

https://www.typescriptlang.org/play/#code/GYVwdgxgLglg9mABMMAKCBDANlgRhiAawH4AuRVASkQF4A+RAZygCcYwBzS85tzgbgCwAKFCRYCZGkw58RMhWr1EABRZwAtjEYBTADy92HOt1Xqtug6yN0ho8NHhIU6bHgIlyVWgwBucGAATRAAfM01tfUNOE3I1CMto41Cma05EAG8RREQYYFQAQhl3Imos4Ryclh0oEBYkAHIGuxyAXxFsxGra+vCLHQA6asY4LF8dVCbKO3bhERdvZQzWygGoAAsdNGmgA

But it's pretty late for me, so I'm not going to question it.

Copy link
Contributor

@jeysal jeysal left a comment

Choose a reason for hiding this comment

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

Types LGTM ;)

packages/jest-transform/src/ScriptTransformer.ts Outdated Show resolved Hide resolved
@SimenB SimenB merged commit abb760a into jestjs:master Aug 14, 2019
@SimenB SimenB deleted the sync-transform-require branch August 14, 2019 08:33
@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 11, 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.

5 participants