UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

24 lines (22 loc) 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); const manipulation_1 = require("./../../manipulation"); const common_1 = require("./../common"); const base_1 = require("./../base"); exports.VariableDeclarationBase = base_1.TypedNode(base_1.InitializerExpressionableNode(base_1.BindingNamedNode(common_1.Node))); class VariableDeclaration extends exports.VariableDeclarationBase { /** * Removes this variable declaration. */ remove() { const variableDeclarationList = this.getParentIfKindOrThrow(ts.SyntaxKind.VariableDeclarationList); const declarations = variableDeclarationList.getDeclarations(); if (declarations.length === 1) variableDeclarationList.getParentIfKindOrThrow(ts.SyntaxKind.VariableStatement).remove(); else manipulation_1.removeCommaSeparatedChild(this, { removePrecedingSpaces: declarations[0] === this ? false : undefined }); } } exports.VariableDeclaration = VariableDeclaration; //# sourceMappingURL=VariableDeclaration.js.map