ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
28 lines (26 loc) • 906 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ts = require("typescript");
const manipulation_1 = require("./../../manipulation");
const Node_1 = require("./Node");
class Expression extends Node_1.Node {
/**
* Gets the contextual type of the expression.
*/
getContextualType() {
return this.global.typeChecker.getContextualType(this);
}
/**
* Removes the expression.
*/
remove() {
const parent = this.getParentSyntaxList() || this.getParentOrThrow();
const isCommaSeparatedChild = parent.getPreviousSiblingIfKind(ts.SyntaxKind.OpenParenToken) != null;
if (isCommaSeparatedChild)
manipulation_1.removeCommaSeparatedChild(this);
else
manipulation_1.removeChildren({ children: [this] });
}
}
exports.Expression = Expression;
//# sourceMappingURL=Expression.js.map