index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. isTSSatisfiesExpression,
  14. isTSTypeAssertion,
  15. isTypeCastExpression
  16. } = _t;
  17. function isTransparentExprWrapper(node) {
  18. return isTSAsExpression(node) || isTSSatisfiesExpression(node) || isTSTypeAssertion(node) || isTSNonNullExpression(node) || isTypeCastExpression(node) || isParenthesizedExpression(node);
  19. }
  20. function skipTransparentExprWrappers(path) {
  21. while (isTransparentExprWrapper(path.node)) {
  22. path = path.get("expression");
  23. }
  24. return path;
  25. }
  26. function skipTransparentExprWrapperNodes(node) {
  27. while (isTransparentExprWrapper(node)) {
  28. node = node.expression;
  29. }
  30. return node;
  31. }
  32. //# sourceMappingURL=index.js.map