index.js 947 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.isTransparentExprWrapper = isTransparentExprWrapper;
  6. exports.skipTransparentExprWrapperNodes = skipTransparentExprWrapperNodes;
  7. exports.skipTransparentExprWrappers = skipTransparentExprWrappers;
  8. var _t = require("@babel/types");
  9. const {
  10. isParenthesizedExpression,
  11. isTSAsExpression,
  12. isTSNonNullExpression,
  13. isTSTypeAssertion,
  14. isTypeCastExpression
  15. } = _t;
  16. function isTransparentExprWrapper(node) {
  17. return isTSAsExpression(node) || isTSTypeAssertion(node) || isTSNonNullExpression(node) || isTypeCastExpression(node) || isParenthesizedExpression(node);
  18. }
  19. function skipTransparentExprWrappers(path) {
  20. while (isTransparentExprWrapper(path.node)) {
  21. path = path.get("expression");
  22. }
  23. return path;
  24. }
  25. function skipTransparentExprWrapperNodes(node) {
  26. while (isTransparentExprWrapper(node)) {
  27. node = node.expression;
  28. }
  29. return node;
  30. }