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

chore: Migrate bable-plugin-jest-hoist to Typescript #7898

Merged
merged 11 commits into from Feb 16, 2019

Conversation

deneuv34
Copy link
Contributor

@deneuv34 deneuv34 commented Feb 14, 2019

Summary

Migrate babel-plugin-jest-hoist into typescript.

diff --git a/packages/babel-plugin-jest-hoist/build/index.js b/packages/babel-plugin-jest-hoist/build/index.js
index f38181f08..d5d1460ea 100644
--- a/packages/babel-plugin-jest-hoist/build/index.js
+++ b/packages/babel-plugin-jest-hoist/build/index.js
@@ -1,18 +1,22 @@
 'use strict';
 
+Object.defineProperty(exports, '__esModule', {
+  value: true
+});
+exports.default = void 0;
+
 /**
  * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  *
  * This source code is licensed under the MIT license found in the
  * LICENSE file in the root directory of this source tree.
  *
- *
  */
-function invariant(condition, message) {
+const invariant = (condition, message) => {
   if (!condition) {
     throw new Error('babel-plugin-jest-hoist: ' + message);
   }
-} // We allow `jest`, `expect`, `require`, all default Node.js globals and all
+}; // We allow `jest`, `expect`, `require`, all default Node.js globals and all
 // ES2015 built-ins to be used inside of a `jest.mock` factory.
 // We also allow variables prefixed with `mock` as an escape-hatch.
 
@@ -78,7 +82,8 @@ const IDVisitor = {
     this.ids.add(path);
   },
 
-  blacklist: ['TypeAnnotation', 'TSTypeAnnotation', 'TSTypeReference']
+  blacklist: ['TypeAnnotation', 'TSTypeAnnotation', 'TSTypeReference'],
+  ids: new Set()
 };
 const FUNCTIONS = Object.create(null);
 
@@ -167,7 +172,7 @@ FUNCTIONS.deepUnmock = args => args.length === 1 && args[0].isStringLiteral();
 FUNCTIONS.disableAutomock = FUNCTIONS.enableAutomock = args =>
   args.length === 0;
 
-module.exports = () => {
+var _default = () => {
   const shouldHoistExpression = expr => {
     if (!expr.isCallExpression()) {
       return false;
@@ -195,3 +200,5 @@ module.exports = () => {
     }
   };
 };
+
+exports.default = _default;

Test plan

Green CI

@SimenB SimenB added this to the TypeScript Migration milestone Feb 14, 2019
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! left some inline questions 🙂

packages/babel-plugin-jest-hoist/src/index.ts Outdated Show resolved Hide resolved
packages/babel-plugin-jest-hoist/src/index.ts Outdated Show resolved Hide resolved
packages/babel-plugin-jest-hoist/src/index.ts Outdated Show resolved Hide resolved
@deneuv34
Copy link
Contributor Author

sure no problem

@SimenB SimenB merged commit c14a45d into jestjs:master Feb 16, 2019
@SimenB
Copy link
Member

SimenB commented Feb 16, 2019

Thanks @deneuv34!

@deneuv34
Copy link
Contributor Author

@SimenB BTW, thanks for the feedback! 😃

@@ -11,5 +11,12 @@
},
"license": "MIT",
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@types/babel__traverse": "^7.0.6"
Copy link

Choose a reason for hiding this comment

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

Why not install this type as a dev dependency?

Copy link
Member

Choose a reason for hiding this comment

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

It's part of the public interface

@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.

None yet

4 participants