Newer
Older
alert / js / node_modules / @babel / helper-skip-transparent-expression-wrappers / lib / index.js
@Réz István Réz István on 18 Nov 2021 603 bytes first commit
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.isTransparentExprWrapper = isTransparentExprWrapper;
exports.skipTransparentExprWrappers = skipTransparentExprWrappers;

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

function isTransparentExprWrapper(node) {
  return t.isTSAsExpression(node) || t.isTSTypeAssertion(node) || t.isTSNonNullExpression(node) || t.isTypeCastExpression(node) || t.isParenthesizedExpression(node);
}

function skipTransparentExprWrappers(path) {
  while (isTransparentExprWrapper(path.node)) {
    path = path.get("expression");
  }

  return path;
}