index.js 603 B

123456789101112131415161718192021
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.isTransparentExprWrapper = isTransparentExprWrapper;
  6. exports.skipTransparentExprWrappers = skipTransparentExprWrappers;
  7. var t = require("@babel/types");
  8. function isTransparentExprWrapper(node) {
  9. return t.isTSAsExpression(node) || t.isTSTypeAssertion(node) || t.isTSNonNullExpression(node) || t.isTypeCastExpression(node) || t.isParenthesizedExpression(node);
  10. }
  11. function skipTransparentExprWrappers(path) {
  12. while (isTransparentExprWrapper(path.node)) {
  13. path = path.get("expression");
  14. }
  15. return path;
  16. }