Skip to content

Commit

Permalink
add babel-types deps
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshanmugam committed May 14, 2018
1 parent c26de18 commit 1bdc224
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
5 changes: 4 additions & 1 deletion packages/babel-helper-evaluate-path/package.json
Expand Up @@ -11,5 +11,8 @@
"license": "MIT",
"author": "boopathi",
"main": "lib/index.js",
"repository": "https://github.com/babel/minify/tree/master/packages/babel-helper-evaluate-path"
"repository": "https://github.com/babel/minify/tree/master/packages/babel-helper-evaluate-path",
"dependencies": {
"@babel/types": "^7.0.0-beta.46"
}
}
22 changes: 11 additions & 11 deletions packages/babel-helper-evaluate-path/src/index.js
@@ -1,5 +1,7 @@
"use strict";

const t = require("@babel/types");

module.exports = function evaluate(path, { tdz = false } = {}) {
if (!tdz && !path.isReferencedIdentifier()) {
return baseEvaluate(path);
Expand Down Expand Up @@ -120,15 +122,14 @@ function evaluateBasedOnControlFlow(binding, refPath) {
// early-exit
const declaration = binding.path.parentPath;

if (declaration.parentPath.removed) {
return { confident: true, value: void 0 };
}

if (
declaration.parentPath.isIfStatement() ||
declaration.parentPath.isLoop() ||
declaration.parentPath.isSwitchCase()
t.isIfStatement(declaration.parentPath) ||
t.isLoop(declaration.parentPath) ||
t.isSwitchCase(declaration.parentPath)
) {
if (declaration.parentPath.removed) {
return { confident: true, value: void 0 };
}
return { shouldDeopt: true };
}

Expand Down Expand Up @@ -180,10 +181,9 @@ function evaluateBasedOnControlFlow(binding, refPath) {
const declaration = declarator.parentPath;

if (
declaration.parentPath &&
(declaration.parentPath.isIfStatement() ||
declaration.parentPath.isLoop() ||
declaration.parentPath.isSwitchCase())
t.isIfStatement(declaration.parentPath) ||
t.isLoop(declaration.parentPath) ||
t.isSwitchCase(declaration.parentPath)
) {
return { shouldDeopt: true };
}
Expand Down
@@ -0,0 +1,2 @@
class MyComponent {}
MyComponent.propTypes = { userName: 123 };
@@ -0,0 +1,5 @@
class MyComponent {}

MyComponent.propTypes = {
userName: 123
};
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -504,7 +504,7 @@
invariant "^2.2.0"
lodash "^4.2.0"

"@babel/types@7.0.0-beta.46":
"@babel/types@7.0.0-beta.46", "@babel/types@^7.0.0-beta.46":
version "7.0.0-beta.46"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.46.tgz#eb84399a699af9fcb244440cce78e1acbeb40e0c"
dependencies:
Expand Down

0 comments on commit 1bdc224

Please sign in to comment.